GroupsController.cs 1018 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using MySqlX.XDevAPI.Relational;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.UserModel;
  11. using NPOI.SS.Util;
  12. using NPOI.XSSF.UserModel;
  13. using OASystem.API.Middlewares;
  14. using OASystem.API.OAMethodLib;
  15. using OASystem.API.OAMethodLib.APNs;
  16. using OASystem.API.OAMethodLib.File;
  17. using OASystem.API.OAMethodLib.Hub.HubClients;
  18. using OASystem.API.OAMethodLib.Hub.Hubs;
  19. using OASystem.API.OAMethodLib.JuHeAPI;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.Financial;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Infrastructure.Repositories.CRM;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using Quartz.Util;
  36. using SqlSugar.Extensions;
  37. using System.Collections;
  38. using System.Data;
  39. using System.Diagnostics;
  40. using System.Globalization;
  41. using System.IO.Compression;
  42. using TencentCloud.Ocr.V20181119.Models;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using Bookmark = Aspose.Words.Bookmark;
  46. using Cell = Aspose.Words.Tables.Cell;
  47. using Table = Aspose.Words.Tables.Table;
  48. namespace OASystem.API.Controllers
  49. {
  50. /// <summary>
  51. /// 团组相关
  52. /// </summary>
  53. //[Authorize]
  54. [Route("api/[controller]/[action]")]
  55. public class GroupsController : ControllerBase
  56. {
  57. private readonly ILogger<GroupsController> _logger;
  58. private readonly GrpScheduleRepository _grpScheduleRep;
  59. private readonly IMapper _mapper;
  60. private readonly DelegationInfoRepository _groupRepository;
  61. private readonly TaskAssignmentRepository _taskAssignmentRep;
  62. private readonly AirTicketResRepository _airTicketResRep;
  63. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  64. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  65. private readonly DelegationEnDataRepository _delegationEnDataRep;
  66. private readonly DelegationVisaRepository _delegationVisaRep;
  67. private readonly VisaPriceRepository _visaPriceRep;
  68. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  69. private readonly HotelPriceRepository _hotelPriceRep;
  70. private readonly CustomersRepository _customersRep;
  71. private readonly MessageRepository _message;
  72. private readonly SqlSugarClient _sqlSugar;
  73. private readonly TourClientListRepository _tourClientListRep;
  74. private readonly TeamRateRepository _teamRateRep;
  75. #region 成本相关
  76. private readonly CheckBoxsRepository _checkBoxs;
  77. private readonly GroupCostRepository _GroupCostRepository;
  78. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  79. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  80. #endregion
  81. private readonly SetDataRepository _setDataRep;
  82. private string url;
  83. private string path;
  84. private readonly EnterExitCostRepository _enterExitCostRep;
  85. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  86. private readonly UsersRepository _usersRep;
  87. private readonly IJuHeApiService _juHeApi;
  88. private readonly InvertedListRepository _invertedListRep;
  89. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  90. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  91. private readonly ThreeCodeRepository _threeCodeRepository;
  92. private readonly HotelInquiryRepository _hotelInquiryRep;
  93. private readonly FeeAuditRepository _feeAuditRep;
  94. private readonly VisaCommissionRepository _visaCommissionRep;
  95. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  96. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  97. private readonly List<CurrencyInfo> _currencyInit;
  98. private readonly List<int> _portTypeData;
  99. private readonly TableOperationRecordRepository _tableorRep;
  100. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  101. private readonly RestaurantRepository _restaurantRep;
  102. /// <summary>
  103. /// 构造函数
  104. /// </summary>
  105. /// <param name="logger"></param>
  106. /// <param name="mapper"></param>
  107. /// <param name="hubContext"></param>
  108. /// <param name="sqlSugar"></param>
  109. /// <param name="grpScheduleRep"></param>
  110. /// <param name="groupRepository"></param>
  111. /// <param name="taskAssignmentRep"></param>
  112. /// <param name="airTicketResRep"></param>
  113. /// <param name="decreasePaymentsRep"></param>
  114. /// <param name="InvitationOfficialActivitiesRep"></param>
  115. /// <param name="delegationEnDataRep"></param>
  116. /// <param name="enterExitCostRep"></param>
  117. /// <param name="delegationVisaRep"></param>
  118. /// <param name="message"></param>
  119. /// <param name="visaPriceRep"></param>
  120. /// <param name="carTouristGuideGroundRep"></param>
  121. /// <param name="checkBoxs"></param>
  122. /// <param name="GroupCostRepository"></param>
  123. /// <param name="CostTypeHotelNumberRepository"></param>
  124. /// <param name="GroupCostParameterRepository"></param>
  125. /// <param name="hotelPriceRep"></param>
  126. /// <param name="customersRep"></param>
  127. /// <param name="setDataRep"></param>
  128. /// <param name="tourClientListRep"></param>
  129. /// <param name="teamRateRep"></param>
  130. /// <param name="usersRep"></param>
  131. /// <param name="juHeApi"></param>
  132. /// <param name="invertedListRep"></param>
  133. /// <param name="visaFeeInfoRep"></param>
  134. /// <param name="ticketBlackCodeRep"></param>
  135. /// <param name="hotelInquiryRep"></param>
  136. /// <param name="threeCodeRepository"></param>
  137. /// <param name="feeAuditRep"></param>
  138. /// <param name="visaCommissionRep"></param>
  139. /// <param name="ffrRep"></param>
  140. /// <param name="opinionaireRep"></param>
  141. /// <param name="tableorRep"></param>
  142. /// <param name="enterExitCostDraftRep"></param>
  143. /// <param name="restaurantRep"></param>
  144. public GroupsController(
  145. ILogger<GroupsController> logger,
  146. IMapper mapper,
  147. IHubContext<ChatHub, IChatClient> hubContext,
  148. SqlSugarClient sqlSugar,
  149. GrpScheduleRepository grpScheduleRep,
  150. DelegationInfoRepository groupRepository,
  151. TaskAssignmentRepository taskAssignmentRep,
  152. AirTicketResRepository airTicketResRep,
  153. DecreasePaymentsRepository decreasePaymentsRep,
  154. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  155. DelegationEnDataRepository delegationEnDataRep,
  156. EnterExitCostRepository enterExitCostRep,
  157. DelegationVisaRepository delegationVisaRep,
  158. MessageRepository message,
  159. VisaPriceRepository visaPriceRep,
  160. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  161. CheckBoxsRepository checkBoxs,
  162. GroupCostRepository GroupCostRepository,
  163. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  164. GroupCostParameterRepository GroupCostParameterRepository,
  165. HotelPriceRepository hotelPriceRep,
  166. CustomersRepository customersRep,
  167. SetDataRepository setDataRep,
  168. TourClientListRepository tourClientListRep,
  169. TeamRateRepository teamRateRep,
  170. UsersRepository usersRep, IJuHeApiService juHeApi,
  171. InvertedListRepository invertedListRep,
  172. VisaFeeInfoRepository visaFeeInfoRep,
  173. TicketBlackCodeRepository ticketBlackCodeRep,
  174. HotelInquiryRepository hotelInquiryRep,
  175. ThreeCodeRepository threeCodeRepository,
  176. FeeAuditRepository feeAuditRep,
  177. VisaCommissionRepository visaCommissionRep,
  178. ForeignReceivablesRepository ffrRep,
  179. OpinionaireRepository opinionaireRep,
  180. TableOperationRecordRepository tableorRep,
  181. EnterExitCostDraftRepository enterExitCostDraftRep,
  182. RestaurantRepository restaurantRep
  183. )
  184. {
  185. _logger = logger;
  186. _mapper = mapper;
  187. _grpScheduleRep = grpScheduleRep;
  188. _groupRepository = groupRepository;
  189. _taskAssignmentRep = taskAssignmentRep;
  190. _airTicketResRep = airTicketResRep;
  191. _sqlSugar = sqlSugar;
  192. url = AppSettingsHelper.Get("ExcelBaseUrl");
  193. path = AppSettingsHelper.Get("ExcelBasePath");
  194. if (!System.IO.Directory.Exists(path))
  195. {
  196. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  197. }
  198. _decreasePaymentsRep = decreasePaymentsRep;
  199. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  200. _delegationEnDataRep = delegationEnDataRep;
  201. _enterExitCostRep = enterExitCostRep;
  202. _delegationVisaRep = delegationVisaRep;
  203. _message = message;
  204. _visaPriceRep = visaPriceRep;
  205. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  206. _checkBoxs = checkBoxs;
  207. _GroupCostRepository = GroupCostRepository;
  208. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  209. _GroupCostParameterRepository = GroupCostParameterRepository;
  210. _hotelPriceRep = hotelPriceRep;
  211. _customersRep = customersRep;
  212. _setDataRep = setDataRep;
  213. _tourClientListRep = tourClientListRep;
  214. _teamRateRep = teamRateRep;
  215. _hubContext = hubContext;
  216. _usersRep = usersRep;
  217. _juHeApi = juHeApi;
  218. _invertedListRep = invertedListRep;
  219. _visaFeeInfoRep = visaFeeInfoRep;
  220. _ticketBlackCodeRep = ticketBlackCodeRep;
  221. _hotelInquiryRep = hotelInquiryRep;
  222. _threeCodeRepository = threeCodeRepository;
  223. _feeAuditRep = feeAuditRep;
  224. _visaCommissionRep = visaCommissionRep;
  225. _ffrRep = ffrRep;
  226. _opinionaireRep = opinionaireRep;
  227. _currencyInit = new List<CurrencyInfo>()
  228. {
  229. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  230. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  231. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  232. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  233. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  234. };
  235. _portTypeData = new List<int>() { 2, 3 };
  236. _tableorRep = tableorRep;
  237. _enterExitCostDraftRep = enterExitCostDraftRep;
  238. _restaurantRep = restaurantRep;
  239. }
  240. #region 流程管控
  241. /// <summary>
  242. /// 获取团组流程管控信息
  243. /// </summary>
  244. /// <param name="_jsonDto"></param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  249. {
  250. if (string.IsNullOrEmpty(_jsonDto.Paras))
  251. {
  252. return Ok(JsonView(false, "参数为空"));
  253. }
  254. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  255. if (_ScheduleDto != null)
  256. {
  257. if (_ScheduleDto.SearchType == 2)//获取列表
  258. {
  259. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  260. return Ok(JsonView(_grpScheduleViewList));
  261. }
  262. else//获取对象
  263. {
  264. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  265. if (_grpScheduleView != null)
  266. {
  267. return Ok(JsonView(_grpScheduleView));
  268. }
  269. }
  270. }
  271. else
  272. {
  273. return Ok(JsonView(false, "参数反序列化失败"));
  274. }
  275. return Ok(JsonView(false, "暂无数据!"));
  276. }
  277. /// <summary>
  278. /// 修改团组流程管控详细表数据
  279. /// </summary>
  280. /// <param name="dto"></param>
  281. /// <returns></returns>
  282. [HttpPost]
  283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  284. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  285. {
  286. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  287. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  288. .SetColumns(it => it.Duty == _detail.Duty)
  289. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  290. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  291. .SetColumns(it => it.JobContent == _detail.JobContent)
  292. .SetColumns(it => it.Remark == _detail.Remark)
  293. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  294. .Where(s => s.Id == dto.Id)
  295. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  296. .ExecuteCommandAsync();
  297. if (result > 0)
  298. {
  299. return Ok(JsonView(true, "保存成功!"));
  300. }
  301. return Ok(JsonView(false, "保存失败!"));
  302. }
  303. /// <summary>
  304. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  305. /// </summary>
  306. /// <param name="dto"></param>
  307. /// <returns></returns>
  308. [HttpPost]
  309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  310. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  311. {
  312. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  313. _detail.IsDel = 1;
  314. _detail.DeleteUserId = dto.Duty;
  315. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  316. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  317. .SetColumns(it => it.IsDel == _detail.IsDel)
  318. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  319. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  320. .Where(it => it.Id == dto.Id)
  321. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  322. //.WhereColumns(s => s.Id == dto.Id)
  323. .ExecuteCommandAsync();
  324. if (result > 0)
  325. {
  326. return Ok(JsonView(true, "删除成功!"));
  327. }
  328. return Ok(JsonView(false, "删除失败!"));
  329. }
  330. /// <summary>
  331. /// 增加团组流程管控详细表数据
  332. /// </summary>
  333. /// <param name="dto"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  337. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  338. {
  339. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  340. if (DateTime.Now < _detail.ExpectBeginDt)
  341. {
  342. _detail.StepStatus = 0;
  343. }
  344. else
  345. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  346. _detail.StepStatus = 1;
  347. }
  348. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  349. if (result > 0)
  350. {
  351. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  352. return Ok(JsonView(true, "添加成功!", _result));
  353. }
  354. return Ok(JsonView(false, "添加失败!"));
  355. }
  356. #endregion
  357. #region 团组基本信息
  358. /// <summary>
  359. /// 接团信息列表
  360. /// </summary>
  361. /// <param name="dto">团组列表请求dto</param>
  362. /// <returns></returns>
  363. [HttpPost]
  364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  365. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  366. {
  367. var groupData = await _groupRepository.GetGroupList(dto);
  368. if (groupData.Code != 0)
  369. {
  370. return Ok(JsonView(false, groupData.Msg));
  371. }
  372. return Ok(JsonView(groupData.Data));
  373. }
  374. /// <summary>
  375. /// 分页查询团组列表
  376. /// </summary>
  377. /// <param name="dto"></param>
  378. /// <returns></returns>
  379. [HttpPost]
  380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  381. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  382. {
  383. var watch = new Stopwatch();
  384. watch.Start();
  385. RefAsync<int> total = 0;
  386. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  387. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  388. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  389. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  390. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  391. .Distinct()
  392. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  393. watch.Stop();
  394. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  395. }
  396. /// <summary>
  397. /// 接团信息列表 Page Init
  398. /// </summary>
  399. /// <returns></returns>
  400. [HttpPost]
  401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  402. public async Task<IActionResult> PostGroupPageListInit()
  403. {
  404. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  405. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  406. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  407. var _view = new
  408. {
  409. depData = depDatas,
  410. rankData = rankDatas
  411. };
  412. return Ok(JsonView(true, "查询成功!", _view));
  413. }
  414. /// <summary>
  415. /// 接团信息列表 Page
  416. /// </summary>
  417. /// <param name="dto">团组列表请求dto</param>
  418. /// <returns></returns>
  419. [HttpPost]
  420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  421. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  422. {
  423. #region 参数验证
  424. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  425. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  426. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  427. #region 页面操作权限验证
  428. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  429. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  430. #endregion
  431. #endregion
  432. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  433. {
  434. string sqlWhere = string.Empty;
  435. if (dto.IsSure == 0) //未完成
  436. {
  437. sqlWhere += string.Format(@" And IsSure = 0");
  438. }
  439. else if (dto.IsSure == 1) //已完成
  440. {
  441. sqlWhere += string.Format(@" And IsSure = 1");
  442. }
  443. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  444. {
  445. string tj = dto.SearchCriteria;
  446. 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}%')",
  447. tj, tj, tj, tj, tj);
  448. }
  449. if (int.TryParse(dto.Rank, out int rankId))
  450. {
  451. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  452. }
  453. string sqlWhere1 = string.Empty;
  454. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  455. {
  456. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  457. }
  458. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  459. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  460. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  461. JietuanOperator,IsSure,CreateTime,IsBid
  462. From (
  463. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  464. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  465. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  466. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  467. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  468. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  469. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  470. From Grp_DelegationInfo gdi
  471. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  472. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  473. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  474. Where gdi.IsDel = 0 {0}
  475. ) temp {1}", sqlWhere, sqlWhere1);
  476. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  477. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  478. var _view = new
  479. {
  480. PageFuncAuth = pageFunAuthView,
  481. Data = _DelegationList
  482. };
  483. return Ok(JsonView(true, "查询成功!", _view, total));
  484. }
  485. else
  486. {
  487. return Ok(JsonView(false, "查询失败"));
  488. }
  489. }
  490. /// <summary>
  491. /// 团组列表
  492. /// </summary>
  493. /// <returns></returns>
  494. [HttpPost]
  495. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  496. {
  497. #region 参数验证
  498. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  499. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  500. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  501. #region 页面操作权限验证
  502. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  503. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  504. #endregion
  505. #endregion
  506. if (dto.PortType != 1 && dto.PortType != 2)
  507. {
  508. return Ok(JsonView(false, "查询失败!"));
  509. }
  510. string orderbyStr = "order by gdi.CreateTime Desc";
  511. string sqlWhere = string.Empty;
  512. if (dto.IsSure == 0) //未完成
  513. {
  514. sqlWhere += string.Format(@" And IsSure = 0");
  515. }
  516. else if (dto.IsSure == 1) //已完成
  517. {
  518. sqlWhere += string.Format(@" And IsSure = 1");
  519. }
  520. //团组类型
  521. if (dto.TeamDid > 0)
  522. {
  523. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  524. }
  525. //团组名称
  526. if (!string.IsNullOrEmpty(dto.TeamName))
  527. {
  528. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  529. }
  530. //客户名称
  531. if (!string.IsNullOrEmpty(dto.ClientName))
  532. {
  533. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  534. }
  535. //客户单位
  536. if (!string.IsNullOrEmpty(dto.ClientUnit))
  537. {
  538. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  539. }
  540. //出访时间
  541. if (!string.IsNullOrEmpty(dto.visitDataTime))
  542. {
  543. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  544. orderbyStr = "order by gdi.VisitDate";
  545. }
  546. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  547. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  548. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  549. JietuanOperator,IsSure,CreateTime
  550. From (
  551. Select row_number() over({0}) as Row_Number,
  552. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  553. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  554. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  555. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  556. From Grp_DelegationInfo gdi
  557. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  558. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  559. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  560. Where gdi.IsDel = 0 {1}
  561. ) temp ", orderbyStr, sqlWhere);
  562. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  563. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  564. #region 处理所属部门
  565. /*
  566. * 1.sq 和 gyy 等显示 市场部
  567. * 2.王鸽和主管及张总还有管理员号统一国交部
  568. * 2-1. 4 管理员 ,21 张海麟
  569. */
  570. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  571. List<int> userIds1 = new List<int>() { 4, 21 };
  572. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  573. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  574. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  575. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  576. .ToList();
  577. foreach (var item in _DelegationList)
  578. {
  579. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  580. }
  581. #endregion
  582. var _view = new
  583. {
  584. PageFuncAuth = pageFunAuthView,
  585. Data = _DelegationList
  586. };
  587. return Ok(JsonView(true, "查询成功!", _view, total));
  588. }
  589. /// <summary>
  590. /// 接团信息详情
  591. /// </summary>
  592. /// <param name="dto">团组info请求dto</param>
  593. /// <returns></returns>
  594. [HttpPost]
  595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  596. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  597. {
  598. var groupData = await _groupRepository.GetGroupInfo(dto);
  599. if (groupData.Code != 0)
  600. {
  601. return Ok(JsonView(false, groupData.Msg));
  602. }
  603. return Ok(JsonView(groupData.Data));
  604. }
  605. /// <summary>
  606. /// 接团信息 编辑添加
  607. /// 基础信息数据源
  608. /// </summary>
  609. /// <param name="dto"></param>
  610. /// <returns></returns>
  611. [HttpPost]
  612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  613. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  614. {
  615. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  616. if (groupData.Code != 0)
  617. {
  618. return Ok(JsonView(false, groupData.Msg));
  619. }
  620. return Ok(JsonView(groupData.Data));
  621. }
  622. /// <summary>
  623. /// 接团信息 操作(增改)
  624. /// </summary>
  625. /// <param name="dto"></param>
  626. /// <returns></returns>
  627. [HttpPost]
  628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  629. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  630. {
  631. // 创建 Stopwatch 实例
  632. Stopwatch stopwatch = Stopwatch.StartNew();
  633. decimal ffrPrice = 0.00M;
  634. DateTime? visitDt = null;
  635. if (dto.Status == 2)
  636. {
  637. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  638. if (groupInfo != null)
  639. {
  640. ffrPrice = groupInfo.PaymentMoney;
  641. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  642. }
  643. }
  644. var groupData = await _groupRepository.GroupOperation(dto);
  645. if (groupData.Code != 0)
  646. {
  647. return Ok(JsonView(false, groupData.Msg));
  648. }
  649. int diId = 0;
  650. try
  651. {
  652. //添加时 默认加入团组汇率
  653. if (dto.Status == 1) //添加
  654. {
  655. diId = groupData.Data;
  656. //添加默认币种
  657. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  658. //默认分配权限
  659. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  660. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  661. var _managerIds = new List<int>() { 22, 32, 21 };
  662. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  663. if (userIds.Count > 0)
  664. {
  665. userIds.Add(208);
  666. //创建团组管控
  667. GroupStepForDelegation.CreateWorkStep(diId);
  668. //发送消息
  669. string groupName = dto.TeamName;
  670. string createGroupUser = string.Empty;
  671. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  672. if (userInfo != null) createGroupUser = userInfo.CnName;
  673. string title = $"系统通知";
  674. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  675. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  676. }
  677. //默认创建倒推表
  678. await _invertedListRep._Create(dto.UserId, diId);
  679. }
  680. else if (dto.Status == 2)
  681. {
  682. diId = dto.Id;
  683. }
  684. #region 签证人员团组时间通知
  685. #region 计算出访起止时间
  686. var startTime = new DateTime();
  687. var endTime = new DateTime();
  688. if (DateTime.TryParse(dto.VisitDate, out startTime))
  689. {
  690. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  691. }
  692. #endregion
  693. #endregion
  694. #region 团组操作默认添加/修改收款账单
  695. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  696. {
  697. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  698. .Where(x => x.IsDel == 0 &&
  699. x.Diid == diId &&
  700. x.Remark.Equals("预付款")
  701. )
  702. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  703. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  704. .FirstAsync();
  705. ffrInfo = new Fin_ForeignReceivables()
  706. {
  707. Diid = diId,
  708. PriceName = dto.ClientUnit,
  709. Price = dto.PaymentMoney,
  710. Count = 1,
  711. Unit = $"元",
  712. ItemSumPrice = dto.PaymentMoney,
  713. Rate = 1.0000M,
  714. Currency = 836,
  715. AddingWay = 0,
  716. CreateUserId = dto.UserId,
  717. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  718. Remark = $"预付款"
  719. };
  720. if (ffrInfo == null) //Add
  721. {
  722. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  723. }
  724. else //修改
  725. {
  726. await _sqlSugar.Updateable(ffrInfo)
  727. .UpdateColumns(x => new
  728. {
  729. x.PriceName,
  730. x.Price,
  731. x.ItemSumPrice,
  732. x.CreateTime,
  733. x.CreateUserId
  734. })
  735. .WhereColumns(x => x.Id)
  736. .ExecuteCommandAsync();
  737. }
  738. }
  739. #endregion
  740. if (diId > 0)
  741. {
  742. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  743. }
  744. // 停止计时
  745. stopwatch.Stop();
  746. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  747. }
  748. catch (Exception ex)
  749. {
  750. // 停止计时
  751. stopwatch.Stop();
  752. Logs("[response]" + JsonConvert.SerializeObject(dto));
  753. Logs(ex.Message);
  754. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  755. }
  756. // 停止计时
  757. stopwatch.Stop();
  758. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  759. }
  760. /// <summary>
  761. /// 接团流程操作(增改)
  762. /// 安卓端使用 建团时添加客户名单
  763. /// </summary>
  764. /// <param name="dto"></param>
  765. /// <returns></returns>
  766. [HttpPost]
  767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  768. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  769. {
  770. #region 参数验证
  771. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  772. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  773. #region 页面操作权限验证
  774. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  775. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  776. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  777. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  778. #endregion
  779. #endregion
  780. try
  781. {
  782. //_sqlSugar.BeginTran();
  783. decimal ffrPrice = 0.00M;
  784. DateTime? visitDt = null;
  785. if (dto.Status == 2)
  786. {
  787. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  788. if (groupInfo != null)
  789. {
  790. ffrPrice = groupInfo.PaymentMoney;
  791. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  792. }
  793. }
  794. var _dto = new GroupOperationDto();
  795. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  796. var groupData = await _groupRepository.GroupOperation(_dto);
  797. if (groupData.Code != 0)
  798. {
  799. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  800. }
  801. int diId = 0;
  802. //添加时 默认加入团组汇率
  803. if (dto.Status == 1) //添加
  804. {
  805. diId = groupData.Data;
  806. //添加默认币种
  807. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  808. //默认分配权限
  809. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  810. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  811. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  812. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  813. if (userIds.Count > 0)
  814. {
  815. userIds.Add(208);
  816. //创建团组管控
  817. GroupStepForDelegation.CreateWorkStep(diId);
  818. //发送消息
  819. string groupName = dto.TeamName;
  820. string createGroupUser = string.Empty;
  821. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  822. if (userInfo != null) createGroupUser = userInfo.CnName;
  823. string title = $"系统通知";
  824. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  825. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  826. }
  827. #region 应用推送
  828. try
  829. {
  830. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  831. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  832. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  833. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  834. {
  835. List<string> userList = new List<string>() { users.QiyeChatUserId };
  836. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  837. }
  838. }
  839. catch (Exception ex)
  840. {
  841. }
  842. #endregion
  843. //默认创建倒推表
  844. await _invertedListRep._Create(dto.UserId, diId);
  845. }
  846. if (dto.Status == 2)
  847. {
  848. diId = dto.Id;
  849. if (diId == 0)
  850. {
  851. //_sqlSugar.RollbackTran();
  852. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  853. }
  854. }
  855. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  856. if (viewData.Code != 0)
  857. {
  858. //_sqlSugar.RollbackTran();
  859. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  860. }
  861. #region 团组操作默认添加/修改收款账单
  862. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  863. {
  864. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  865. .Where(x => x.IsDel == 0 &&
  866. x.Diid == diId &&
  867. x.Remark.Equals("预付款")
  868. )
  869. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  870. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  871. .FirstAsync();
  872. ffrInfo = new Fin_ForeignReceivables()
  873. {
  874. Diid = diId,
  875. PriceName = dto.ClientUnit,
  876. Price = dto.PaymentMoney,
  877. Count = 1,
  878. Unit = $"元",
  879. ItemSumPrice = dto.PaymentMoney,
  880. Rate = 1.0000M,
  881. Currency = 836,
  882. AddingWay = 0,
  883. CreateUserId = dto.UserId,
  884. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  885. Remark = $"预付款"
  886. };
  887. if (ffrInfo == null) //Add
  888. {
  889. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  890. }
  891. else //修改
  892. {
  893. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  894. .UpdateColumns(x => new
  895. {
  896. x.PriceName,
  897. x.Price,
  898. x.ItemSumPrice,
  899. x.CreateTime,
  900. x.CreateUserId
  901. })
  902. .WhereColumns(x => x.Id)
  903. .ExecuteCommandAsync();
  904. }
  905. }
  906. #endregion
  907. #region 签证人员团组时间通知
  908. #region 计算出访起止时间
  909. var startTime = new DateTime();
  910. var endTime = new DateTime();
  911. if (DateTime.TryParse(dto.VisitDate, out startTime))
  912. {
  913. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  914. }
  915. #endregion
  916. if (diId > 0)
  917. {
  918. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  919. }
  920. #endregion
  921. //_sqlSugar.CommitTran();
  922. return Ok(JsonView(true, "添加成功"));
  923. }
  924. catch (Exception ex)
  925. {
  926. _sqlSugar.RollbackTran();
  927. return Ok(JsonView(false, ex.Message));
  928. }
  929. }
  930. /// <summary>
  931. /// 接团流程操作(增改)
  932. /// 安卓端使用 建团时添加客户名单
  933. /// </summary>
  934. /// <param name="dto"></param>
  935. /// <returns></returns>
  936. [HttpPost]
  937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  938. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  939. {
  940. #region 参数验证
  941. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  942. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  943. #region 页面操作权限验证
  944. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  945. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  946. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  947. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  948. #endregion
  949. #endregion
  950. _sqlSugar.BeginTran();
  951. decimal ffrPrice = 0.00M;
  952. DateTime? visitDt = null;
  953. if (dto.Status == 2)
  954. {
  955. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  956. if (groupInfo != null)
  957. {
  958. ffrPrice = groupInfo.PaymentMoney;
  959. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  960. }
  961. }
  962. var _dto = new GroupOperationDto();
  963. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  964. var groupData = await _groupRepository.GroupOperation(_dto);
  965. if (groupData.Code != 0)
  966. {
  967. _sqlSugar.RollbackTran();
  968. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  969. }
  970. try
  971. {
  972. int diId = 0;
  973. //添加时 默认加入团组汇率
  974. if (dto.Status == 1) //添加
  975. {
  976. diId = groupData.Data;
  977. //添加默认币种
  978. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  979. //默认分配权限
  980. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  981. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  982. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  983. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  984. if (userIds.Count > 0)
  985. {
  986. userIds.Add(208);
  987. //创建团组管控
  988. GroupStepForDelegation.CreateWorkStep(diId);
  989. //发送消息
  990. string groupName = dto.TeamName;
  991. string createGroupUser = string.Empty;
  992. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  993. if (userInfo != null) createGroupUser = userInfo.CnName;
  994. string title = $"系统通知";
  995. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  996. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  997. }
  998. #region 应用推送
  999. try
  1000. {
  1001. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1002. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1003. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1004. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1005. {
  1006. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1007. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1008. }
  1009. }
  1010. catch (Exception ex)
  1011. {
  1012. _sqlSugar.CommitTran();
  1013. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1014. }
  1015. #endregion
  1016. //默认创建倒推表
  1017. await _invertedListRep._Create(dto.UserId, diId);
  1018. }
  1019. else if (dto.Status == 2)
  1020. {
  1021. diId = dto.Id;
  1022. if (diId == 0)
  1023. {
  1024. _sqlSugar.RollbackTran();
  1025. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1026. }
  1027. }
  1028. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1029. if (viewData.Code != 0)
  1030. {
  1031. _sqlSugar.RollbackTran();
  1032. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1033. }
  1034. #region 团组操作默认添加/修改收款账单
  1035. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1036. {
  1037. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1038. .Where(x => x.IsDel == 0 &&
  1039. x.Diid == diId &&
  1040. x.Remark.Equals("预付款")
  1041. )
  1042. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1043. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1044. .FirstAsync();
  1045. ffrInfo = new Fin_ForeignReceivables()
  1046. {
  1047. Diid = diId,
  1048. PriceName = dto.ClientUnit,
  1049. Price = dto.PaymentMoney,
  1050. Count = 1,
  1051. Unit = $"元",
  1052. ItemSumPrice = dto.PaymentMoney,
  1053. Rate = 1.0000M,
  1054. Currency = 836,
  1055. AddingWay = 0,
  1056. CreateUserId = dto.UserId,
  1057. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1058. Remark = $"预付款"
  1059. };
  1060. if (ffrInfo == null) //Add
  1061. {
  1062. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1063. }
  1064. else //修改
  1065. {
  1066. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1067. .UpdateColumns(x => new
  1068. {
  1069. x.PriceName,
  1070. x.Price,
  1071. x.ItemSumPrice,
  1072. x.CreateTime,
  1073. x.CreateUserId
  1074. })
  1075. .WhereColumns(x => x.Id)
  1076. .ExecuteCommandAsync();
  1077. }
  1078. }
  1079. #endregion
  1080. #region 签证人员团组时间通知
  1081. #region 计算出访起止时间
  1082. var startTime = new DateTime();
  1083. var endTime = new DateTime();
  1084. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1085. {
  1086. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1087. }
  1088. #endregion
  1089. if (diId > 0)
  1090. {
  1091. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1092. }
  1093. #endregion
  1094. _sqlSugar.CommitTran();
  1095. return Ok(JsonView(true));
  1096. }
  1097. catch (Exception ex)
  1098. {
  1099. _sqlSugar.RollbackTran();
  1100. return Ok(JsonView(false, ex.Message));
  1101. }
  1102. }
  1103. /// <summary>
  1104. /// 接团信息 操作(删除)
  1105. /// </summary>
  1106. /// <param name="dto"></param>
  1107. /// <returns></returns>
  1108. [HttpPost]
  1109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1110. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1111. {
  1112. var diId = dto.Id;
  1113. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1114. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1115. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1116. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1117. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1118. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1119. #endregion
  1120. var groupData = await _groupRepository.GroupDel(dto);
  1121. if (groupData.Code != 0)
  1122. {
  1123. return Ok(JsonView(false, groupData.Msg));
  1124. }
  1125. return Ok(JsonView(true));
  1126. }
  1127. /// <summary>
  1128. /// 获取团组销售报价号
  1129. /// 团组添加时 使用
  1130. /// </summary>
  1131. /// <returns></returns>
  1132. [HttpPost]
  1133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1134. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1135. {
  1136. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1137. if (groupData.Code != 0)
  1138. {
  1139. return Ok(JsonView(false, groupData.Msg));
  1140. }
  1141. object salesQuoteNo = new
  1142. {
  1143. SalesQuoteNo = groupData.Data
  1144. };
  1145. return Ok(JsonView(salesQuoteNo));
  1146. }
  1147. /// <summary>
  1148. /// 设置确认出团
  1149. /// </summary>
  1150. /// <param name="dto"></param>
  1151. /// <returns></returns>
  1152. [HttpPost]
  1153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1154. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1155. {
  1156. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1157. if (groupData.Code != 0)
  1158. {
  1159. return Ok(JsonView(false, groupData.Msg));
  1160. }
  1161. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1162. #region OA消息推送
  1163. try
  1164. {
  1165. string groupName = groupInfo.TeamName;
  1166. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1167. string title = $"系统通知";
  1168. string content = $"团组[{groupName}]已确认出团!";
  1169. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1170. }
  1171. catch (Exception ex)
  1172. {
  1173. }
  1174. #endregion
  1175. #region 应用推送
  1176. try
  1177. {
  1178. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1179. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1180. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1181. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1182. {
  1183. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1184. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1185. }
  1186. }
  1187. catch (Exception ex)
  1188. {
  1189. }
  1190. #endregion
  1191. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1192. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1193. }
  1194. /// <summary>
  1195. /// 获取团组名称data And 签证国别Data
  1196. /// </summary>
  1197. /// <param name="dto"></param>
  1198. /// <returns></returns>
  1199. [HttpPost]
  1200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1201. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1202. {
  1203. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1204. if (groupData.Code != 0)
  1205. {
  1206. return Ok(JsonView(false, groupData.Msg));
  1207. }
  1208. return Ok(JsonView(groupData.Data));
  1209. }
  1210. /// <summary>
  1211. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1212. /// </summary>
  1213. /// <returns></returns>
  1214. [HttpPost]
  1215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1216. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1217. {
  1218. try
  1219. {
  1220. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1221. if (groupData.Code != 0)
  1222. {
  1223. return Ok(JsonView(false, groupData.Msg));
  1224. }
  1225. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1226. }
  1227. catch (Exception ex)
  1228. {
  1229. return Ok(JsonView(false, "程序错误!"));
  1230. throw;
  1231. }
  1232. }
  1233. /// <summary>
  1234. /// 团组清单 Excel
  1235. /// </summary>
  1236. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1237. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1238. /// <returns></returns>
  1239. [HttpGet]
  1240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1241. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1242. {
  1243. DateTime _beginDt, _endDt;
  1244. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1245. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1246. if (!beginBool && !endBool)
  1247. {
  1248. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1249. }
  1250. string sql = string.Format(@"
  1251. SELECT
  1252. ROW_NUMBER,
  1253. Id,
  1254. SalesQuoteNo,
  1255. TourCode,
  1256. TeamTypeId,
  1257. TeamType,
  1258. TeamLevId,
  1259. TeamLev,
  1260. TeamName,
  1261. ClientName,
  1262. ClientUnit,
  1263. VisitDate,
  1264. VisitDays,
  1265. VisitPNumber,
  1266. JietuanOperatorId,
  1267. JietuanOperator,
  1268. IsSure,
  1269. CreateUserName,
  1270. IsBid
  1271. FROM
  1272. (
  1273. SELECT
  1274. ROW_NUMBER() OVER(
  1275. ORDER BY
  1276. gdi.CreateTime Desc
  1277. ) AS ROW_NUMBER,
  1278. gdi.Id,
  1279. SalesQuoteNo,
  1280. TourCode,
  1281. ssd.Id TeamTypeId,
  1282. ssd.Name TeamType,
  1283. ssd1.Id TeamLevId,
  1284. ssd1.Name TeamLev,
  1285. TeamName,
  1286. ClientName,
  1287. ClientUnit,
  1288. VisitDate,
  1289. VisitDays,
  1290. VisitPNumber,
  1291. JietuanOperator JietuanOperatorId,
  1292. su.CnName JietuanOperator,
  1293. IsSure,
  1294. gdi.CreateTime,
  1295. su1.CnName As CreateUserName,
  1296. gdi.IsBid
  1297. FROM
  1298. Grp_DelegationInfo gdi
  1299. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1300. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1301. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1302. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1303. WHERE
  1304. gdi.IsDel = 0
  1305. AND gdi.IsBid = 0
  1306. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1307. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1308. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1309. #region 处理所属部门
  1310. /*
  1311. * 1.sq 和 gyy 等显示 市场部
  1312. * 2.王鸽和主管及张总还有管理员号统一国交部
  1313. * 2-1. 4 管理员 ,21 张海麟
  1314. */
  1315. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1316. List<int> userIds1 = new List<int>() { 4, 21 };
  1317. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1318. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1319. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1320. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1321. .ToListAsync();
  1322. var droupIds = groupList.Select(it => it.Id).ToList();
  1323. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1324. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1325. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1326. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1327. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1328. {
  1329. DiId = tcl.DiId,
  1330. LastName = dc.LastName,
  1331. FirstName = dc.FirstName,
  1332. Sex = dc.Sex,
  1333. Birthday = dc.BirthDay,
  1334. Company = cc.CompanyFullName,
  1335. Job = dc.Job,
  1336. CreateTime = tcl.CreateTime,
  1337. })
  1338. .ToList();
  1339. foreach (var item in groupList)
  1340. {
  1341. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1342. string groupFirstName = "";
  1343. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1344. if (currDatas.Any())
  1345. {
  1346. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1347. }
  1348. item.GroupFirst = groupFirstName;
  1349. }
  1350. #endregion
  1351. #region Excel
  1352. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1353. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1354. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1355. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1356. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1357. //载入模板
  1358. WorkbookDesigner designer = new WorkbookDesigner();
  1359. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1360. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1361. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1362. dt.TableName = "GroupList";
  1363. designer.SetDataSource(dt);
  1364. designer.Process();
  1365. if (!Directory.Exists(savePath))
  1366. {
  1367. Directory.CreateDirectory(savePath);
  1368. }
  1369. string serverPath = $"{savePath}{fileName}";
  1370. designer.Workbook.Save(serverPath);
  1371. string rst = $"{servicePath}{ftpPath}{fileName}";
  1372. #endregion
  1373. return Ok(JsonView(true, "操作成功!", rst));
  1374. }
  1375. #endregion
  1376. #region 团组&签证
  1377. /// <summary>
  1378. /// 根据团组Id获取签证客户信息List
  1379. /// </summary>
  1380. /// <param name="dto">请求dto</param>
  1381. /// <returns></returns>
  1382. [HttpPost]
  1383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1384. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1385. {
  1386. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1387. if (groupData.Code != 0)
  1388. {
  1389. return Ok(JsonView(false, groupData.Msg));
  1390. }
  1391. return Ok(JsonView(groupData.Data));
  1392. }
  1393. /// <summary>
  1394. /// IOS获取团组签证拍照上传进度01(团组列表)
  1395. /// </summary>
  1396. /// <param name="dto">请求dto</param>
  1397. /// <returns></returns>
  1398. [HttpPost]
  1399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1400. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1401. {
  1402. if (dto == null)
  1403. {
  1404. return Ok(JsonView(false, "参数为空"));
  1405. }
  1406. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1407. return Ok(JsonView(visaList));
  1408. }
  1409. /// <summary>
  1410. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1411. /// </summary>
  1412. /// <returns></returns>
  1413. [HttpPost]
  1414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1415. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1416. {
  1417. if (dto == null)
  1418. {
  1419. return Ok(JsonView(false, "请求错误:"));
  1420. }
  1421. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1422. return Ok(JsonView(list));
  1423. }
  1424. /// <summary>
  1425. /// IOS获取团组签证拍照上传进度03(相册)
  1426. /// </summary>
  1427. /// <returns></returns>
  1428. [HttpPost]
  1429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1430. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1431. {
  1432. if (dto == null)
  1433. {
  1434. return Ok(JsonView(false, "请求错误:"));
  1435. }
  1436. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1437. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1438. list.ForEach(s => s.url = url);
  1439. return Ok(JsonView(list));
  1440. }
  1441. /// <summary>
  1442. /// IOS获取团组签证拍照上传进度04(图片上传)
  1443. /// </summary>
  1444. /// <param name="dto"></param>
  1445. /// <returns></returns>
  1446. [HttpPost]
  1447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1448. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1449. {
  1450. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1451. //if (!string.IsNullOrEmpty(result))
  1452. //{
  1453. //}
  1454. //else {
  1455. // return Ok(JsonView(false, "上传失败"));
  1456. //}
  1457. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1458. int sucNum = 0;
  1459. try
  1460. {
  1461. foreach (var item in dto.base64DataList)
  1462. {
  1463. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1464. string result = DecodeBase64ToImage(item, imageName);
  1465. if (!string.IsNullOrEmpty(result))
  1466. {
  1467. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1468. pic.CreateUserId = dto.CreateUserId;
  1469. pic.PicName = imageName;
  1470. pic.PicPath = result;
  1471. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1472. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1473. if (insertResult > 0)
  1474. {
  1475. sucNum++;
  1476. }
  1477. }
  1478. }
  1479. }
  1480. catch (Exception ex)
  1481. {
  1482. return Ok(JsonView(false, ex.Message));
  1483. }
  1484. string msg = string.Format(@"成功上传{0}张", sucNum);
  1485. return Ok(JsonView(true, msg));
  1486. }
  1487. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1488. {
  1489. string filename = "";//声明一个string类型的相对路径
  1490. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1491. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1492. try//会有异常抛出,try,catch一下
  1493. {
  1494. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1495. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1496. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1497. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1498. //文件名称
  1499. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1500. //上传的文件的路径
  1501. string filePath = "";
  1502. if (!Directory.Exists(fileDir))
  1503. {
  1504. Directory.CreateDirectory(fileDir);
  1505. }
  1506. //上传的文件的路径
  1507. filePath = fileDir + filename;
  1508. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1509. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1510. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1511. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1512. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1513. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1514. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1515. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1516. bitmap.Dispose();
  1517. }
  1518. catch (Exception e)
  1519. {
  1520. string massage = e.Message;
  1521. Logs("IOS图片上传Error:" + massage);
  1522. //filename = e.Message;
  1523. }
  1524. return filename;//返回相对路径
  1525. }
  1526. /// <summary>
  1527. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1528. /// </summary>
  1529. /// <param name="dto"></param>
  1530. /// <returns></returns>
  1531. [HttpPost]
  1532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1533. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1534. {
  1535. if (dto == null)
  1536. {
  1537. return Ok(JsonView(false, "请求错误:"));
  1538. }
  1539. string msg = "参数错误";
  1540. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1541. {
  1542. try
  1543. {
  1544. //_delegationVisaRep.BeginTran();
  1545. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1546. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1547. .Where(s => s.Id == dto.visaProgressCustomerId)
  1548. .ExecuteCommandAsync();
  1549. if (updCount > 0 && dto.publishCode == 1)
  1550. {
  1551. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1552. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1553. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1554. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1555. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1556. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1557. if (groupData == null)
  1558. {
  1559. _delegationVisaRep.RollbackTran();
  1560. }
  1561. string title = string.Format(@"[签证进度更新]");
  1562. string content = string.Format(@"测试文本");
  1563. bool rst = await _message.AddMsg(new MessageDto()
  1564. {
  1565. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1566. IssuerId = dto.publisher,
  1567. Title = title,
  1568. Content = content,
  1569. ReleaseTime = DateTime.Now,
  1570. UIdList = new List<int> {
  1571. 234
  1572. }
  1573. });
  1574. if (rst)
  1575. {
  1576. return Ok(JsonView(true, "发送通知成功"));
  1577. }
  1578. }
  1579. //_delegationVisaRep.CommitTran();
  1580. }
  1581. catch (Exception)
  1582. {
  1583. //_delegationVisaRep.RollbackTran();
  1584. }
  1585. }
  1586. return Ok(JsonView(true, msg));
  1587. }
  1588. #endregion
  1589. #region 团组任务分配
  1590. /// <summary>
  1591. /// 团组任务分配初始化
  1592. /// </summary>
  1593. /// <returns></returns>
  1594. [HttpPost]
  1595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1596. public async Task<IActionResult> GetTaskAssignmen()
  1597. {
  1598. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1599. if (groupData.Code != 0)
  1600. {
  1601. return Ok(JsonView(false, groupData.Msg));
  1602. }
  1603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1604. }
  1605. /// <summary>
  1606. /// 团组任务分配查询
  1607. /// </summary>
  1608. /// <param name="dto"></param>
  1609. /// <returns></returns>
  1610. [HttpPost]
  1611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1612. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1613. {
  1614. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1615. if (groupData.Code != 0)
  1616. {
  1617. return Ok(JsonView(false, groupData.Msg));
  1618. }
  1619. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1620. }
  1621. /// <summary>
  1622. /// 团组任务分配操作
  1623. /// </summary>
  1624. /// <param name="dto"></param>
  1625. /// <returns></returns>
  1626. [HttpPost]
  1627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1628. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1629. {
  1630. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1631. if (groupData.Code != 0)
  1632. {
  1633. return Ok(JsonView(false, groupData.Msg));
  1634. }
  1635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1636. }
  1637. /// <summary>
  1638. /// 团组任务分配
  1639. /// 批量分配
  1640. /// 查询团组
  1641. /// </summary>
  1642. /// <param name="dto"></param>
  1643. /// <returns></returns>
  1644. [HttpPost]
  1645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1646. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1647. {
  1648. //参数验证
  1649. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1650. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1651. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1652. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1653. }
  1654. /// <summary>
  1655. /// 团组任务分配
  1656. /// 批量分配
  1657. /// </summary>
  1658. /// <param name="dto"></param>
  1659. /// <returns></returns>
  1660. [HttpPost]
  1661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1662. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1663. {
  1664. //参数验证
  1665. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1666. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1667. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1668. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1669. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1670. }
  1671. #endregion
  1672. #region 团组费用审核
  1673. /// <summary>
  1674. /// 费用审核
  1675. /// 团组列表 Page
  1676. /// </summary>
  1677. /// <param name="_dto">团组列表请求dto</param>
  1678. /// <returns></returns>
  1679. [HttpPost]
  1680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1681. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1682. {
  1683. #region 参数验证
  1684. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1685. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1687. #region 页面操作权限验证
  1688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1689. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1690. #endregion
  1691. #endregion
  1692. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1693. {
  1694. string sqlWhere = string.Empty;
  1695. if (_dto.IsSure == 0) //未完成
  1696. {
  1697. sqlWhere += string.Format(@" And IsSure = 0");
  1698. }
  1699. else if (_dto.IsSure == 1) //已完成
  1700. {
  1701. sqlWhere += string.Format(@" And IsSure = 1");
  1702. }
  1703. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1704. {
  1705. string tj = _dto.SearchCriteria;
  1706. 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}%')",
  1707. tj, tj, tj, tj, tj);
  1708. }
  1709. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1710. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1711. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1712. From (
  1713. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1714. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1715. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1716. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1717. From Grp_DelegationInfo gdi
  1718. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1719. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1720. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1721. Where gdi.IsDel = 0 {0}
  1722. ) temp ", sqlWhere);
  1723. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1724. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1725. var _view = new
  1726. {
  1727. PageFuncAuth = pageFunAuthView,
  1728. Data = _DelegationList
  1729. };
  1730. return Ok(JsonView(true, "查询成功!", _view, total));
  1731. }
  1732. else
  1733. {
  1734. return Ok(JsonView(false, "查询失败"));
  1735. }
  1736. }
  1737. /// <summary>
  1738. /// 获取团组费用审核
  1739. /// </summary>
  1740. /// <param name="_dto"></param>
  1741. /// <returns></returns>
  1742. [HttpPost]
  1743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1744. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1745. {
  1746. try
  1747. {
  1748. #region 参数验证
  1749. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1750. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1751. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1752. #region 页面操作权限验证
  1753. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1755. #endregion
  1756. #endregion
  1757. var _view = new Grp_CreditCardPaymentView();
  1758. var clientNameList = getSimplClientList(_dto.DiId);
  1759. #region 费用清单
  1760. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1761. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1762. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1763. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1764. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1765. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1766. /*
  1767. * 76://酒店预订
  1768. */
  1769. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1770. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1771. /*
  1772. * 79://车/导游地接
  1773. */
  1774. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1776. /*
  1777. * 80: //签证
  1778. */
  1779. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1780. /*
  1781. *81: //邀请/公务活动
  1782. */
  1783. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1784. /*
  1785. * 82: //团组客户保险
  1786. */
  1787. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1788. /*
  1789. * Lable = 85 机票预订
  1790. */
  1791. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1792. /*
  1793. * 85 机票预定
  1794. */
  1795. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1796. /*
  1797. * 98 其他款项
  1798. */
  1799. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 285:收款退还
  1802. */
  1803. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1804. /*
  1805. * 1015: //超支费用
  1806. */
  1807. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1808. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1809. /*
  1810. * 币种信息
  1811. */
  1812. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1813. /*
  1814. * 车/导游地接 费用类型
  1815. */
  1816. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1817. /*
  1818. * 车/导游地接 费用类型
  1819. */
  1820. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1821. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1822. /*
  1823. * 用户信息
  1824. */
  1825. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1826. /*
  1827. * 费用模块
  1828. */
  1829. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1830. string priceModule = string.Empty;
  1831. if (sdPriceName != null)
  1832. {
  1833. priceModule = sdPriceName.Name;
  1834. }
  1835. /*
  1836. * 成本信息
  1837. */
  1838. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1839. decimal _groupRate = 0.0000M;
  1840. string _groupCurrencyCode = "-";
  1841. if (groupCost != null)
  1842. {
  1843. _groupRate = groupCost.Rate;
  1844. if (int.TryParse(groupCost.Currency, out int _currency))
  1845. {
  1846. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1847. }
  1848. else _groupCurrencyCode = groupCost.Currency;
  1849. }
  1850. string costContentSql = $"Select * From Grp_GroupCost";
  1851. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1852. //处理日期为空的天数
  1853. for (int i = 0; i < groupCostDetails.Count; i++)
  1854. if (i != 0)
  1855. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1856. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1857. /*
  1858. * 处理详情数据
  1859. */
  1860. foreach (var entity in entityList)
  1861. {
  1862. var _detail = new Grp_CreditCardPaymentDetailView();
  1863. _detail.Id = entity.Id;
  1864. _detail.PriceName = priceModule;
  1865. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1866. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1867. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1868. //处理金额
  1869. if (entity.CTable == 1015)
  1870. {
  1871. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1872. if (czInfo != null)
  1873. {
  1874. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1875. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1876. }
  1877. }
  1878. /*
  1879. * 应付款金额
  1880. */
  1881. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1882. string PaymentCurrency_WaitPay = "Unknown";
  1883. string hotelCurrncyCode = "Unknown";
  1884. string hotelCurrncyName = "Unknown";
  1885. if (sdPaymentCurrency_WaitPay != null)
  1886. {
  1887. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1888. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1889. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1890. if (hotelCurrncyCode.Equals("CNY"))
  1891. {
  1892. entity.DayRate = 1.0000M;
  1893. }
  1894. }
  1895. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1896. /*
  1897. * 此次付款金额
  1898. */
  1899. decimal CurrPayStr = 0.00M,
  1900. OriginalCurrPay = 0.00M;
  1901. if (entity.PayPercentage == 0)
  1902. {
  1903. if (entity.PayThenMoney != 0)
  1904. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1905. }
  1906. else
  1907. {
  1908. if (entity.PayMoney != 0)
  1909. {
  1910. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1911. }
  1912. }
  1913. //if (_dto.Label == 79)
  1914. //{
  1915. // string original = string.Empty;
  1916. // if (hotelCurrncyCode.Equals("CNY"))
  1917. // {
  1918. // OriginalCurrPay = CurrPayStr;
  1919. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1920. // }
  1921. // else
  1922. // {
  1923. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1924. // //760 EUR(7600.00 CNY)
  1925. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1926. // }
  1927. //}
  1928. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1929. string original = string.Empty;
  1930. if (hotelCurrncyCode.Equals("CNY"))
  1931. {
  1932. OriginalCurrPay = CurrPayStr;
  1933. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1934. }
  1935. else
  1936. {
  1937. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1938. //760 EUR(7600.00 CNY)
  1939. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1940. }
  1941. /*
  1942. * 剩余尾款
  1943. */
  1944. decimal BalanceStr = 0;
  1945. if (CurrPayStr != 0)
  1946. {
  1947. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1948. BalanceStr = 0;
  1949. else
  1950. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1951. }
  1952. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1953. /*
  1954. * Bus名称
  1955. */
  1956. _detail.BusName = "待增加";
  1957. /*
  1958. *费用所属
  1959. */
  1960. switch (entity.CTable)
  1961. {
  1962. case 76://酒店预订
  1963. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1964. if (hotelReservations != null)
  1965. {
  1966. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1967. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1968. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1969. string roomFeeStr = "", roomFeestr1 = "";
  1970. //是否比较房型价格
  1971. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1972. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1973. roomFeeStr += $"<br/>";
  1974. var roomTotal = 0.00M;
  1975. if (hotelReservations.SingleRoomPrice > 0)
  1976. {
  1977. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1978. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1979. //__isSingle = true;
  1980. roomTotal += fee;
  1981. }
  1982. if (hotelReservations.DoubleRoomPrice > 0)
  1983. {
  1984. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1985. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1986. // __isDouble = true;
  1987. roomTotal += fee;
  1988. }
  1989. if (hotelReservations.SuiteRoomPrice > 0)
  1990. {
  1991. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1992. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1993. //__isSuite = true;
  1994. roomTotal += fee;
  1995. }
  1996. if (hotelReservations.OtherRoomPrice > 0)
  1997. {
  1998. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1999. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2000. //__isOther = true;
  2001. roomTotal += fee;
  2002. }
  2003. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2004. else roomFeeStr += " 0.00 * 0";
  2005. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2006. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2007. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2008. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2009. /*
  2010. * 费用类型
  2011. * 1:房费
  2012. * 2:早餐
  2013. * 3:地税
  2014. * 4:城市税
  2015. * </summary>
  2016. */
  2017. //地税
  2018. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2019. if (governmentRentData != null)
  2020. {
  2021. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2022. governmentRentFee = governmentRentData.Price;
  2023. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2024. if (governmentRentCurrData != null)
  2025. {
  2026. governmentRentCode = governmentRentCurrData.Name;
  2027. governmentRentName = $"({governmentRentCurrData.Remark})";
  2028. }
  2029. }
  2030. //城市税
  2031. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2032. if (cityTaxData != null)
  2033. {
  2034. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2035. cityTaxFee = cityTaxData.Price;
  2036. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2037. if (cityTaxCurrData != null)
  2038. {
  2039. cityTaxCode = cityTaxCurrData.Name;
  2040. cityTaxName = $"({cityTaxCurrData.Remark})";
  2041. }
  2042. }
  2043. //酒店早餐
  2044. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2045. if (breakfastData != null)
  2046. {
  2047. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2048. breakfastFee = breakfastData.Price;
  2049. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2050. if (breakfastCurrData != null)
  2051. {
  2052. breakfastCode = breakfastCurrData.Name;
  2053. breakfastName = $"({breakfastCurrData.Remark})";
  2054. }
  2055. }
  2056. //房间费用
  2057. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2058. if (roomData != null)
  2059. {
  2060. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2061. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2062. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2063. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2064. roomFee = roomData.Price;
  2065. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2066. if (roomCurrData != null)
  2067. {
  2068. roomCode = roomCurrData.Name;
  2069. roomName = $"({roomCurrData.Remark})";
  2070. }
  2071. }
  2072. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2073. string hotelCostStr = "";
  2074. decimal hotelCsotTotal = 0.00M;
  2075. if (groupCost != null)
  2076. {
  2077. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2078. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2079. }
  2080. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2081. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2082. string hotelCost_day = "";
  2083. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2084. foreach (var item in hotelCostDetails1)
  2085. {
  2086. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2087. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2088. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2089. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2090. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2091. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2092. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2093. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2094. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2095. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2096. hotelCost_day += @$"<br/>";
  2097. }
  2098. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2099. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2100. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2101. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2102. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2103. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2104. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2105. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2106. $"房间说明: {hotelReservations.Remark} <br/>" +
  2107. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2108. $"{hotelBreakfastStr}" +
  2109. $"{hotelGovernmentRentStr}" +
  2110. $"{hotelCityTaxStr}";
  2111. _detail.PriceNameContent = hotelReservations.HotelName;
  2112. }
  2113. break;
  2114. case 79://车/导游地接
  2115. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2116. if (touristGuideGroundReservations != null)
  2117. {
  2118. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2119. {
  2120. _detail.BusName = touristGuideGroundReservations.BusName;
  2121. }
  2122. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2123. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2124. //if (isInt)
  2125. //{
  2126. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2127. // if (cityInfo != null)
  2128. // {
  2129. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2130. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2131. // if (carFeeItem != null)
  2132. // {
  2133. // nameContent += $@"({carFeeItem.Name})";
  2134. // }
  2135. // _detail.PriceNameContent = nameContent;
  2136. // }
  2137. //}
  2138. //else
  2139. //{
  2140. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2141. //}
  2142. var touristGuideGroundReservationsContents =
  2143. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2144. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2145. foreach (var item in touristGuideGroundReservationsContents)
  2146. {
  2147. string typeName = "Unknown";
  2148. string carCurrencyCode = "Unknown";
  2149. string carCurrencyName = "Unknown";
  2150. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2151. if (carTypeData != null) typeName = carTypeData.Name;
  2152. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2153. if (currencyData != null)
  2154. {
  2155. carCurrencyCode = currencyData.Name;
  2156. carCurrencyName = currencyData.Remark;
  2157. }
  2158. //op、成本 币种是否一致
  2159. bool IsCurrencyAgreement = false;
  2160. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2161. string opCostStr = string.Empty;
  2162. decimal opCostTypePrice = 0.00M;
  2163. #region 处理成本各项费用
  2164. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2165. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2166. if (opCost.Count > 0)
  2167. {
  2168. switch (item.SId)
  2169. {
  2170. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2171. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2172. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2173. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2174. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2175. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2176. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2177. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2178. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2179. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2180. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2181. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2182. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2183. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2184. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2185. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2186. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2187. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2188. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2189. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2190. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2191. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2192. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2193. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2194. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2195. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2197. }
  2198. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2199. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2200. }
  2201. #endregion
  2202. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2203. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2204. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2205. $"{opTypeStr} {opCostStr}<br/>" +
  2206. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2207. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2208. }
  2209. _detail.PriceMsgContent = priceMsg;
  2210. }
  2211. break;
  2212. case 80: //签证
  2213. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2214. if (visaInfo != null)
  2215. {
  2216. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2217. _detail.PriceNameContent = visaInfo.VisaDescription;
  2218. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2219. }
  2220. break;
  2221. case 81: //邀请/公务活动
  2222. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2223. if (_ioa != null)
  2224. {
  2225. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2226. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2227. sendCurrName = "Unknown", //快递费用币种 Name
  2228. sendCurrCode = "Unknown", //快递费用币种 Code
  2229. eventsCurrName = "Unknown", //公务活动费币种 Name
  2230. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2231. translateCurrName = "Unknown", //公务翻译费 Name
  2232. translateCurrCode = "Unknown"; //公务翻译费 Code
  2233. #region 处理费用币种
  2234. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2235. if (inviteCurrData != null)
  2236. {
  2237. inviteCurrName = inviteCurrData.Remark;
  2238. inviteCurrCode = inviteCurrData.Name;
  2239. }
  2240. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2241. if (sendCurrData != null)
  2242. {
  2243. sendCurrName = sendCurrData.Remark;
  2244. sendCurrCode = sendCurrData.Name;
  2245. }
  2246. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2247. if (eventsCurrData != null)
  2248. {
  2249. eventsCurrName = eventsCurrData.Remark;
  2250. eventsCurrCode = eventsCurrData.Name;
  2251. }
  2252. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2253. if (translateCurrData != null)
  2254. {
  2255. translateCurrName = translateCurrData.Remark;
  2256. translateCurrCode = translateCurrData.Name;
  2257. }
  2258. #endregion
  2259. _detail.PriceNameContent = _ioa.InviterArea;
  2260. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2261. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2262. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2263. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2264. $@"备注:" + _ioa.Remark + "<br/>";
  2265. }
  2266. break;
  2267. case 82: //团组客户保险
  2268. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2269. if (customers != null)
  2270. {
  2271. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2272. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2273. }
  2274. break;
  2275. case 85: //机票预订
  2276. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2277. if (jpRes != null)
  2278. {
  2279. string FlightsDescription = jpRes.FlightsDescription;
  2280. string PriceDescription = jpRes.PriceDescription;
  2281. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2282. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2283. }
  2284. break;
  2285. case 98://其他款项
  2286. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2287. if (gdpRes != null)
  2288. {
  2289. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2290. _detail.PriceNameContent = gdpRes.PriceName;
  2291. }
  2292. break;
  2293. case 285://收款退还
  2294. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2295. if (refundAndOtherMoney != null)
  2296. {
  2297. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2298. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2299. }
  2300. break;
  2301. case 751://酒店早餐
  2302. break;
  2303. case 1015://超支费用
  2304. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2305. if (groupExtraCost != null)
  2306. {
  2307. _detail.PriceNameContent = groupExtraCost.PriceName;
  2308. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2309. }
  2310. break;
  2311. default:
  2312. break;
  2313. }
  2314. /*
  2315. * 申请人
  2316. */
  2317. string operatorName = " - ";
  2318. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2319. if (_opUser != null)
  2320. {
  2321. operatorName = _opUser.CnName;
  2322. }
  2323. _detail.OperatorName = operatorName;
  2324. /*
  2325. * 审核人
  2326. */
  2327. string auditOperatorName = "Unknown";
  2328. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2329. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2330. else
  2331. {
  2332. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2333. if (_adUser != null)
  2334. {
  2335. auditOperatorName = _adUser.CnName;
  2336. }
  2337. }
  2338. _detail.AuditOperatorName = auditOperatorName;
  2339. /*
  2340. * 超预算比例
  2341. */
  2342. string overBudgetStr = "";
  2343. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2344. else if (entity.ExceedBudget == 0)
  2345. {
  2346. if (entity.CTable == 76 || entity.CTable == 79)
  2347. {
  2348. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2349. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2350. }
  2351. else
  2352. {
  2353. overBudgetStr = "未超预算";
  2354. }
  2355. }
  2356. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2357. _detail.OverBudget = overBudgetStr;
  2358. decimal auditFee = 0.00M; //已审核金额 人名币
  2359. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2360. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2361. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2362. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2363. {
  2364. auditedFeeOriginal = entity.PayMoney;
  2365. auditFee = CurrPayStr;
  2366. }
  2367. else if (entity.IsAuditGM == 0)
  2368. {
  2369. unAuditFeeCNY = CurrPayStr;
  2370. unAuditFeeOriginal = OriginalCurrPay;
  2371. OriginalCurrPay = 0.00M;
  2372. }
  2373. /*
  2374. * 费用总计
  2375. */
  2376. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2377. {
  2378. CurrencyId = entity.PaymentCurrency,
  2379. CurrencyName = PaymentCurrency_WaitPay,
  2380. AmountPayable = entity.PayMoney,
  2381. ThisPayment = OriginalCurrPay,
  2382. BalancePayment = BalanceStr,
  2383. AuditedFunds = auditFee,
  2384. AuditedFundsOriginal = auditedFeeOriginal,
  2385. UnAuditFundsCNY = unAuditFeeCNY,
  2386. UnAuditFundsOriginal = unAuditFeeOriginal
  2387. });
  2388. _detail.IsAuditGM = entity.IsAuditGM;
  2389. detailList.Add(_detail);
  2390. }
  2391. #endregion
  2392. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2393. /*
  2394. * 下方描述处理
  2395. */
  2396. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2397. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2398. if (ccpCurrencyPrice != null)
  2399. {
  2400. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2401. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2402. }
  2403. else
  2404. {
  2405. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2406. }
  2407. string amountPayableStr = string.Format(@"应付款总金额: ");
  2408. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2409. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2410. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2411. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2412. foreach (var item in nonDuplicat)
  2413. {
  2414. var currencyName = item.CurrencyName;
  2415. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2416. if (strs.Count > 0)
  2417. {
  2418. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2419. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2420. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2421. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2422. //单独处理此次付款金额
  2423. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2424. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2425. //单独处理已审核费用
  2426. //if (item.CurrencyId == 836) //人民币
  2427. //{
  2428. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2429. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2430. //}
  2431. //else
  2432. //{
  2433. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2434. //}
  2435. if (currencyName.Equals("CNY"))
  2436. {
  2437. //已审核费用
  2438. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2439. //未审核费用
  2440. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2441. }
  2442. else
  2443. {
  2444. //已审核费用
  2445. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2446. //未审核费用
  2447. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  2448. }
  2449. }
  2450. }
  2451. _view.TotalStr1 = amountPayableStr[..^1];
  2452. _view.TotalStr2 = thisPaymentStr[..^1];
  2453. _view.TotalStr3 = balancePaymentStr[..^1];
  2454. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2455. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2456. var _view1 = new
  2457. {
  2458. PageFuncAuth = pageFunAuthView,
  2459. Data = _view
  2460. };
  2461. return Ok(JsonView(_view1));
  2462. }
  2463. catch (Exception ex)
  2464. {
  2465. return Ok(JsonView(false, ex.Message));
  2466. }
  2467. }
  2468. /// <summary>
  2469. /// 费用审核
  2470. /// 修改团组费用审核状态
  2471. /// </summary>
  2472. /// <param name="_dto">参数Json字符串</param>
  2473. /// <returns></returns>
  2474. [HttpPost]
  2475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2476. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2477. {
  2478. #region 参数验证
  2479. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2480. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2481. #endregion
  2482. #region 页面操作权限验证
  2483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2484. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2485. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2486. #endregion
  2487. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2488. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2489. DateTime dtNow = DateTime.Now;
  2490. _groupRepository.BeginTran();
  2491. int rst = 0;
  2492. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2493. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2494. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2495. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2496. List<dynamic> msgDatas = new List<dynamic>();
  2497. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2498. foreach (var item in idList)
  2499. {
  2500. int CreditId = int.Parse(item);
  2501. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2502. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2503. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2504. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2505. .Where(s => s.Id == CreditId)
  2506. .ExecuteCommandAsync();
  2507. if (result < 1)
  2508. {
  2509. rst = -1;
  2510. _groupRepository.RollbackTran();
  2511. return Ok(JsonView(false, "操作失败并回滚!"));
  2512. }
  2513. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2514. if (creditData != null)
  2515. {
  2516. #region 应用通知配置
  2517. try
  2518. {
  2519. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2520. }
  2521. catch (Exception ex)
  2522. {
  2523. }
  2524. #endregion
  2525. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2526. string groupNameStr = string.Empty;
  2527. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2528. if (groupData != null) groupNameStr = groupData.TeamName;
  2529. string creditTypeStr = string.Empty;
  2530. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2531. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2532. string creditCurrency = string.Empty;
  2533. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2534. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2535. if (creditCurrency.Equals("CNY"))
  2536. {
  2537. creditData.DayRate = 1.0000M;
  2538. }
  2539. if (creditData.PayPercentage == 0.00M)
  2540. {
  2541. creditData.PayPercentage = 100M;
  2542. }
  2543. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2544. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2545. string msgContent = "";
  2546. if (creditCurrency.Equals("CNY"))
  2547. {
  2548. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2549. }
  2550. else
  2551. {
  2552. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2553. }
  2554. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2555. }
  2556. }
  2557. if (rst == 0)
  2558. {
  2559. _groupRepository.CommitTran();
  2560. foreach (var item in msgDatas)
  2561. {
  2562. //发送消息
  2563. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2564. }
  2565. #region 应用推送
  2566. try
  2567. {
  2568. foreach (var ccpId in dic_ccp_user.Keys)
  2569. {
  2570. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2571. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2572. }
  2573. }
  2574. catch (Exception)
  2575. {
  2576. }
  2577. #endregion
  2578. return Ok(JsonView(true, "操作成功!"));
  2579. }
  2580. return Ok(JsonView(false, "操作失败!"));
  2581. }
  2582. #endregion
  2583. #region 机票费用录入
  2584. /// <summary>
  2585. /// 机票录入当前登录人可操作团组
  2586. /// </summary>
  2587. /// <param name="dto"></param>
  2588. /// <returns></returns>
  2589. [HttpPost]
  2590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2591. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2592. {
  2593. try
  2594. {
  2595. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2596. if (groupData.Code != 0)
  2597. {
  2598. return Ok(JsonView(false, groupData.Msg));
  2599. }
  2600. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2601. }
  2602. catch (Exception ex)
  2603. {
  2604. return Ok(JsonView(false, "程序错误!"));
  2605. throw;
  2606. }
  2607. }
  2608. /// <summary>
  2609. /// 机票费用录入列表
  2610. /// </summary>
  2611. /// <param name="dto"></param>
  2612. /// <returns></returns>
  2613. [HttpPost]
  2614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2615. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2616. {
  2617. try
  2618. {
  2619. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2620. if (groupData.Code != 0)
  2621. {
  2622. return Ok(JsonView(false, groupData.Msg));
  2623. }
  2624. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2625. }
  2626. catch (Exception ex)
  2627. {
  2628. return Ok(JsonView(false, ex.Message));
  2629. throw;
  2630. }
  2631. }
  2632. /// <summary>
  2633. /// 根据id查询费用录入信息
  2634. /// </summary>
  2635. /// <param name="dto"></param>
  2636. /// <returns></returns>
  2637. [HttpPost]
  2638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2639. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2640. {
  2641. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2642. if (groupData.Code != 0)
  2643. {
  2644. return Ok(JsonView(false, groupData.Msg));
  2645. }
  2646. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2647. }
  2648. /// <summary>
  2649. /// 机票费用录入操作(Status:1.新增,2.修改)
  2650. /// </summary>
  2651. /// <param name="dto"></param>
  2652. /// <returns></returns>
  2653. [HttpPost]
  2654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2655. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2656. {
  2657. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2658. if (groupData.Code != 0)
  2659. {
  2660. return Ok(JsonView(false, groupData.Msg));
  2661. }
  2662. #region 应用推送
  2663. try
  2664. {
  2665. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2666. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2667. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2668. //2024-10-21 新增LZ UID
  2669. var userIds = new List<int>() { 21 };
  2670. string title = $"系统通知";
  2671. string content = "";
  2672. var diId = dto.AirTicketResOpData.DiId;
  2673. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2674. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2675. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2676. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2677. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2678. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2679. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2680. }
  2681. catch (Exception ex)
  2682. {
  2683. }
  2684. #endregion
  2685. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2686. }
  2687. /// <summary>
  2688. /// 根据舱位类型查询接团客户名单信息
  2689. /// </summary>
  2690. /// <param name="dto"></param>
  2691. /// <returns></returns>
  2692. [HttpPost]
  2693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2694. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2695. {
  2696. try
  2697. {
  2698. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2699. if (crm_Groups.Count != 0)
  2700. {
  2701. List<dynamic> Customer = new List<dynamic>();
  2702. foreach (var item in crm_Groups)
  2703. {
  2704. var data = new
  2705. {
  2706. Id = item.Id,
  2707. Pinyin = item.Pinyin,
  2708. Name = item.LastName + item.FirstName
  2709. };
  2710. Customer.Add(data);
  2711. }
  2712. return Ok(JsonView(true, "查询成功!", Customer));
  2713. }
  2714. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2715. }
  2716. catch (Exception ex)
  2717. {
  2718. return Ok(JsonView(false, "程序错误!"));
  2719. throw;
  2720. }
  2721. }
  2722. /// <summary>
  2723. /// 根据团号获取客户信息
  2724. /// </summary>
  2725. /// <param name="dto"></param>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2730. {
  2731. var jw = JsonView(false);
  2732. if (dto.DIID < 1)
  2733. {
  2734. jw.Msg += "请输入正确的diid";
  2735. return Ok(jw);
  2736. }
  2737. var arr = getSimplClientList(dto.DIID);
  2738. jw = JsonView(true, "获取成功!", arr);
  2739. return Ok(jw);
  2740. }
  2741. private List<SimplClientInfo> getSimplClientList(int diId)
  2742. {
  2743. 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);
  2744. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2745. foreach (var item in arr)
  2746. {
  2747. EncryptionProcessor.DecryptProperties(item);
  2748. }
  2749. return arr;
  2750. }
  2751. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2752. {
  2753. string result = origin;
  2754. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2755. {
  2756. string[] temparr = origin.Split(',');
  2757. string fistrStr = temparr[0];
  2758. int count = temparr.Count();
  2759. int tempId;
  2760. bool success = int.TryParse(fistrStr, out tempId);
  2761. if (success)
  2762. {
  2763. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2764. if (tempInfo != null)
  2765. {
  2766. if (count > 1)
  2767. {
  2768. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2769. }
  2770. else
  2771. {
  2772. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2773. }
  2774. }
  2775. }
  2776. }
  2777. return result;
  2778. }
  2779. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2780. {
  2781. string result = origin;
  2782. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2783. {
  2784. string[] temparr = origin.Split(',');
  2785. result = "";
  2786. foreach (var item in temparr)
  2787. {
  2788. int tempId;
  2789. bool success = int.TryParse(item, out tempId);
  2790. if (success)
  2791. {
  2792. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2793. if (tempInfo != null)
  2794. {
  2795. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2796. }
  2797. }
  2798. }
  2799. }
  2800. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2801. return result;
  2802. }
  2803. /// <summary>
  2804. /// 机票费用录入,删除
  2805. /// </summary>
  2806. /// <param name="dto"></param>
  2807. /// <returns></returns>
  2808. [HttpPost]
  2809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2810. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2811. {
  2812. try
  2813. {
  2814. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2815. if (res)
  2816. {
  2817. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2818. {
  2819. IsDel = 1,
  2820. DeleteUserId = dto.DeleteUserId,
  2821. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2822. }).ExecuteCommandAsync();
  2823. return Ok(JsonView(true, "删除成功!"));
  2824. }
  2825. return Ok(JsonView(false, "删除失败!"));
  2826. }
  2827. catch (Exception ex)
  2828. {
  2829. return Ok(JsonView(false, "程序错误!"));
  2830. throw;
  2831. }
  2832. }
  2833. /// <summary>
  2834. /// 导出机票录入报表
  2835. /// </summary>
  2836. /// <param name="dto"></param>
  2837. /// <returns></returns>
  2838. [HttpPost]
  2839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2840. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2841. {
  2842. try
  2843. {
  2844. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2845. if (groupData.Code != 0)
  2846. {
  2847. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2848. }
  2849. else
  2850. {
  2851. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2852. if (AirTicketReservations.Count != 0)
  2853. {
  2854. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2855. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2856. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2857. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2858. WorkbookDesigner designer = new WorkbookDesigner();
  2859. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2860. decimal countCost = 0;
  2861. foreach (var item in AirTicketReservations)
  2862. {
  2863. #region 处理客人姓名
  2864. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2865. item.ClientName = clientNames;
  2866. #endregion
  2867. if (item.BankType == "其他")
  2868. {
  2869. item.BankNo = "--";
  2870. }
  2871. else
  2872. {
  2873. if (!string.IsNullOrEmpty(item.BankType))
  2874. {
  2875. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2876. }
  2877. }
  2878. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2879. item.Price = System.Decimal.Round(item.Price, 2);
  2880. countCost += Convert.ToDecimal(item.Price);
  2881. }
  2882. designer.SetDataSource("Export", AirTicketReservations);
  2883. designer.SetDataSource("ExportDiCode", diCode);
  2884. designer.SetDataSource("ExportDiName", diName);
  2885. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2886. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2887. designer.Process();
  2888. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2889. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2890. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2891. return Ok(JsonView(true, "成功", url = rst));
  2892. }
  2893. else
  2894. {
  2895. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2896. }
  2897. }
  2898. }
  2899. catch (Exception ex)
  2900. {
  2901. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2902. throw;
  2903. }
  2904. }
  2905. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2906. /// <summary>
  2907. /// 行程单导出
  2908. /// </summary>
  2909. /// <param name="dto"></param>
  2910. /// <returns></returns>
  2911. [HttpPost]
  2912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2913. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2914. {
  2915. try
  2916. {
  2917. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2918. if (groupData.Code != 0)
  2919. {
  2920. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2921. }
  2922. else
  2923. {
  2924. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2925. if (dto.Language == "CN")
  2926. {
  2927. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2928. DocumentBuilder builder = new DocumentBuilder(doc);
  2929. int tableIndex = 0;//表格索引
  2930. //得到文档中的第一个表格
  2931. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2932. foreach (var item in _AirTicketReservations)
  2933. {
  2934. #region 处理固定数据
  2935. string[] FlightsCode = item.FlightsCode.Split('/');
  2936. if (FlightsCode.Length != 0)
  2937. {
  2938. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2939. if (_AirCompany != null)
  2940. {
  2941. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2942. }
  2943. else
  2944. {
  2945. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2946. }
  2947. }
  2948. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2949. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2950. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2951. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2952. string name = "";
  2953. foreach (string clientName in nameArray)
  2954. {
  2955. if (!name.Contains(clientName))
  2956. {
  2957. name += clientName + ",";
  2958. }
  2959. }
  2960. if (!string.IsNullOrWhiteSpace(name))
  2961. {
  2962. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2963. }
  2964. else
  2965. {
  2966. table.Range.Bookmarks["ClientName"].Text = "--";
  2967. }
  2968. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2969. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2970. table.Range.Bookmarks["JointTicket"].Text = "--";
  2971. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2972. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2973. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2974. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2975. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2976. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2977. #endregion
  2978. #region 循环数据处理
  2979. List<AirInfo> airs = new List<AirInfo>();
  2980. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2981. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2982. for (int i = 0; i < FlightsCode.Length; i++)
  2983. {
  2984. AirInfo air = new AirInfo();
  2985. string[] tempstr = DayArray[i]
  2986. .Replace("\r\n", string.Empty)
  2987. .Replace("\\r\\n", string.Empty)
  2988. .TrimStart().TrimEnd()
  2989. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2990. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2991. string starCity = "";
  2992. if (star_Three != null)
  2993. {
  2994. starCity = star_Three.AirPort;
  2995. }
  2996. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2997. string EndCity = "";
  2998. if (End_Three != null)
  2999. {
  3000. EndCity = End_Three.AirPort;
  3001. }
  3002. air.Destination = starCity + "/" + EndCity;
  3003. air.Flight = FlightsCode[i];
  3004. air.SeatingClass = item.CTypeName;
  3005. string dateTime = tempstr[2];
  3006. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3007. air.FlightDate = DateTemp;
  3008. air.DepartureTime = tempstr[5];
  3009. air.LandingTime = tempstr[6];
  3010. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3011. air.TicketStatus = "--";
  3012. air.Luggage = "--";
  3013. air.DepartureTerminal = "--";
  3014. air.LandingTerminal = "--";
  3015. airs.Add(air);
  3016. }
  3017. int row = 13;
  3018. for (int i = 0; i < airs.Count; i++)
  3019. {
  3020. if (airs.Count > 2)
  3021. {
  3022. for (int j = 0; j < airs.Count - 2; j++)
  3023. {
  3024. var CopyRow = table.Rows[12].Clone(true);
  3025. table.Rows.Add(CopyRow);
  3026. }
  3027. }
  3028. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3029. int index = 0;
  3030. foreach (PropertyInfo property in properties)
  3031. {
  3032. string value = property.GetValue(airs[i]).ToString();
  3033. Cell ishcel0 = table.Rows[row].Cells[index];
  3034. Paragraph p = new Paragraph(doc);
  3035. string s = value;
  3036. p.AppendChild(new Run(doc, s));
  3037. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3038. ishcel0.AppendChild(p);
  3039. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3040. index++;
  3041. }
  3042. row++;
  3043. }
  3044. #endregion
  3045. Paragraph lastParagraph = new Paragraph(doc);
  3046. //第一个表格末尾加段落
  3047. table.ParentNode.InsertAfter(lastParagraph, table);
  3048. //复制第一个表格
  3049. Table cloneTable = (Table)table.Clone(true);
  3050. //在文档末尾段落后面加入复制的表格
  3051. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3052. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3053. {
  3054. int rownewsIndex = 13;
  3055. for (int i = 0; i < 2; i++)
  3056. {
  3057. var CopyRow = table.Rows[12].Clone(true);
  3058. table.Rows.RemoveAt(13);
  3059. table.Rows.Add(CopyRow);
  3060. rownewsIndex++;
  3061. }
  3062. }
  3063. else
  3064. {
  3065. table.Rows.RemoveAt(12);
  3066. }
  3067. cloneTable.Rows.RemoveAt(12);
  3068. }
  3069. if (_AirTicketReservations.Count != 0)
  3070. {
  3071. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3072. if (FlightsCode.Length != 0)
  3073. {
  3074. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3075. if (_AirCompany != null)
  3076. {
  3077. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3078. }
  3079. else
  3080. {
  3081. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3082. }
  3083. }
  3084. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3085. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3086. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3087. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3088. string name = "";
  3089. foreach (string clientName in nameArray)
  3090. {
  3091. if (!name.Contains(clientName))
  3092. {
  3093. name += clientName + ",";
  3094. }
  3095. }
  3096. if (!string.IsNullOrWhiteSpace(name))
  3097. {
  3098. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3099. }
  3100. else
  3101. {
  3102. table.Range.Bookmarks["ClientName"].Text = "--";
  3103. }
  3104. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3105. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3106. table.Range.Bookmarks["JointTicket"].Text = "--";
  3107. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3108. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3109. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3110. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3111. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3112. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3113. }
  3114. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3115. //保存合并后的文档
  3116. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3117. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3118. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3119. return Ok(JsonView(true, "成功!", rst));
  3120. }
  3121. else
  3122. {
  3123. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3124. DocumentBuilder builder = new DocumentBuilder(doc);
  3125. int tableIndex = 0;//表格索引
  3126. //得到文档中的第一个表格
  3127. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3128. List<string> texts = new List<string>();
  3129. foreach (var item in _AirTicketReservations)
  3130. {
  3131. string[] FlightsCode = item.FlightsCode.Split('/');
  3132. if (FlightsCode.Length != 0)
  3133. {
  3134. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3135. if (_AirCompany != null)
  3136. {
  3137. if (!transDic.ContainsKey(_AirCompany.CnName))
  3138. {
  3139. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3140. }
  3141. }
  3142. else
  3143. {
  3144. if (!transDic.ContainsKey("--"))
  3145. {
  3146. transDic.Add("--", "--");
  3147. }
  3148. }
  3149. }
  3150. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3151. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3152. string name = "";
  3153. foreach (string clientName in nameArray)
  3154. {
  3155. name += clientName + ",";
  3156. }
  3157. if (!texts.Contains(name))
  3158. {
  3159. texts.Add(name);
  3160. }
  3161. List<AirInfo> airs = new List<AirInfo>();
  3162. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3163. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3164. for (int i = 0; i < FlightsCode.Length; i++)
  3165. {
  3166. AirInfo air = new AirInfo();
  3167. string[] tempstr = DayArray[i]
  3168. .Replace("\r\n", string.Empty)
  3169. .Replace("\\r\\n", string.Empty)
  3170. .TrimStart().TrimEnd()
  3171. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3172. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3173. if (star_Three != null)
  3174. {
  3175. if (!transDic.ContainsKey(star_Three.AirPort))
  3176. {
  3177. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3178. }
  3179. }
  3180. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3181. if (End_Three != null)
  3182. {
  3183. if (!transDic.ContainsKey(End_Three.AirPort))
  3184. {
  3185. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3186. }
  3187. }
  3188. if (!texts.Contains(item.CTypeName))
  3189. {
  3190. texts.Add(item.CTypeName);
  3191. }
  3192. }
  3193. }
  3194. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3195. if (transData.Count > 0)
  3196. {
  3197. foreach (TranslateResult item in transData)
  3198. {
  3199. if (!transDic.ContainsKey(item.Query))
  3200. {
  3201. transDic.Add(item.Query, item.Translation);
  3202. }
  3203. }
  3204. }
  3205. foreach (var item in _AirTicketReservations)
  3206. {
  3207. #region 处理固定数据
  3208. string[] FlightsCode = item.FlightsCode.Split('/');
  3209. if (FlightsCode.Length != 0)
  3210. {
  3211. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3212. if (_AirCompany != null)
  3213. {
  3214. string str = "--";
  3215. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3216. if (!string.IsNullOrEmpty(translateResult))
  3217. {
  3218. str = translateResult;
  3219. str = _airTicketResRep.Processing(str);
  3220. }
  3221. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3222. }
  3223. else
  3224. {
  3225. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3226. }
  3227. }
  3228. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3229. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3230. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3231. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3232. string names = "";
  3233. foreach (string clientName in nameArray)
  3234. {
  3235. names += clientName + ",";
  3236. }
  3237. if (!string.IsNullOrWhiteSpace(names))
  3238. {
  3239. string str = "--";
  3240. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3241. if (!string.IsNullOrEmpty(translateResult))
  3242. {
  3243. str = translateResult;
  3244. str = _airTicketResRep.Processing(str);
  3245. }
  3246. table.Range.Bookmarks["ClientName"].Text = str;
  3247. }
  3248. else
  3249. {
  3250. table.Range.Bookmarks["ClientName"].Text = "--";
  3251. }
  3252. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3253. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3254. table.Range.Bookmarks["JointTicket"].Text = "--";
  3255. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3256. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3257. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3258. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3259. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3260. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3261. #endregion
  3262. #region 循环数据处理
  3263. List<AirInfo> airs = new List<AirInfo>();
  3264. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3265. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3266. for (int i = 0; i < FlightsCode.Length; i++)
  3267. {
  3268. AirInfo air = new AirInfo();
  3269. string[] tempstr = DayArray[i]
  3270. .Replace("\r\n", string.Empty)
  3271. .Replace("\\r\\n", string.Empty)
  3272. .TrimStart().TrimEnd()
  3273. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3274. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3275. string starCity = "";
  3276. if (star_Three != null)
  3277. {
  3278. string str2 = "--";
  3279. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3280. if (!string.IsNullOrEmpty(translateResult2))
  3281. {
  3282. str2 = translateResult2;
  3283. str2 = _airTicketResRep.Processing(str2);
  3284. }
  3285. starCity = str2;
  3286. }
  3287. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3288. string EndCity = "";
  3289. if (End_Three != null)
  3290. {
  3291. string str1 = "--";
  3292. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3293. if (!string.IsNullOrEmpty(translateResult1))
  3294. {
  3295. str1 = translateResult1;
  3296. str1 = _airTicketResRep.Processing(str1);
  3297. }
  3298. EndCity = str1;
  3299. }
  3300. air.Destination = starCity + "/" + EndCity;
  3301. air.Flight = FlightsCode[i];
  3302. string str = "--";
  3303. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3304. if (!string.IsNullOrEmpty(translateResult))
  3305. {
  3306. str = translateResult;
  3307. str = _airTicketResRep.Processing(str);
  3308. }
  3309. air.SeatingClass = str;
  3310. string dateTime = tempstr[2];
  3311. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3312. air.FlightDate = DateTemp;
  3313. air.DepartureTime = tempstr[5];
  3314. air.LandingTime = tempstr[6];
  3315. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3316. air.TicketStatus = "--";
  3317. air.Luggage = "--";
  3318. air.DepartureTerminal = "--";
  3319. air.LandingTerminal = "--";
  3320. airs.Add(air);
  3321. }
  3322. int row = 13;
  3323. for (int i = 0; i < airs.Count; i++)
  3324. {
  3325. if (airs.Count > 2)
  3326. {
  3327. for (int j = 0; j < airs.Count - 2; j++)
  3328. {
  3329. var CopyRow = table.Rows[12].Clone(true);
  3330. table.Rows.Add(CopyRow);
  3331. }
  3332. }
  3333. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3334. int index = 0;
  3335. foreach (PropertyInfo property in properties)
  3336. {
  3337. string value = property.GetValue(airs[i]).ToString();
  3338. Cell ishcel0 = table.Rows[row].Cells[index];
  3339. Paragraph p = new Paragraph(doc);
  3340. string s = value;
  3341. p.AppendChild(new Run(doc, s));
  3342. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3343. ishcel0.AppendChild(p);
  3344. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3345. //ishcel0.CellFormat.VerticalAlignment=
  3346. index++;
  3347. }
  3348. row++;
  3349. }
  3350. #endregion
  3351. Paragraph lastParagraph = new Paragraph(doc);
  3352. //第一个表格末尾加段落
  3353. table.ParentNode.InsertAfter(lastParagraph, table);
  3354. //复制第一个表格
  3355. Table cloneTable = (Table)table.Clone(true);
  3356. //在文档末尾段落后面加入复制的表格
  3357. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3358. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3359. {
  3360. int rownewsIndex = 13;
  3361. for (int i = 0; i < 2; i++)
  3362. {
  3363. var CopyRow = table.Rows[12].Clone(true);
  3364. table.Rows.RemoveAt(13);
  3365. table.Rows.Add(CopyRow);
  3366. rownewsIndex++;
  3367. }
  3368. }
  3369. else
  3370. {
  3371. table.Rows.RemoveAt(12);
  3372. }
  3373. cloneTable.Rows.RemoveAt(12);
  3374. }
  3375. if (_AirTicketReservations.Count != 0)
  3376. {
  3377. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3378. if (FlightsCode.Length != 0)
  3379. {
  3380. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3381. if (_AirCompany != null)
  3382. {
  3383. string str = "--";
  3384. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3385. if (!string.IsNullOrEmpty(translateResult))
  3386. {
  3387. str = translateResult;
  3388. str = _airTicketResRep.Processing(str);
  3389. }
  3390. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3391. }
  3392. else
  3393. {
  3394. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3395. }
  3396. }
  3397. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3398. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3399. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3400. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3401. string names = "";
  3402. foreach (string clientName in nameArray)
  3403. {
  3404. names += clientName + ",";
  3405. }
  3406. if (!string.IsNullOrWhiteSpace(names))
  3407. {
  3408. string str = "--";
  3409. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3410. if (!string.IsNullOrEmpty(translateResult))
  3411. {
  3412. str = translateResult;
  3413. str = _airTicketResRep.Processing(str);
  3414. }
  3415. table.Range.Bookmarks["ClientName"].Text = str;
  3416. }
  3417. else
  3418. {
  3419. table.Range.Bookmarks["ClientName"].Text = "--";
  3420. }
  3421. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3422. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3423. table.Range.Bookmarks["JointTicket"].Text = "--";
  3424. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3425. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3426. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3427. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3428. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3429. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3430. }
  3431. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3432. //保存合并后的文档
  3433. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3434. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3435. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3436. return Ok(JsonView(true, "成功!", rst));
  3437. }
  3438. }
  3439. }
  3440. catch (Exception ex)
  3441. {
  3442. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3443. throw;
  3444. }
  3445. }
  3446. #endregion
  3447. #region 团组增减款项 --> 其他款项
  3448. /// <summary>
  3449. /// 团组增减款项下拉框绑定
  3450. /// </summary>
  3451. /// <param name="dto"></param>
  3452. /// <returns></returns>
  3453. [HttpPost]
  3454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3455. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3456. {
  3457. #region 参数验证
  3458. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3459. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3460. #endregion
  3461. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3462. }
  3463. /// <summary>
  3464. /// 根据团组Id查询团组增减款项
  3465. /// </summary>
  3466. /// <param name="dto"></param>
  3467. /// <returns></returns>
  3468. [HttpPost]
  3469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3470. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3471. {
  3472. #region 参数验证
  3473. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3474. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3475. #endregion
  3476. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3477. }
  3478. /// <summary>
  3479. /// 团组增减款项操作(Status:1.新增,2.修改)
  3480. /// </summary>
  3481. /// <param name="dto"></param>
  3482. /// <returns></returns>
  3483. [HttpPost]
  3484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3485. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3486. {
  3487. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3488. if (groupData.Code != 200)
  3489. {
  3490. return Ok(JsonView(false, groupData.Msg));
  3491. }
  3492. #region 应用推送
  3493. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3494. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3495. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3496. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3497. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3498. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3499. //自动审核
  3500. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3501. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3502. //2024-10-21 新增LZ UID
  3503. var userIds = new List<int>() { 21 };
  3504. string title = $"系统通知";
  3505. string content = "";
  3506. var diId = dto.DiId;
  3507. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3508. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3509. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3510. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3511. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3512. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3513. #endregion
  3514. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3515. }
  3516. /// <summary>
  3517. /// 团组增减款项操作 删除
  3518. /// </summary>
  3519. /// <param name="dto"></param>
  3520. /// <returns></returns>
  3521. [HttpPost]
  3522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3523. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3524. {
  3525. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3526. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3527. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3528. if (res.Code == 0)
  3529. {
  3530. return Ok(JsonView(true, "删除成功!"));
  3531. }
  3532. return Ok(JsonView(false, "删除失败!"));
  3533. }
  3534. /// <summary>
  3535. /// 根据团组增减款项Id查询
  3536. /// </summary>
  3537. /// <param name="dto"></param>
  3538. /// <returns></returns>
  3539. [HttpPost]
  3540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3541. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3542. {
  3543. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3544. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3545. }
  3546. /// <summary>
  3547. /// 查询供应商名称
  3548. /// </summary>
  3549. /// <param name="dto"></param>
  3550. /// <returns></returns>
  3551. [HttpPost]
  3552. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3553. {
  3554. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3555. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3556. ?? new List<Grp_DecreasePayments>();
  3557. dbResult = dbResult.Distinct(new
  3558. ProductComparer()).ToList();
  3559. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3560. {
  3561. x.Id,
  3562. x.SupplierAddress,
  3563. x.SupplierArea,
  3564. x.SupplierContact,
  3565. x.SupplierContactNumber,
  3566. x.SupplierEmail,
  3567. x.SupplierName,
  3568. x.SupplierSocialAccount,
  3569. x.SupplierTypeId,
  3570. }).ToList());
  3571. return Ok(jw);
  3572. }
  3573. /// <summary>
  3574. /// 团组增减款项 OTA匹配
  3575. /// </summary>
  3576. /// <param name="file"></param>
  3577. /// <returns></returns>
  3578. [HttpPost]
  3579. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3580. {
  3581. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3582. string fileName = file.FileName;
  3583. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3584. {
  3585. return Ok(JsonView(false, "请上传Excel文件!"));
  3586. }
  3587. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3588. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3589. if (!Directory.Exists(path))
  3590. {
  3591. Directory.CreateDirectory(path);
  3592. }
  3593. var filePath = @$"{path}/{fileName}";
  3594. //保存文件
  3595. using (FileStream fs = System.IO.File.Create(filePath))
  3596. {
  3597. file.CopyTo(fs);
  3598. fs.Flush();
  3599. }
  3600. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3601. //读取ExcelFile
  3602. DataTable dt = ConvertExcelToDataTable(filePath);
  3603. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3604. dt.TableName = "TB";
  3605. //修改table列名
  3606. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3607. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3608. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3609. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3610. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3611. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3612. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3613. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3614. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3615. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3616. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3617. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3618. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3619. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3620. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3621. var otaOrderNos = new List<string>();
  3622. foreach (DataRow item in dt.Rows)
  3623. {
  3624. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3625. }
  3626. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3627. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3628. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3629. .Select((dp, di) => new
  3630. {
  3631. dp.PriceName,
  3632. dp.OTAOrderNo,
  3633. dp.FeeTotal,
  3634. di.TeamName,
  3635. })
  3636. .ToListAsync();
  3637. foreach (DataRow item in dt.Rows)
  3638. {
  3639. var otaOrderNo = item["OTAOrderNo"].ToString();
  3640. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3641. if (oaData == null) continue;
  3642. item["GroupName"] = oaData.TeamName;
  3643. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3644. }
  3645. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3646. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3647. List<DataTable> datas = new List<DataTable>();
  3648. datas.Add(dt);
  3649. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3650. return Ok(JsonView(true, "操作成功", new { url = url }));
  3651. }
  3652. #region
  3653. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3654. {
  3655. // 创建Workbook对象
  3656. Workbook workbook = new Workbook(excelFilePath);
  3657. // 获取第一个工作表
  3658. Worksheet worksheet = workbook.Worksheets[0];
  3659. // 将工作表转换为DataTable
  3660. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3661. return dataTable;
  3662. }
  3663. #endregion
  3664. #endregion
  3665. #region 文件上传、删除
  3666. /// <summary>
  3667. /// region 文件上传 可以带参数
  3668. /// </summary>
  3669. /// <param name="file"></param>
  3670. /// <returns></returns>
  3671. [HttpPost]
  3672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3673. public async Task<IActionResult> UploadProject(IFormFile file)
  3674. {
  3675. //var TypeName = Request.Headers["TypeName"].ToString();
  3676. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3677. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3678. ////文件名称
  3679. //string projectFileName = file.FileName;
  3680. ////上传的文件的路径
  3681. //string filePath = $"{fileDir}/{projectFileName}";
  3682. //if (TypeName == "A")//A代表团组增减款项
  3683. //{
  3684. // filePath = fileDir + $@"\团组增减款项相关文件";
  3685. // if (!Directory.Exists(filePath))
  3686. // {
  3687. // Directory.CreateDirectory(filePath);
  3688. // }
  3689. // //上传的文件的路径
  3690. // filePath += $@"\{projectFileName}";
  3691. //}
  3692. //else if (TypeName == "B")//B代表商邀相关文件
  3693. //{
  3694. // //上传的文件的路径
  3695. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3696. // if (!Directory.Exists(filePath))
  3697. // {
  3698. // Directory.CreateDirectory(filePath);
  3699. // }
  3700. // //上传的文件的路径
  3701. // filePath = $@"\{projectFileName}";
  3702. //}
  3703. //try
  3704. //{
  3705. // using (FileStream fs = System.IO.File.Create(filePath))
  3706. // {
  3707. // file.CopyTo(fs);
  3708. // fs.Flush();
  3709. // }
  3710. //}
  3711. //catch (Exception ex)
  3712. //{
  3713. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3714. //}
  3715. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3716. try
  3717. {
  3718. var TypeName = Request.Headers["TypeName"].ToString();
  3719. if (file != null)
  3720. {
  3721. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3722. //文件名称
  3723. string projectFileName = file.FileName;
  3724. //上传的文件的路径
  3725. string filePath = $"{fileDir}/{projectFileName}";
  3726. if (TypeName == "A")//A代表团组增减款项
  3727. {
  3728. if (!Directory.Exists(fileDir))
  3729. {
  3730. Directory.CreateDirectory(fileDir);
  3731. }
  3732. //上传的文件的路径
  3733. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3734. }
  3735. else if (TypeName == "B")//B代表商邀相关文件
  3736. {
  3737. if (!Directory.Exists(fileDir))
  3738. {
  3739. Directory.CreateDirectory(fileDir);
  3740. }
  3741. //上传的文件的路径
  3742. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3743. }
  3744. using (FileStream fs = System.IO.File.Create(filePath))
  3745. {
  3746. file.CopyTo(fs);
  3747. fs.Flush();
  3748. }
  3749. return Ok(JsonView(true, "上传成功!", projectFileName));
  3750. }
  3751. else
  3752. {
  3753. return Ok(JsonView(false, "上传失败!"));
  3754. }
  3755. }
  3756. catch (Exception ex)
  3757. {
  3758. return Ok(JsonView(false, "程序错误!"));
  3759. }
  3760. }
  3761. /// <summary>
  3762. /// 删除指定文件
  3763. /// </summary>
  3764. /// <param name="dto"></param>
  3765. /// <returns></returns>
  3766. [HttpPost]
  3767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3768. public async Task<IActionResult> DelFile(DelFileDto dto)
  3769. {
  3770. try
  3771. {
  3772. var TypeName = Request.Headers["TypeName"].ToString();
  3773. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3774. string filePath = "";
  3775. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3776. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3777. int id = 0;
  3778. if (TypeName == "A")
  3779. {
  3780. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3781. // 删除该文件
  3782. System.IO.File.Delete(filePath);
  3783. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3784. .Where(a => a.Id == dto.Id)
  3785. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3786. .ExecuteCommandAsync();
  3787. }
  3788. else if (TypeName == "B")
  3789. {
  3790. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3791. // 删除该文件
  3792. System.IO.File.Delete(filePath);
  3793. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3794. if (info != null)
  3795. {
  3796. string[] files = new string[] { };
  3797. if (!string.IsNullOrEmpty(info.Attachment))
  3798. {
  3799. try
  3800. {
  3801. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3802. }
  3803. catch (Exception)
  3804. {
  3805. files = new List<string>() { info.Attachment }.ToArray();
  3806. }
  3807. }
  3808. if (files.Length > 0)
  3809. {
  3810. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3811. string filePath2 = string.Empty;
  3812. if (files1.Length > 0)
  3813. {
  3814. filePath2 = JsonConvert.SerializeObject(files1);
  3815. }
  3816. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3817. .Where(a => a.Id == dto.Id)
  3818. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3819. .ExecuteCommandAsync();
  3820. }
  3821. }
  3822. }
  3823. if (id != 0)
  3824. {
  3825. return Ok(JsonView(true, "成功!"));
  3826. }
  3827. else
  3828. {
  3829. return Ok(JsonView(false, "失败!"));
  3830. }
  3831. }
  3832. catch (Exception ex)
  3833. {
  3834. return Ok(JsonView(false, "程序错误!"));
  3835. throw;
  3836. }
  3837. }
  3838. /// <summary>
  3839. /// 文件上传多个文件 可以带参数
  3840. /// </summary>
  3841. /// <param name="files"></param>
  3842. /// <returns></returns>
  3843. [HttpPost]
  3844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3845. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3846. {
  3847. try
  3848. {
  3849. var TypeName = Request.Headers["TypeName"].ToString();
  3850. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3851. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3852. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3853. var filePahts = new List<string>();
  3854. foreach (var file in files)
  3855. {
  3856. //文件名称
  3857. string projectFileName = file.FileName;
  3858. //上传的文件的路径
  3859. string filePath = $"{fileDir}/{projectFileName}";
  3860. if (TypeName == "A")//A代表团组增减款项
  3861. {
  3862. if (!Directory.Exists(fileDir))
  3863. {
  3864. Directory.CreateDirectory(fileDir);
  3865. }
  3866. //上传的文件的路径
  3867. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3868. }
  3869. else if (TypeName == "B")//B代表商邀相关文件
  3870. {
  3871. if (!Directory.Exists(fileDir))
  3872. {
  3873. Directory.CreateDirectory(fileDir);
  3874. }
  3875. //上传的文件的路径
  3876. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3877. }
  3878. using (FileStream fs = System.IO.File.Create(filePath))
  3879. {
  3880. file.CopyTo(fs);
  3881. fs.Flush();
  3882. }
  3883. filePahts.Add(projectFileName);
  3884. }
  3885. return Ok(JsonView(true, "上传成功!", filePahts));
  3886. }
  3887. catch (Exception ex)
  3888. {
  3889. return Ok(JsonView(false, "程序错误!"));
  3890. }
  3891. }
  3892. #endregion
  3893. #region 商邀费用录入
  3894. /// <summary>
  3895. /// 根据团组Id查询商邀费用列表
  3896. /// </summary>
  3897. /// <param name="dto"></param>
  3898. /// <returns></returns>
  3899. [HttpPost]
  3900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3901. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3902. {
  3903. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3904. if (groupData.Code != 0)
  3905. {
  3906. return Ok(JsonView(false, groupData.Msg));
  3907. }
  3908. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3909. }
  3910. /// <summary>
  3911. /// 商邀费用列表
  3912. /// 下载文件
  3913. /// </summary>
  3914. /// <param name="id"></param>
  3915. /// <returns></returns>
  3916. [HttpGet("{id}")]
  3917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3918. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3919. {
  3920. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3921. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3922. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3923. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3924. var filePaths = new List<string>();
  3925. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3926. try
  3927. {
  3928. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3929. }
  3930. catch (Exception ex)
  3931. {
  3932. filePaths.Add(info.Attachment);
  3933. }
  3934. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3935. for (int i = 0; i < filePaths.Count; i++)
  3936. {
  3937. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3938. }
  3939. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3940. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3941. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3942. {
  3943. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3944. {
  3945. foreach (string filePath in filePaths)
  3946. {
  3947. if (System.IO.File.Exists(filePath))
  3948. {
  3949. // 获取文件名
  3950. string fileName = Path.GetFileName(filePath);
  3951. // 将文件添加到ZIP归档中
  3952. zipArchive.CreateEntryFromFile(filePath, fileName);
  3953. }
  3954. }
  3955. }
  3956. }
  3957. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3958. }
  3959. /// <summary>
  3960. /// 商邀费用 Info Page 基础数据源
  3961. /// </summary>
  3962. /// <returns></returns>
  3963. [HttpPost]
  3964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3965. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3966. {
  3967. try
  3968. {
  3969. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3970. if (groupData.Code != 0)
  3971. {
  3972. return Ok(JsonView(false, groupData.Msg));
  3973. }
  3974. return Ok(JsonView(true, "操作成功", groupData.Data));
  3975. }
  3976. catch (Exception ex)
  3977. {
  3978. return Ok(JsonView(false, ex.Message));
  3979. throw;
  3980. }
  3981. }
  3982. /// <summary>
  3983. /// 根据商邀费用ID查询C表和商邀费用数据
  3984. /// </summary>
  3985. /// <param name="dto"></param>
  3986. /// <returns></returns>
  3987. [HttpPost]
  3988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3989. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3990. {
  3991. try
  3992. {
  3993. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3994. if (groupData.Code != 0)
  3995. {
  3996. return Ok(JsonView(false, groupData.Msg));
  3997. }
  3998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3999. }
  4000. catch (Exception ex)
  4001. {
  4002. return Ok(JsonView(false, ex.Message));
  4003. throw;
  4004. }
  4005. }
  4006. /// <summary>
  4007. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4008. /// </summary>
  4009. /// <param name="dto"></param>
  4010. /// <returns></returns>
  4011. [HttpPost]
  4012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4013. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4014. {
  4015. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4016. if (groupData.Code != 0)
  4017. {
  4018. return Ok(JsonView(false, groupData.Msg));
  4019. }
  4020. #region 应用推送
  4021. try
  4022. {
  4023. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4024. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4025. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4026. //2024-10-21 新增LZ UID
  4027. var userIds = new List<int>() { 21 };
  4028. string title = $"系统通知";
  4029. string content = "";
  4030. var diId = dto.DiId;
  4031. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4032. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4033. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4034. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4035. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4036. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4037. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4038. }
  4039. catch (Exception ex)
  4040. {
  4041. }
  4042. #endregion
  4043. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4044. }
  4045. /// <summary>
  4046. /// 商邀删除
  4047. /// </summary>
  4048. /// <param name="dto"></param>
  4049. /// <returns></returns>
  4050. [HttpPost]
  4051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4052. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4053. {
  4054. try
  4055. {
  4056. _sqlSugar.BeginTran();
  4057. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4058. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4059. {
  4060. IsDel = 1,
  4061. DeleteUserId = dto.DeleteUserId,
  4062. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4063. })
  4064. .Where(it => it.Id == dto.Id)
  4065. .ExecuteCommand();
  4066. if (res1 > 0)
  4067. {
  4068. int _diId = 0;
  4069. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4070. if (_ioaInfo != null)
  4071. {
  4072. _diId = _ioaInfo.DiId;
  4073. }
  4074. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4075. .SetColumns(a => new Grp_CreditCardPayment()
  4076. {
  4077. IsDel = 1,
  4078. DeleteUserId = dto.DeleteUserId,
  4079. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4080. })
  4081. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4082. .ExecuteCommand();
  4083. if (res2 > 0)
  4084. {
  4085. _sqlSugar.CommitTran();
  4086. return Ok(JsonView(true, "删除成功!"));
  4087. }
  4088. }
  4089. _sqlSugar.RollbackTran();
  4090. return Ok(JsonView(false, "删除失败"));
  4091. }
  4092. catch (Exception ex)
  4093. {
  4094. _sqlSugar.RollbackTran();
  4095. return Ok(JsonView(false, ex.Message));
  4096. }
  4097. }
  4098. /// <summary>
  4099. /// 团组模块文件上传
  4100. /// </summary>
  4101. /// <param name="dto"></param>
  4102. /// <returns></returns>
  4103. [HttpPost]
  4104. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4105. {
  4106. var jw = JsonView(false);
  4107. long M = 1024 * 1024;
  4108. if (dto.Files == null || dto.Files.Count == 0)
  4109. {
  4110. jw.Msg = "无文件信息!";
  4111. return Ok(jw);
  4112. }
  4113. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4114. {
  4115. jw.Msg = "文件大小超过20M!";
  4116. return Ok(jw);
  4117. }
  4118. //var nameSp = dto.File.FileName.Split(".");
  4119. //if (nameSp.Length < 2)
  4120. //{
  4121. // jw.Msg = "拓展名称有误!";
  4122. // return Ok(jw);
  4123. //}
  4124. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4125. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4126. //{
  4127. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4128. // return Ok(jw);
  4129. //}
  4130. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4131. if (Ctable == null)
  4132. {
  4133. jw.Msg = "Ctable指向有误!";
  4134. return Ok(jw);
  4135. }
  4136. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4137. if (groupInfo == null)
  4138. {
  4139. jw.Msg = "团组信息不存在!";
  4140. return Ok(jw);
  4141. }
  4142. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4143. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4144. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4145. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4146. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4147. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4148. try
  4149. {
  4150. if (!Directory.Exists(fileBase))
  4151. {
  4152. Directory.CreateDirectory(fileBase);
  4153. }
  4154. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4155. foreach (var fileStream in dto.Files)
  4156. {
  4157. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4158. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4159. {
  4160. Cid = dto.Cid,
  4161. CreateTime = DateTime.Now,
  4162. CreateUserId = dto.Userid,
  4163. Ctable = dto.Ctable,
  4164. Diid = dto.Diid,
  4165. IsDel = 0,
  4166. FilePath = saveFilePath,
  4167. FileName = fileStream.FileName
  4168. };
  4169. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4170. {
  4171. fileStream.CopyTo(fs);
  4172. fs.Flush();
  4173. }
  4174. saveArr.Add(file);
  4175. }
  4176. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4177. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4178. jw = JsonView(true, "保存成功!", new
  4179. {
  4180. count = addResult,
  4181. filesName = saveArr.Select(x => x.FileName)
  4182. });
  4183. }
  4184. catch (Exception ex)
  4185. {
  4186. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4187. {
  4188. count = 0,
  4189. filesName = new string[0],
  4190. });
  4191. }
  4192. return Ok(jw);
  4193. }
  4194. /// <summary>
  4195. /// 查询各模块已保存文件
  4196. /// </summary>
  4197. /// <param name="dto"></param>
  4198. /// <returns></returns>
  4199. [HttpPost]
  4200. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4201. {
  4202. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4203. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4204. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4205. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4206. {
  4207. expression = Expressionable.Create<Grp_GroupModelFile>()
  4208. .And(x => visaIds.Contains(x.CreateUserId));
  4209. }
  4210. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4211. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4212. .Where(expression.ToExpression())
  4213. .ToList();
  4214. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4215. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4216. {
  4217. x.FileName,
  4218. x.Id,
  4219. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4220. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4221. })));
  4222. }
  4223. /// <summary>
  4224. /// 下载该团组下的所有文件
  4225. /// </summary>
  4226. /// <param name="dto"></param>
  4227. /// <returns></returns>
  4228. [HttpPost]
  4229. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4230. {
  4231. var jw = JsonView(false);
  4232. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4233. if (groupInfo == null)
  4234. {
  4235. jw.Msg = "团组信息不存在!";
  4236. return Ok(jw);
  4237. }
  4238. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4239. var isModule = Convert.ToBoolean(dto.isModule);
  4240. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4241. IOOperatorHelper io = new IOOperatorHelper();
  4242. if (isModule)
  4243. {
  4244. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4245. foreach (var moduleArr in moduleGroup)
  4246. {
  4247. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4248. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4249. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4250. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4251. foreach (var item in moduleArr)
  4252. {
  4253. if (System.IO.File.Exists(item.FilePath))
  4254. {
  4255. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4256. {
  4257. byte[] bytes = new byte[fileStream.Length];
  4258. fileStream.Read(bytes, 0, bytes.Length);
  4259. fileStream.Close();
  4260. Stream stream = new MemoryStream(bytes);
  4261. chiZips.Add(item.FileName, stream);
  4262. }
  4263. }
  4264. }
  4265. if (chiZips.Count > 0)
  4266. {
  4267. var byts = io.ConvertZipStream(chiZips);
  4268. Stream stream = new MemoryStream(byts);
  4269. Zips.Add(key.Name + "_.zip", stream);
  4270. }
  4271. }
  4272. }
  4273. else
  4274. {
  4275. foreach (var item in dbQuery)
  4276. {
  4277. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4278. {
  4279. byte[] bytes = new byte[fileStream.Length];
  4280. fileStream.Read(bytes, 0, bytes.Length);
  4281. fileStream.Close();
  4282. Stream stream = new MemoryStream(bytes);
  4283. while (Zips.Keys.Contains(item.FileName))
  4284. {
  4285. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4286. }
  4287. Zips.Add(item.FileName, stream);
  4288. }
  4289. }
  4290. }
  4291. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4292. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4293. if (Zips.Count > 0)
  4294. {
  4295. var byts = io.ConvertZipStream(Zips);
  4296. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4297. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4298. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4299. }
  4300. else
  4301. {
  4302. jw.Msg = "暂无生成文件!";
  4303. }
  4304. return Ok(jw);
  4305. }
  4306. /// <summary>
  4307. /// 下载该团组下此模块的所有文件
  4308. /// </summary>
  4309. /// <param name="dto"></param>
  4310. /// <returns></returns>
  4311. [HttpPost]
  4312. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4313. {
  4314. var jw = JsonView(false);
  4315. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4316. if (groupInfo == null)
  4317. {
  4318. jw.Msg = "团组信息不存在!";
  4319. return Ok(jw);
  4320. }
  4321. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4322. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4323. && x.IsDel == 0);
  4324. if (key == null)
  4325. {
  4326. jw.Msg = "Ctable指向错误!";
  4327. return Ok(jw);
  4328. }
  4329. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4330. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4331. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4332. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4333. IOOperatorHelper io = new IOOperatorHelper();
  4334. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4335. foreach (var item in dbQuery)
  4336. {
  4337. if (System.IO.File.Exists(item.FilePath))
  4338. {
  4339. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4340. {
  4341. byte[] bytes = new byte[fileStream.Length];
  4342. fileStream.Read(bytes, 0, bytes.Length);
  4343. fileStream.Close();
  4344. Stream stream = new MemoryStream(bytes);
  4345. while (Zips.Keys.Contains(item.FileName))
  4346. {
  4347. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4348. }
  4349. Zips.Add(item.FileName, stream);
  4350. }
  4351. }
  4352. }
  4353. if (Zips.Count > 0)
  4354. {
  4355. var byts = io.ConvertZipStream(Zips);
  4356. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4357. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4358. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4359. }
  4360. else
  4361. {
  4362. jw.Msg = "暂无生成文件!";
  4363. }
  4364. return Ok(jw);
  4365. }
  4366. /// <summary>
  4367. /// 删除该团组下的指定文件
  4368. /// </summary>
  4369. /// <param name="dto"></param>
  4370. /// <returns></returns>
  4371. [HttpPost]
  4372. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4373. {
  4374. var jw = JsonView(false);
  4375. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4376. if (sing == null)
  4377. {
  4378. jw.Msg = "暂无";
  4379. return Ok(jw);
  4380. }
  4381. if (System.IO.File.Exists(sing.FilePath))
  4382. {
  4383. try
  4384. {
  4385. System.IO.File.Delete(sing.FilePath);
  4386. }
  4387. catch (Exception ex)
  4388. {
  4389. jw.Msg = "删除失败!" + ex.Message;
  4390. return Ok(jw);
  4391. }
  4392. }
  4393. sing.IsDel = 1;
  4394. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4395. sing.DeleteUserId = dto.UserId;
  4396. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4397. jw = JsonView(true, "删除成功!");
  4398. return Ok(jw);
  4399. }
  4400. #endregion
  4401. #region 团组英文资料
  4402. /// <summary>
  4403. /// 查询团组英文所有资料
  4404. /// </summary>
  4405. /// <param name="dto"></param>
  4406. /// <returns></returns>
  4407. [HttpPost]
  4408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4409. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4410. {
  4411. try
  4412. {
  4413. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4414. if (groupData.Code != 0)
  4415. {
  4416. return Ok(JsonView(false, groupData.Msg));
  4417. }
  4418. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4419. }
  4420. catch (Exception ex)
  4421. {
  4422. return Ok(JsonView(false, "程序错误!"));
  4423. throw;
  4424. }
  4425. }
  4426. /// <summary>
  4427. /// 团组英文资料操作(Status:1.新增,2.修改)
  4428. /// </summary>
  4429. /// <param name="dto"></param>
  4430. /// <returns></returns>
  4431. [HttpPost]
  4432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4433. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4434. {
  4435. try
  4436. {
  4437. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4438. if (groupData.Code != 0)
  4439. {
  4440. return Ok(JsonView(false, groupData.Msg));
  4441. }
  4442. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4443. }
  4444. catch (Exception ex)
  4445. {
  4446. return Ok(JsonView(false, "程序错误!"));
  4447. throw;
  4448. }
  4449. }
  4450. /// <summary>
  4451. /// 团组英文资料Id查询数据
  4452. /// </summary>
  4453. /// <param name="dto"></param>
  4454. /// <returns></returns>
  4455. [HttpPost]
  4456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4457. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4458. {
  4459. try
  4460. {
  4461. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4462. if (_DelegationEnData != null)
  4463. {
  4464. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4465. }
  4466. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4467. }
  4468. catch (Exception ex)
  4469. {
  4470. return Ok(JsonView(false, "程序错误!"));
  4471. throw;
  4472. }
  4473. }
  4474. /// <summary>
  4475. /// 团组英文资料删除
  4476. /// </summary>
  4477. /// <param name="dto"></param>
  4478. /// <returns></returns>
  4479. [HttpPost]
  4480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4481. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4482. {
  4483. try
  4484. {
  4485. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4486. if (!res)
  4487. {
  4488. return Ok(JsonView(false, "删除失败"));
  4489. }
  4490. return Ok(JsonView(true, "删除成功!"));
  4491. }
  4492. catch (Exception ex)
  4493. {
  4494. return Ok(JsonView(false, "程序错误!"));
  4495. throw;
  4496. }
  4497. }
  4498. #endregion
  4499. #region 导出邀请函
  4500. /// <summary>
  4501. /// 导出邀请函页面初始化
  4502. /// </summary>
  4503. /// <param name="dto"></param>
  4504. /// <returns></returns>
  4505. [HttpPost]
  4506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4507. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4508. {
  4509. try
  4510. {
  4511. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4512. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4513. if (dto.DiId == 0)
  4514. {
  4515. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4516. }
  4517. else
  4518. {
  4519. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4520. }
  4521. return Ok(JsonView(true, "查询成功!", new
  4522. {
  4523. deleClient = crm_Deles,
  4524. delegations = grp_Delegations
  4525. }));
  4526. }
  4527. catch (Exception ex)
  4528. {
  4529. return Ok(JsonView(false, "程序错误!"));
  4530. throw;
  4531. }
  4532. }
  4533. /// <summary>
  4534. /// 导出邀请函
  4535. /// </summary>
  4536. /// <param name="dto"></param>
  4537. /// <returns></returns>
  4538. [HttpPost]
  4539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4540. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4541. {
  4542. #region 参数验证
  4543. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4544. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4545. #endregion
  4546. try
  4547. {
  4548. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4549. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4550. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4551. From Grp_TourClientList tcl
  4552. Left Join
  4553. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4554. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4555. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4556. From Crm_DeleClient dc
  4557. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4558. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4559. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4560. Where dc.IsDel = 0) temp
  4561. On temp.DcId =tcl.ClientId
  4562. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4563. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4564. List<string> texts = new List<string>();
  4565. if (datas.Count != 0)
  4566. {
  4567. foreach (TourClientListDetailsView item in datas)
  4568. {
  4569. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4570. {
  4571. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4572. }
  4573. else
  4574. {
  4575. string name = item.LastName + item.FirstName;
  4576. texts.Add(name);
  4577. }
  4578. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4579. {
  4580. if (!transDic.ContainsKey(item.Job))
  4581. {
  4582. texts.Add(item.Job);
  4583. }
  4584. }
  4585. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4586. {
  4587. texts.Add(item.CompanyFullName);
  4588. }
  4589. }
  4590. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4591. if (transData.Count > 0)
  4592. {
  4593. foreach (TranslateResult item in transData)
  4594. {
  4595. if (!transDic.ContainsKey(item.Query))
  4596. {
  4597. transDic.Add(item.Query, item.Translation);
  4598. }
  4599. }
  4600. }
  4601. List<GuestList> list = new List<GuestList>();
  4602. foreach (TourClientListDetailsView dele in datas)
  4603. {
  4604. GuestList guestList = new GuestList();
  4605. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4606. {
  4607. guestList.Name = dele.Pinyin;
  4608. }
  4609. else
  4610. {
  4611. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4612. guestList.Name = Name;
  4613. }
  4614. if (dele.Sex == 0)
  4615. {
  4616. guestList.Sex = "Male";
  4617. }
  4618. else if (dele.Sex == 1)
  4619. {
  4620. guestList.Sex = "Female";
  4621. }
  4622. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4623. if (!string.IsNullOrEmpty(dele.Job))
  4624. {
  4625. guestList.Job = dele.Job;
  4626. }
  4627. list.Add(guestList);
  4628. }
  4629. //载入模板
  4630. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4631. DocumentBuilder builder = new DocumentBuilder(doc);
  4632. //获取word里所有表格
  4633. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4634. //获取所填表格的序数
  4635. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4636. var rowStart = tableOne.Rows[0]; //获取第1行
  4637. //循环赋值
  4638. for (int i = 0; i < list.Count; i++)
  4639. {
  4640. builder.MoveToCell(0, i + 1, 0, 0);
  4641. builder.Write(list[i].Name.ToString());
  4642. builder.MoveToCell(0, i + 1, 1, 0);
  4643. builder.Write(list[i].Sex.ToString());
  4644. builder.MoveToCell(0, i + 1, 2, 0);
  4645. builder.Write(list[i].DOB.ToString());
  4646. builder.MoveToCell(0, i + 1, 3, 0);
  4647. builder.Write(list[i].Job.ToString());
  4648. }
  4649. //删除多余行
  4650. while (tableOne.Rows.Count > list.Count + 1)
  4651. {
  4652. tableOne.Rows.RemoveAt(list.Count + 1);
  4653. }
  4654. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4655. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4656. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4657. doc.Save(filePath);
  4658. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4659. return Ok(JsonView(true, "操作成功!", Url));
  4660. }
  4661. else
  4662. {
  4663. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4664. }
  4665. }
  4666. catch (Exception ex)
  4667. {
  4668. return Ok(JsonView(false, ex.Message));
  4669. throw;
  4670. }
  4671. }
  4672. #endregion
  4673. #region 团组经理模块 出入境费用
  4674. /// <summary>
  4675. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4676. /// </summary>
  4677. /// <returns></returns>
  4678. [HttpPost]
  4679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4680. public async Task<IActionResult> SetDayAndCostAreaChange()
  4681. {
  4682. try
  4683. {
  4684. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4685. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4686. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4687. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4688. foreach (var item in unite) //处理交集数据
  4689. {
  4690. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4691. }
  4692. foreach (var item in merge) //处理差集数据
  4693. {
  4694. int nationalTravelFeeId = 0;
  4695. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4696. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4697. else
  4698. {
  4699. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4700. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4701. }
  4702. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4703. }
  4704. //只更新dayAndCost 的 nationalTravelFeeId;
  4705. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4706. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4707. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4708. }
  4709. catch (Exception ex)
  4710. {
  4711. return Ok(JsonView(false, ex.Message));
  4712. throw;
  4713. }
  4714. }
  4715. /// <summary>
  4716. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4717. /// </summary>
  4718. /// <returns></returns>
  4719. [HttpPost]
  4720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4721. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4722. {
  4723. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4724. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4725. //SetDataInfoView
  4726. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4727. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4728. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4729. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4730. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4731. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4732. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4733. //默认币种显示
  4734. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4735. {
  4736. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4737. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4738. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4739. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4740. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4741. };
  4742. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4743. if (_currencyRate.Count > 0)
  4744. {
  4745. foreach (var item in _currencyInfos)
  4746. {
  4747. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4748. if (rateInfo != null)
  4749. {
  4750. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4751. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  4752. else rate1 *= 1.035M;
  4753. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4754. }
  4755. }
  4756. }
  4757. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4758. return Ok(JsonView(true, "查询成功!", new
  4759. {
  4760. GroupNameData = groupNameData.Data,
  4761. CurrencyData = _CurrencyData,
  4762. WordTypeData = _WordTypeData,
  4763. ExcelTypeData = _ExcelTypeData,
  4764. CurrencyInit = _currencyInfos,
  4765. ViewPermissionData = viewPermissionData
  4766. }));
  4767. }
  4768. /// <summary>
  4769. /// 团组模块 - 出入境费用
  4770. /// 实时汇率 tips
  4771. /// 签证费用 tips
  4772. /// 机票费用 tips
  4773. /// </summary>
  4774. /// <returns></returns>
  4775. [HttpPost]
  4776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4777. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4778. {
  4779. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4780. //默认币种显示
  4781. var _currencyInfos = _currencyInit;
  4782. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4783. List<dynamic> reteInfos = new List<dynamic>();
  4784. if (_currencyRate.Count > 0)
  4785. {
  4786. foreach (var item in _currencyInfos)
  4787. {
  4788. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4789. if (rateInfo != null)
  4790. {
  4791. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4792. decimal rate1 = item.Rate;
  4793. rate1 *= 1.03M;
  4794. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4795. reteInfos.Add(new
  4796. {
  4797. currCode = item.CurrencyCode,
  4798. currName = item.CurrencyName,
  4799. rate = rate2,
  4800. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4801. });
  4802. }
  4803. }
  4804. }
  4805. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4806. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4807. return Ok(JsonView(true, "查询成功!", new
  4808. {
  4809. //GroupNameData = groupNameData.Data,
  4810. visaData = visaData.Data,
  4811. airData = airData.Data,
  4812. reteInfos = reteInfos
  4813. }));
  4814. }
  4815. /// <summary>
  4816. /// 团组模块 - 出入境费用 - Info
  4817. /// </summary>
  4818. /// <returns></returns>
  4819. [HttpPost]
  4820. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4822. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4823. {
  4824. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4825. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4826. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4827. }
  4828. /// <summary>
  4829. /// 团组模块 - 出入境费用 - 设置view权限
  4830. /// </summary>
  4831. /// <returns></returns>
  4832. [HttpPost]
  4833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4834. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4835. {
  4836. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4837. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4838. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4839. var permissions = new List<Grp_EnterExitCostPermission>();
  4840. foreach (var userId in dto.UserIds)
  4841. {
  4842. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4843. }
  4844. if (permissions.Any())
  4845. {
  4846. _sqlSugar.BeginTran();
  4847. try
  4848. {
  4849. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4850. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4851. if (result < 1)
  4852. {
  4853. _sqlSugar.RollbackTran();
  4854. return Ok(JsonView(false));
  4855. }
  4856. }
  4857. catch (Exception ex)
  4858. {
  4859. _sqlSugar.RollbackTran();
  4860. return Ok(JsonView(false, ex.Message));
  4861. }
  4862. _sqlSugar.CommitTran();
  4863. return Ok(JsonView(true));
  4864. }
  4865. return Ok(JsonView(false));
  4866. }
  4867. /// <summary>
  4868. /// 团组模块 - 出入境费用 - Add And Update
  4869. /// </summary>
  4870. /// <returns></returns>
  4871. [HttpPost]
  4872. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4874. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4875. {
  4876. try
  4877. {
  4878. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4879. if (dto.DayOtherPriceData.Any())
  4880. {
  4881. var inserList = dto.DayOtherPriceData
  4882. .Where(x => x.Id == 0)
  4883. .Select(x => new Grp_DayOtherPrice
  4884. {
  4885. Cost = x.Cost,
  4886. Id = x.Id,
  4887. CreateTime = DateTime.Now,
  4888. CreateUserId = dto.UserId,
  4889. Currency = x.Currency,
  4890. Diid = x.DiId,
  4891. Index = x.Index,
  4892. IsDel = 0,
  4893. SetDataId = x.SetDataId,
  4894. SubTotal = x.SubTotal,
  4895. Remark = x.Remark
  4896. })
  4897. .ToList();
  4898. var updateList = dto.DayOtherPriceData
  4899. .Where(x => x.Id != 0)
  4900. .Select(x => new Grp_DayOtherPrice
  4901. {
  4902. Cost = x.Cost,
  4903. Id = x.Id,
  4904. CreateTime = DateTime.Now,
  4905. CreateUserId = dto.UserId,
  4906. Currency = x.Currency,
  4907. Diid = x.DiId,
  4908. Index = x.Index,
  4909. IsDel = 0,
  4910. SetDataId = x.SetDataId,
  4911. SubTotal = x.SubTotal,
  4912. Remark = x.Remark
  4913. })
  4914. .ToList();
  4915. //添加
  4916. _sqlSugar.BeginTran();
  4917. if (inserList.Any())
  4918. {
  4919. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4920. }
  4921. if (updateList.Any())
  4922. {
  4923. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4924. }
  4925. _sqlSugar.CommitTran();
  4926. }
  4927. if (data.Code != 0)
  4928. {
  4929. return Ok(JsonView(false, data.Msg));
  4930. }
  4931. //生成默认文件pdf并且通知人员
  4932. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4933. {
  4934. DiId = dto.DiId,
  4935. ExportType = 1,
  4936. SubTypeId = 1005
  4937. }, "pdf");
  4938. //发送通知
  4939. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4940. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4941. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4942. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4943. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4944. //汇率信息记录
  4945. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4946. return Ok(JsonView(true, data.Msg, data.Data));
  4947. }
  4948. catch (Exception ex)
  4949. {
  4950. return Ok(JsonView(false, ex.Message));
  4951. }
  4952. }
  4953. /// <summary>
  4954. /// 团组模块 - 出入境费用 - Confirm 费用
  4955. /// </summary>
  4956. /// <returns></returns>
  4957. [HttpPost]
  4958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4959. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4960. {
  4961. //TODO:测试完毕需把对应的用户ID更改
  4962. //1、数据表添加字段
  4963. //2、更改字段接口()
  4964. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4965. //3、确认成功 给财务发送消息
  4966. if (_view.Code == 200)
  4967. {
  4968. if (dto.Type == 1)
  4969. {
  4970. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4971. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4972. }
  4973. }
  4974. return Ok(_view);
  4975. }
  4976. /// <summary>
  4977. /// 团组模块 - 出入境费用 - File download
  4978. /// </summary>
  4979. /// <param name="dto"></param>
  4980. /// <returns></returns>
  4981. [HttpPost]
  4982. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  4983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4984. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4985. {
  4986. try
  4987. {
  4988. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4989. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4990. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4991. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4992. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4993. 3 团组成员名单 1 团组成员名单", ""));
  4994. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4995. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4996. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4997. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4998. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4999. //数据源
  5000. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5001. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5002. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5003. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5004. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5005. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5006. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5007. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5008. .Select((x, a, b) => new
  5009. {
  5010. x.Index,
  5011. itemName = a.Name,
  5012. CurrencyStr = b.Name,
  5013. x.Cost,
  5014. x.SubTotal,
  5015. x.Remark
  5016. })
  5017. .OrderBy((x) => x.Index)
  5018. .ToList(); //其他款项费用
  5019. var peiceItemCurrencys = new List<string>();
  5020. if (_DayAndCosts.Any())
  5021. {
  5022. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5023. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5024. }
  5025. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5026. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5027. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5028. {
  5029. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5030. }
  5031. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5032. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5033. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5034. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5035. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5036. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5037. .Select((tcl, dc, cc) => new ClientInfo
  5038. {
  5039. LastName = dc.LastName,
  5040. FirstName = dc.FirstName,
  5041. Sex = dc.Sex,
  5042. Birthday = dc.BirthDay,
  5043. Company = cc.CompanyFullName,
  5044. Job = dc.Job
  5045. })
  5046. .ToList();
  5047. foreach (var item in DeleClientList)
  5048. {
  5049. EncryptionProcessor.DecryptProperties(item);
  5050. }
  5051. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5052. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5053. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5054. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5055. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5056. if (dto.ExportType == 1) //明细表
  5057. {
  5058. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5059. {
  5060. //获取模板
  5061. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5062. //载入模板
  5063. Document doc = new Document(tempPath);
  5064. DocumentBuilder builder = new DocumentBuilder(doc);
  5065. //利用键值对存放数据
  5066. Dictionary<string, string> dic = new Dictionary<string, string>();
  5067. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5068. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5069. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5070. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5071. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5072. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5073. //境内费用(其他费用)
  5074. if (_EnterExitCosts.ChoiceOne == 1)
  5075. {
  5076. string row1_1 = "";
  5077. if (_EnterExitCosts.Visa > 0)
  5078. {
  5079. //insidePayTotal += _EnterExitCosts.Visa;
  5080. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5081. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5082. {
  5083. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5084. }
  5085. }
  5086. string row1_2 = "";
  5087. if (_EnterExitCosts.YiMiao > 0)
  5088. {
  5089. //insidePayTotal += _EnterExitCosts.YiMiao;
  5090. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5091. }
  5092. if (_EnterExitCosts.HeSuan > 0)
  5093. {
  5094. //insidePayTotal += _EnterExitCosts.HeSuan;
  5095. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5096. }
  5097. if (_EnterExitCosts.Service > 0)
  5098. {
  5099. //insidePayTotal += _EnterExitCosts.Service;
  5100. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5101. }
  5102. string row1_3 = "";
  5103. if (_EnterExitCosts.Safe > 0)
  5104. {
  5105. //insidePayTotal += _EnterExitCosts.Safe;
  5106. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5107. }
  5108. if (_EnterExitCosts.Ticket > 0)
  5109. {
  5110. //insidePayTotal += _EnterExitCosts.Ticket;
  5111. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5112. }
  5113. string row1 = "";
  5114. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5115. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5116. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5117. row1 += $"备注:{_EnterExitCosts.Remark}";
  5118. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5119. dic.Add("Row1Str", row1);
  5120. }
  5121. string airTotalStr = string.Empty,
  5122. airPriceStr = string.Empty;
  5123. //经济舱
  5124. if (_EnterExitCosts.SumJJC == 1)
  5125. {
  5126. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5127. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5128. }
  5129. //公务舱
  5130. if (_EnterExitCosts.SumGWC == 1)
  5131. {
  5132. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5133. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5134. }
  5135. //头等舱
  5136. if (_EnterExitCosts.SumTDC == 1)
  5137. {
  5138. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5139. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5140. }
  5141. //汇率描述
  5142. string rateStr = "";
  5143. if (peiceItemCurrencyInfos.Any())
  5144. {
  5145. rateStr = "\r\n汇率描述:";
  5146. foreach (var item in peiceItemCurrencyInfos)
  5147. {
  5148. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5149. }
  5150. }
  5151. string twoItemRemark = "备注:";
  5152. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5153. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5154. dic.Add("AirTotalStr", airTotalStr);
  5155. dic.Add("AirPriceStr", airPriceStr);
  5156. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5157. dic.Add("TwoItemRemark", twoItemRemark);
  5158. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5159. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5160. int table1Row = 0,
  5161. table2Row = 0,
  5162. table3Row = 0,
  5163. table4Row = 0,
  5164. table5Row = 0;
  5165. //住宿费
  5166. if (_EnterExitCosts.ChoiceThree == 1)
  5167. {
  5168. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5169. table1Row = dac1.Count;
  5170. #region 填充word表格内容
  5171. for (int i = 0; i < dac1.Count; i++)
  5172. {
  5173. Grp_DayAndCost dac = dac1[i];
  5174. if (dac == null) continue;
  5175. builder.MoveToCell(0, i, 0, 0);
  5176. builder.Write("第" + dac.Days.ToString() + "晚:");
  5177. builder.MoveToCell(0, i, 1, 0);
  5178. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5179. //builder.Write(dac.Place == null ? "" : dac.Place);
  5180. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5181. builder.MoveToCell(0, i, 2, 0);
  5182. builder.Write("费用标准:");
  5183. string curr = "";
  5184. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5185. if (currData != null)
  5186. {
  5187. curr = currData.Name;
  5188. }
  5189. builder.MoveToCell(0, i, 3, 0);
  5190. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5191. builder.MoveToCell(0, i, 4, 0);
  5192. builder.Write("费用小计:");
  5193. builder.MoveToCell(0, i, 5, 0);
  5194. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5195. }
  5196. #endregion
  5197. }
  5198. else dic.Add("SubZS", "0.00");
  5199. //删除多余行
  5200. while (table1.Rows.Count > table1Row)
  5201. {
  5202. table1.Rows.RemoveAt(table1Row);
  5203. }
  5204. //伙食费
  5205. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5206. if (_EnterExitCosts.ChoiceFour == 1)
  5207. {
  5208. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5209. table2Row = dac2.Count;
  5210. #region 填充word表格内容
  5211. for (int i = 0; i < dac2.Count; i++)
  5212. {
  5213. Grp_DayAndCost dac = dac2[i];
  5214. if (dac == null) continue;
  5215. builder.MoveToCell(1, i, 0, 0);
  5216. builder.Write("第" + dac.Days.ToString() + "天:");
  5217. builder.MoveToCell(1, i, 1, 0);
  5218. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5219. builder.MoveToCell(1, i, 2, 0);
  5220. builder.Write("费用标准:");
  5221. string curr = "";
  5222. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5223. if (currData != null)
  5224. {
  5225. curr = currData.Name;
  5226. }
  5227. builder.MoveToCell(1, i, 3, 0);
  5228. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5229. builder.MoveToCell(1, i, 4, 0);
  5230. builder.Write("费用小计:");
  5231. builder.MoveToCell(1, i, 5, 0);
  5232. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5233. }
  5234. #endregion
  5235. }
  5236. else dic.Add("SubHS", "0.00");
  5237. //删除多余行
  5238. while (table2.Rows.Count > table2Row)
  5239. {
  5240. table2.Rows.RemoveAt(table2Row);
  5241. }
  5242. //公杂费
  5243. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5244. if (_EnterExitCosts.ChoiceFive == 1)
  5245. {
  5246. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5247. table3Row = dac3.Count;
  5248. #region 填充word表格内容
  5249. for (int i = 0; i < dac3.Count; i++)
  5250. {
  5251. Grp_DayAndCost dac = dac3[i];
  5252. if (dac == null) continue;
  5253. builder.MoveToCell(2, i, 0, 0);
  5254. builder.Write("第" + dac.Days.ToString() + "天:");
  5255. builder.MoveToCell(2, i, 1, 0);
  5256. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5257. builder.MoveToCell(2, i, 2, 0);
  5258. builder.Write("费用标准:");
  5259. string curr = "";
  5260. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5261. if (currData != null)
  5262. {
  5263. curr = currData.Name;
  5264. }
  5265. builder.MoveToCell(2, i, 3, 0);
  5266. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5267. builder.MoveToCell(2, i, 4, 0);
  5268. builder.Write("费用小计:");
  5269. builder.MoveToCell(2, i, 5, 0);
  5270. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5271. }
  5272. //删除多余行
  5273. while (table3.Rows.Count > table3Row)
  5274. {
  5275. table3.Rows.RemoveAt(table3Row);
  5276. }
  5277. #endregion
  5278. }
  5279. else dic.Add("SubGZF", "0.00");
  5280. //删除多余行
  5281. while (table3.Rows.Count > table3Row)
  5282. {
  5283. table3.Rows.RemoveAt(table3Row);
  5284. }
  5285. //培训费
  5286. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5287. if (_EnterExitCosts.ChoiceSix == 1)
  5288. {
  5289. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5290. dic.Add("SubPX", pxStr);
  5291. table4Row = dac4.Count;
  5292. #region 填充word表格内容
  5293. for (int i = 0; i < dac4.Count; i++)
  5294. {
  5295. Grp_DayAndCost dac = dac4[i];
  5296. if (dac == null) continue;
  5297. builder.MoveToCell(3, i, 0, 0);
  5298. builder.Write("第" + dac.Days.ToString() + "天:");
  5299. builder.MoveToCell(3, i, 1, 0);
  5300. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5301. builder.MoveToCell(3, i, 2, 0);
  5302. builder.Write("费用标准:");
  5303. string curr = "";
  5304. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5305. if (currData != null)
  5306. {
  5307. curr = currData.Name;
  5308. }
  5309. builder.MoveToCell(3, i, 3, 0);
  5310. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5311. builder.MoveToCell(3, i, 4, 0);
  5312. builder.Write("费用小计:");
  5313. builder.MoveToCell(3, i, 5, 0);
  5314. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5315. }
  5316. #endregion
  5317. }
  5318. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5319. //删除多余行
  5320. while (table4.Rows.Count > table4Row)
  5321. {
  5322. table4.Rows.RemoveAt(table4Row);
  5323. }
  5324. //其他费用
  5325. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5326. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5327. {
  5328. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5329. dic.Add("titleQi", qtStr);
  5330. table5Row = dac5.Count;
  5331. #region 填充word表格内容
  5332. for (int i = 0; i < dac5.Count; i++)
  5333. {
  5334. var dac = dac5[i];
  5335. if (dac == null) continue;
  5336. builder.MoveToCell(4, i, 0, 0);
  5337. builder.Write("第" + dac.Index.ToString() + "项:");
  5338. builder.MoveToCell(4, i, 1, 0);
  5339. builder.Write(dac.itemName);
  5340. builder.MoveToCell(4, i, 2, 0);
  5341. builder.Write("费用标准:");
  5342. builder.MoveToCell(4, i, 3, 0);
  5343. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5344. builder.MoveToCell(4, i, 4, 0);
  5345. builder.Write("费用小计:");
  5346. builder.MoveToCell(4, i, 5, 0);
  5347. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5348. builder.MoveToCell(4, i, 6, 0);
  5349. builder.Write("备注:");
  5350. builder.MoveToCell(4, i, 7, 0);
  5351. builder.Write(dac.Remark);
  5352. }
  5353. #endregion
  5354. }
  5355. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5356. //删除多余行
  5357. while (table5.Rows.Count > table5Row)
  5358. {
  5359. table5.Rows.RemoveAt(table5Row);
  5360. }
  5361. //加上其他费用
  5362. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5363. decimal subJJC = 0.00M,
  5364. subGWC = 0.00M,
  5365. subTDC = 0.00M;
  5366. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5367. string totalLabel = string.Format("全部费用总计:");
  5368. //经济舱
  5369. if (_EnterExitCosts.SumJJC == 1)
  5370. {
  5371. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5372. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5373. }
  5374. //公务舱
  5375. if (_EnterExitCosts.SumGWC == 1) {
  5376. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5377. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5378. }
  5379. //头等舱
  5380. if (_EnterExitCosts.SumTDC == 1)
  5381. {
  5382. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5383. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5384. }
  5385. //TotalLabel
  5386. dic.Add("TotalLabel", totalLabel);
  5387. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5388. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5389. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5390. #region 填充word模板书签内容
  5391. foreach (var key in dic.Keys)
  5392. {
  5393. Bookmark bookmark = doc.Range.Bookmarks[key];
  5394. if (bookmark != null)
  5395. {
  5396. builder.MoveToBookmark(key);
  5397. builder.Write(dic[key]);
  5398. }
  5399. }
  5400. #endregion
  5401. #region 设置页眉
  5402. string userLabel = string.Empty;
  5403. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5404. if (currUserInfo != null)
  5405. {
  5406. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5407. if (userInfo != null)
  5408. {
  5409. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5410. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5411. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5412. }
  5413. }
  5414. //设置页脚
  5415. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5416. #endregion
  5417. //文件名
  5418. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5419. AsposeHelper.removewatermark_v2180();
  5420. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5421. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5422. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5423. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5424. }
  5425. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5426. {
  5427. //获取模板
  5428. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5429. //载入模板
  5430. Document doc = new Document(tempPath);
  5431. DocumentBuilder builder = new DocumentBuilder(doc);
  5432. Dictionary<string, string> dic = new Dictionary<string, string>();
  5433. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5434. {
  5435. List<string> list = new List<string>();
  5436. try
  5437. {
  5438. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5439. foreach (var item in spilitArr)
  5440. {
  5441. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5442. var depCode = spDotandEmpty[2].Substring(0, 3);
  5443. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5444. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5445. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5446. list.Add(depName);
  5447. list.Add(arrName);
  5448. }
  5449. list = list.Distinct().ToList();
  5450. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5451. }
  5452. catch (Exception)
  5453. {
  5454. dic.Add("ReturnCode", "行程录入不正确!");
  5455. }
  5456. }
  5457. else
  5458. {
  5459. dic.Add("ReturnCode", "未录入行程!");
  5460. }
  5461. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5462. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5463. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5464. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5465. {
  5466. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5467. dic.Add("Day", sp.Days.ToString());
  5468. }
  5469. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5470. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5471. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5472. //dic.Add("Names", Names);
  5473. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5474. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5475. decimal dac1totalPrice = 0.00M;
  5476. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5477. foreach (var dac in dac1)
  5478. {
  5479. if (dac.SubTotal == 0.00M)
  5480. {
  5481. continue;
  5482. }
  5483. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5484. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5485. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5486. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5487. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5488. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5489. builder.Write(currency);//币种
  5490. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5491. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5492. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5493. builder.Write("");//人数
  5494. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5495. builder.Write("");//天数
  5496. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5497. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5498. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5499. decimal rate = 0.00M;
  5500. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5501. builder.Write(rate.ToString("#0.0000"));//汇率
  5502. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5503. decimal rbmPrice = dac.SubTotal;
  5504. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5505. accommodationStartIndex++;
  5506. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5507. }
  5508. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5509. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5510. {
  5511. table1.Rows.RemoveAt(i - 1);
  5512. foodandotherStartIndex--;
  5513. }
  5514. if (dac2.Count == dac3.Count)//国家 币种 金额
  5515. {
  5516. for (int i = 0; i < dac2.Count; i++)
  5517. {
  5518. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5519. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5520. }
  5521. }
  5522. decimal dac2totalPrice = 0.00M;
  5523. foreach (var dac in dac2)
  5524. {
  5525. if (dac.SubTotal == 0)
  5526. {
  5527. continue;
  5528. }
  5529. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5530. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5531. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5532. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5533. builder.Write(currency);//币种
  5534. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5535. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5536. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5537. builder.Write("");//人数
  5538. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5539. builder.Write("");//天数
  5540. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5541. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5542. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5543. decimal rate = 0.00M;
  5544. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5545. builder.Write(rate.ToString("#0.0000"));//汇率
  5546. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5547. decimal rbmPrice = dac.SubTotal;
  5548. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5549. foodandotherStartIndex++;
  5550. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5551. }
  5552. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5553. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5554. {
  5555. table1.Rows.RemoveAt(i - 1);
  5556. }
  5557. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5558. string otherFeeStr = "";
  5559. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5560. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5561. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5562. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5563. foreach (var otherInfo in dac5)
  5564. {
  5565. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5566. }
  5567. #endregion
  5568. if (otherFeeStr.Length > 0)
  5569. {
  5570. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5571. otherFeeStr = $"({otherFeeStr})";
  5572. dic.Add("OtherFeeStr", otherFeeStr);
  5573. }
  5574. //总计
  5575. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5576. //国际旅费
  5577. string outsideAir = string.Empty;
  5578. string allPriceAir = string.Empty;
  5579. if (_EnterExitCosts.SumJJC == 1)
  5580. {
  5581. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5582. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5583. }
  5584. if (_EnterExitCosts.SumGWC == 1)
  5585. {
  5586. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5587. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5588. }
  5589. if (_EnterExitCosts.SumTDC == 1)
  5590. {
  5591. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5592. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5593. }
  5594. dic.Add("InTravelPrice", $"({outsideAir})");
  5595. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5596. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5597. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5598. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5599. foreach (var key in dic.Keys)
  5600. {
  5601. builder.MoveToBookmark(key);
  5602. builder.Write(dic[key]);
  5603. }
  5604. //模板文件名
  5605. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5606. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5607. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5608. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5609. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5610. }
  5611. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5612. {
  5613. //获取模板
  5614. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5615. //载入模板
  5616. WorkbookDesigner designer = new WorkbookDesigner();
  5617. designer.Workbook = new Workbook(tempPath);
  5618. Dictionary<string, string> dic = new Dictionary<string, string>();
  5619. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5620. {
  5621. List<string> list = new List<string>();
  5622. try
  5623. {
  5624. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5625. foreach (var item in spilitArr)
  5626. {
  5627. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5628. var depCode = spDotandEmpty[2].Substring(0, 3);
  5629. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5630. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5631. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5632. list.Add(depName);
  5633. list.Add(arrName);
  5634. }
  5635. list = list.Distinct().ToList();
  5636. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5637. }
  5638. catch (Exception)
  5639. {
  5640. dic.Add("ReturnCode", "行程录入不正确!");
  5641. }
  5642. }
  5643. else
  5644. {
  5645. dic.Add("ReturnCode", "未录入行程!");
  5646. }
  5647. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5648. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5649. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5650. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5651. {
  5652. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5653. dic.Add("Day", sp.Days.ToString());
  5654. }
  5655. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5656. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5657. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5658. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5659. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5660. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5661. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5662. designer.SetDataSource("Name", Names);
  5663. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5664. designer.SetDataSource("Day", dic["Day"] + "天");
  5665. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5666. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5667. int startIndex = 10;
  5668. const int startIndexcopy = 10;
  5669. if (dac2.Count == dac3.Count)//国家 币种 金额
  5670. {
  5671. for (int i = 0; i < dac2.Count; i++)
  5672. {
  5673. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5674. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5675. }
  5676. }
  5677. DataTable dtdac1 = new DataTable();
  5678. List<string> place = new List<string>();
  5679. dtdac1.Columns.AddRange(new DataColumn[] {
  5680. new DataColumn(){ ColumnName = "city"},
  5681. new DataColumn(){ ColumnName = "curr"},
  5682. new DataColumn(){ ColumnName = "criterion"},
  5683. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5684. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5685. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5686. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5687. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5688. });
  5689. DataTable dtdac2 = new DataTable();
  5690. dtdac2.Columns.AddRange(new DataColumn[] {
  5691. new DataColumn(){ ColumnName = "city"},
  5692. new DataColumn(){ ColumnName = "curr"},
  5693. new DataColumn(){ ColumnName = "criterion"},
  5694. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5695. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5696. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5697. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5698. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5699. });
  5700. dtdac1.TableName = "tb1";
  5701. dtdac2.TableName = "tb2";
  5702. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5703. foreach (var item in dac1)
  5704. {
  5705. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5706. if (place.Contains(item.Place))
  5707. {
  5708. continue;
  5709. }
  5710. DataRow row = dtdac1.NewRow();
  5711. row["city"] = item.Place;
  5712. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5713. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5714. row["curr"] = currency;
  5715. row["rate"] = rate.ToString("#0.0000");
  5716. row["criterion"] = item.Cost.ToString("#0.00");
  5717. row["number"] = 1;
  5718. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5719. //row["costRMB"] = rbmPrice;
  5720. dtdac1.Rows.Add(row);
  5721. place.Add(item.Place);
  5722. }
  5723. place = new List<string>();
  5724. foreach (var item in dac2)
  5725. {
  5726. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5727. if (place.Contains(item.Place))
  5728. {
  5729. continue;
  5730. }
  5731. DataRow row = dtdac2.NewRow();
  5732. row["city"] = item.Place;
  5733. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5734. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5735. row["curr"] = currency;
  5736. row["rate"] = rate.ToString("#0.0000");
  5737. row["criterion"] = item.Cost.ToString("#0.00");
  5738. row["number"] = 1;
  5739. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5740. //row["cost"] = item.SubTotal;
  5741. //row["costRMB"] = rbmPrice;
  5742. dtdac2.Rows.Add(row);
  5743. place.Add(item.Place);
  5744. //dac2totalPrice += rbmPrice;
  5745. }
  5746. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5747. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5748. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5749. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5750. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5751. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5752. string cell4Str1 = string.Empty;
  5753. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5754. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5755. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5756. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5757. string cellStr = $" 5.其他费用(";
  5758. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5759. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5760. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5761. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5762. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5763. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5764. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5765. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5766. foreach (var otherInfo in dac5)
  5767. {
  5768. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5769. }
  5770. #endregion
  5771. if (cellStr.Length > 8)
  5772. {
  5773. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5774. }
  5775. cellStr += ")";
  5776. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5777. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5778. decimal pxFee = dac4.Sum(it => it.Cost);
  5779. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5780. string celllastStr1 = "";
  5781. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5782. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5783. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5784. celllastStr1 += $",国际旅费 元";
  5785. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5786. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5787. designer.SetDataSource("cell4Str", cell4Str);
  5788. designer.SetDataSource("cellStr", cellStr);
  5789. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5790. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5791. designer.SetDataSource("celllastStr", celllastStr);
  5792. Workbook wb = designer.Workbook;
  5793. var sheet = wb.Worksheets[0];
  5794. //绑定datatable数据集
  5795. designer.SetDataSource(dtdac1);
  5796. designer.SetDataSource(dtdac2);
  5797. designer.Process();
  5798. var rowStart = dtdac1.Rows.Count;
  5799. while (rowStart > 0)
  5800. {
  5801. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5802. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5803. startIndex++;
  5804. rowStart--;
  5805. }
  5806. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5807. startIndex += 1; //总计行
  5808. rowStart = dtdac2.Rows.Count;
  5809. while (rowStart > 0)
  5810. {
  5811. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5812. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5813. startIndex++;
  5814. rowStart--;
  5815. }
  5816. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5817. wb.CalculateFormula(true);
  5818. //模板文件名
  5819. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5820. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5821. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5822. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5823. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5824. }
  5825. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5826. {
  5827. //获取模板
  5828. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5829. //载入模板
  5830. Document doc = new Document(tempPath);
  5831. DocumentBuilder builder = new DocumentBuilder(doc);
  5832. Dictionary<string, string> dic = new Dictionary<string, string>();
  5833. dic.Add("GroupName", _DelegationInfo.TeamName);
  5834. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5835. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5836. string missionLeaderJob = "";//负责人job
  5837. //int groupNumber = 0; //团人数
  5838. if (DeleClientList.Count > 0)
  5839. {
  5840. missionLeader = DeleClientList[0]?.Name ?? "";
  5841. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5842. }
  5843. dic.Add("MissionLeader", missionLeader); //团负责人
  5844. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5845. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5846. #region MyRegion
  5847. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5848. //{
  5849. // List<string> list = new List<string>();
  5850. // try
  5851. // {
  5852. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5853. // foreach (var item in spilitArr)
  5854. // {
  5855. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5856. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5857. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5858. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5859. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5860. // list.Add(depName);
  5861. // list.Add(arrName);
  5862. // }
  5863. // list = list.Distinct().ToList();
  5864. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5865. // }
  5866. // catch (Exception)
  5867. // {
  5868. // dic.Add("ReturnCode", "行程录入不正确!");
  5869. // }
  5870. //}
  5871. //else
  5872. //{
  5873. // dic.Add("ReturnCode", "未录入行程!");
  5874. //}
  5875. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5876. dic.Add("ReturnCode", string.Join("、", countrys));
  5877. #endregion
  5878. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5879. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5880. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5881. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5882. //{
  5883. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5884. // dic.Add("Day", sp.Days.ToString());
  5885. //}
  5886. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5887. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5888. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5889. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5890. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5891. //培训人员名单
  5892. int cultivateRowIndex = 7;
  5893. foreach (var item in DeleClientList)
  5894. {
  5895. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5896. builder.Write(item.Name);
  5897. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5898. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5899. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5900. string birthDay = "";
  5901. if (item.Birthday != null)
  5902. {
  5903. DateTime dt = Convert.ToDateTime(item.Birthday);
  5904. birthDay = $"{dt.Year}.{dt.Month}";
  5905. }
  5906. builder.Write(birthDay);
  5907. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5908. builder.Write(item.Company);
  5909. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5910. builder.Write(item.Job);
  5911. cultivateRowIndex++;
  5912. }
  5913. //删除多余行
  5914. //cultivateRowIndex -= 2;
  5915. int delRows = 10 + 7 - cultivateRowIndex;
  5916. if (delRows > 0)
  5917. {
  5918. for (int i = 0; i < delRows; i++)
  5919. {
  5920. table1.Rows.RemoveAt(cultivateRowIndex);
  5921. //cultivateRowIndex++;
  5922. }
  5923. }
  5924. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5925. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5926. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5927. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5928. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5929. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5930. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5931. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5932. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5933. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5934. //其他费用
  5935. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5936. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5937. //其他费用合计
  5938. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5939. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5940. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5941. //公务舱合计
  5942. //国际旅费
  5943. //string outsideJJ = "";
  5944. //string allPriceJJ = "";
  5945. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5946. {
  5947. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5948. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5949. }
  5950. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5951. {
  5952. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5953. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5954. }
  5955. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5956. {
  5957. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5958. dic.Add("AirFeeTotal", airFeeTotalStr);
  5959. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5960. dic.Add("FeeTotal", feeTotalStr);
  5961. }
  5962. foreach (var key in dic.Keys)
  5963. {
  5964. builder.MoveToBookmark(key);
  5965. builder.Write(dic[key]);
  5966. }
  5967. //模板文件名
  5968. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5969. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5970. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5971. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5972. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5973. }
  5974. }
  5975. else if (dto.ExportType == 2) //表格
  5976. {
  5977. //利用键值对存放数据
  5978. Dictionary<string, string> dic = new Dictionary<string, string>();
  5979. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5980. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5981. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5982. dic.Add("Day", sp.Days.ToString());
  5983. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5984. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5985. {
  5986. //获取模板
  5987. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5988. //载入模板
  5989. Document doc = new Document(tempPath);
  5990. DocumentBuilder builder = new DocumentBuilder(doc);
  5991. dic.Add("TeamName", _DelegationInfo.TeamName);
  5992. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5993. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5994. string missionLeaderName = "",
  5995. missionLeaderJob = "";
  5996. if (DeleClientList.Count > 0)
  5997. {
  5998. missionLeaderName = DeleClientList[0].Name;
  5999. missionLeaderJob = DeleClientList[0].Job;
  6000. }
  6001. dic.Add("MissionLeaderName", missionLeaderName);
  6002. dic.Add("MissionLeaderJob", missionLeaderJob);
  6003. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6004. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6005. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6006. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6007. int rowCount = 10;//总人数行
  6008. int startRowIndex = 7; //起始行
  6009. for (int i = 0; i < DeleClientList.Count; i++)
  6010. {
  6011. builder.MoveToCell(0, startRowIndex, 0, 0);
  6012. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6013. builder.MoveToCell(0, startRowIndex, 1, 0);
  6014. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6015. builder.Write(sex);//性别
  6016. builder.MoveToCell(0, startRowIndex, 2, 0);
  6017. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6018. builder.MoveToCell(0, startRowIndex, 3, 0);
  6019. builder.Write(DeleClientList[i].Company);//工作单位
  6020. builder.MoveToCell(0, startRowIndex, 4, 0);
  6021. builder.Write(DeleClientList[i].Job);//职务及级别
  6022. builder.MoveToCell(0, startRowIndex, 5, 0);
  6023. builder.Write("");//人员属性
  6024. builder.MoveToCell(0, startRowIndex, 6, 0);
  6025. builder.Write("");//上次出国时间
  6026. startRowIndex++;
  6027. }
  6028. int nullRow = rowCount - DeleClientList.Count;//空行
  6029. for (int i = 0; i < nullRow; i++)
  6030. {
  6031. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6032. }
  6033. foreach (var key in dic.Keys)
  6034. {
  6035. builder.MoveToBookmark(key);
  6036. builder.Write(dic[key]);
  6037. }
  6038. //模板文件名
  6039. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6040. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6041. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6042. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6043. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6044. }
  6045. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6046. {
  6047. //获取模板
  6048. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6049. //载入模板
  6050. Document doc = new Document(tempPath);
  6051. DocumentBuilder builder = new DocumentBuilder(doc);
  6052. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6053. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6054. dic.Add("Names", Names);
  6055. int accommodationRows = 12;
  6056. //int foodandotherRows = 12;
  6057. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6058. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6059. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6060. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6061. int accommodationStartIndex = 6;
  6062. decimal dac1totalPrice = 0.00M;
  6063. foreach (var dac in dac1)
  6064. {
  6065. if (dac.SubTotal == 0)
  6066. {
  6067. continue;
  6068. }
  6069. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6070. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6071. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6072. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6073. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6074. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6075. builder.Write(currency);//币种
  6076. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6077. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6078. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6079. builder.Write("");//人数
  6080. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6081. builder.Write("");//天数
  6082. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6083. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6084. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6085. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6086. builder.Write(rate.ToString("#0.0000"));//汇率
  6087. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6088. decimal rbmPrice = rate * dac.SubTotal;
  6089. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6090. accommodationStartIndex++;
  6091. dac1totalPrice += rbmPrice;
  6092. }
  6093. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6094. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6095. builder.Write("小计");
  6096. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6097. builder.Write(dac1totalPrice.ToString("#0.00"));
  6098. accommodationStartIndex++;
  6099. int nullRow = accommodationRows - dac1.Count;
  6100. //删除空行
  6101. //if (nullRow > 0)
  6102. //{
  6103. // int rowIndex = accommodationStartIndex;
  6104. // for (int i = 0; i < nullRow; i++)
  6105. // {
  6106. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6107. // row.Remove();
  6108. // rowIndex++;
  6109. // }
  6110. //}
  6111. if (dac2.Count == dac3.Count)//国家 币种 金额
  6112. {
  6113. for (int i = 0; i < dac2.Count; i++)
  6114. {
  6115. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6116. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6117. }
  6118. }
  6119. int foodandotherStartIndex = 19;//
  6120. decimal dac2totalPrice = 0.00M;
  6121. foreach (var dac in dac2)
  6122. {
  6123. if (dac.SubTotal == 0)
  6124. {
  6125. continue;
  6126. }
  6127. //foodandotherStartIndex = 12;
  6128. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6129. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6130. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6131. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6132. builder.Write(currency);//币种
  6133. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6134. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6135. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6136. builder.Write("");//人数
  6137. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6138. builder.Write("");//天数
  6139. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6140. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6141. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6142. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6143. builder.Write(rate.ToString("#0.0000"));//汇率
  6144. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6145. decimal rbmPrice = rate * dac.SubTotal;
  6146. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6147. foodandotherStartIndex++;
  6148. dac2totalPrice += rbmPrice;
  6149. }
  6150. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6151. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6152. //删除空行
  6153. //if (dac2.Count < foodandotherRows)
  6154. //{
  6155. // while (table2.Rows.Count > dac2.Count)
  6156. // {
  6157. // table2.Rows.RemoveAt(dac2.Count);
  6158. // }
  6159. //}
  6160. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6161. string otherFeeStr = "";
  6162. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6163. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6164. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6165. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6166. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6167. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6168. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6169. foreach (var otherInfo in dac5)
  6170. {
  6171. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6172. }
  6173. #endregion
  6174. if (otherFeeStr.Length > 0)
  6175. {
  6176. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6177. otherFeeStr = $"({otherFeeStr})";
  6178. dic.Add("OtherFeeStr", otherFeeStr);
  6179. }
  6180. foreach (var key in dic.Keys)
  6181. {
  6182. builder.MoveToBookmark(key);
  6183. builder.Write(dic[key]);
  6184. }
  6185. //模板文件名
  6186. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6187. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6188. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6189. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6190. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6191. }
  6192. }
  6193. else if (dto.ExportType == 3)
  6194. {
  6195. if (dto.SubTypeId == 1) //团组成员名单
  6196. {
  6197. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6198. //获取模板
  6199. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6200. //载入模板
  6201. Document doc = new Document(tempPath);
  6202. DocumentBuilder builder = new DocumentBuilder(doc);
  6203. //获取word里所有表格
  6204. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6205. //获取所填表格的序数
  6206. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6207. var rowStart = tableOne.Rows[0]; //获取第1行
  6208. //循环赋值
  6209. for (int i = 0; i < DeleClientList.Count; i++)
  6210. {
  6211. builder.MoveToCell(0, i + 1, 0, 0);
  6212. builder.Write(DeleClientList[i].Name);
  6213. builder.MoveToCell(0, i + 1, 1, 0);
  6214. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6215. builder.Write(sex);
  6216. builder.MoveToCell(0, i + 1, 2, 0);
  6217. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6218. builder.MoveToCell(0, i + 1, 3, 0);
  6219. builder.Write(DeleClientList[i].Company);
  6220. builder.MoveToCell(0, i + 1, 4, 0);
  6221. builder.Write(DeleClientList[i].Job);
  6222. }
  6223. //删除多余行
  6224. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6225. {
  6226. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6227. }
  6228. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6229. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6230. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6231. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6232. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6233. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6234. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6235. }
  6236. }
  6237. return Ok(JsonView(400, "操作失败!", ""));
  6238. }
  6239. catch (Exception ex)
  6240. {
  6241. return Ok(JsonView(400, ex.Message, ""));
  6242. }
  6243. }
  6244. /// <summary>
  6245. /// 获取三公费用标准city
  6246. /// </summary>
  6247. /// <param name="placeData"></param>
  6248. /// <param name="nationalTravelFeeId"></param>
  6249. /// <returns></returns>
  6250. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6251. {
  6252. string _city = string.Empty;
  6253. if (placeData.Count < 1) return _city;
  6254. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6255. if (data == null) return _city;
  6256. string country = data.Country;
  6257. string city = data.City;
  6258. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6259. else _city = city;
  6260. return _city;
  6261. }
  6262. /// <summary>
  6263. /// 团组模块 - 出入境费用 - 明细表导出
  6264. /// </summary>
  6265. /// <returns></returns>
  6266. [HttpPost]
  6267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6268. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6269. {
  6270. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6271. if (data.Code != 0)
  6272. {
  6273. return Ok(JsonView(false, data.Msg));
  6274. }
  6275. return Ok(JsonView(true, data.Msg, data.Data));
  6276. }
  6277. /// <summary>
  6278. /// 团组模块 - 出入境费用 - 一键清空
  6279. /// </summary>
  6280. /// <returns></returns>
  6281. [HttpPost]
  6282. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6284. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6285. {
  6286. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6287. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6288. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6289. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6290. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6291. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6292. .SetColumns(x => new Grp_DayOtherPrice
  6293. {
  6294. IsDel = 1,
  6295. DeleteUserId = dto.UserId,
  6296. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6297. })
  6298. .ExecuteCommandAsync();
  6299. if (_view.Code == 0)
  6300. {
  6301. return Ok(JsonView(true, "操作成功"));
  6302. }
  6303. return Ok(JsonView(false, "操作失败"));
  6304. }
  6305. /// <summary>
  6306. /// 团组模块 - 出入境费用 - 子项删除
  6307. /// </summary>
  6308. /// <returns></returns>
  6309. [HttpPost]
  6310. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6312. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6313. {
  6314. try
  6315. {
  6316. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6317. if (data.Code != 0)
  6318. {
  6319. return Ok(JsonView(false, data.Msg));
  6320. }
  6321. return Ok(JsonView(true, "操作成功!", data.Data));
  6322. }
  6323. catch (Exception ex)
  6324. {
  6325. return Ok(JsonView(false, ex.Message));
  6326. }
  6327. }
  6328. /// <summary>
  6329. /// 删除三公其他费用
  6330. /// </summary>
  6331. /// <param name="dto"></param>
  6332. /// <returns></returns>
  6333. [HttpPost]
  6334. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6335. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6336. {
  6337. var jw = JsonView(false, "删除失败!");
  6338. var data = new Grp_DayOtherPrice()
  6339. {
  6340. Id = dto.Id,
  6341. IsDel = 1,
  6342. DeleteUserId = dto.DeleteUserId,
  6343. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6344. };
  6345. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6346. if (del > 0)
  6347. {
  6348. jw.Code = 200;
  6349. jw.Msg = "删除成功!";
  6350. }
  6351. return Ok(jw);
  6352. }
  6353. /// <summary>
  6354. /// 团组模块 - 出入境国家费用标准 List
  6355. /// </summary>
  6356. /// <returns></returns>
  6357. [HttpPost]
  6358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6359. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6360. {
  6361. try
  6362. {
  6363. Stopwatch sw = new Stopwatch();
  6364. sw.Start();
  6365. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6366. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6367. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6368. Where gntf.Isdel = 0");
  6369. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6370. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6371. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6372. //foreach (var item in nationalTravel)
  6373. //{
  6374. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6375. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6376. // if (otherData != null)
  6377. // {
  6378. // cityData.Remove(otherData);
  6379. // cityData.Add(otherData);
  6380. // }
  6381. // nationalTravelFeeData1.Add(new
  6382. // {
  6383. // Country = item.Country,
  6384. // CityData = cityData
  6385. // });
  6386. //}
  6387. sw.Stop();
  6388. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6389. }
  6390. catch (Exception ex)
  6391. {
  6392. return Ok(JsonView(false, ex.Message));
  6393. throw;
  6394. }
  6395. }
  6396. /// <summary>
  6397. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6398. /// </summary>
  6399. /// <returns></returns>
  6400. [HttpPost]
  6401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6402. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6403. {
  6404. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6405. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6406. List<string> countryData = new List<string>();
  6407. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6408. countryData = countryData.Distinct().ToList();
  6409. List<dynamic> dataSource = new List<dynamic>();
  6410. foreach (var item in countryData)
  6411. {
  6412. var cityData1 = new List<string>();
  6413. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6414. var countryData2 = new
  6415. {
  6416. CountryName = item,
  6417. CityData = cityData1
  6418. };
  6419. dataSource.Add(countryData2);
  6420. }
  6421. return Ok(JsonView(true, "查询成功!", dataSource));
  6422. }
  6423. /// <summary>
  6424. /// 团组模块 - 出入境国家费用标准 Page List
  6425. /// </summary>
  6426. /// <returns></returns>
  6427. [HttpPost]
  6428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6429. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6430. {
  6431. int portId = dto.PortType;
  6432. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6433. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6434. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6435. string whereSql = string.Empty;
  6436. if (!string.IsNullOrEmpty(dto.Country))
  6437. {
  6438. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6439. }
  6440. if (!string.IsNullOrEmpty(dto.City))
  6441. {
  6442. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6443. }
  6444. string pageSql = string.Format(@"Select * From (
  6445. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6446. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6447. From Grp_NationalTravelFee gntf
  6448. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6449. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6450. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6451. RefAsync<int> total = 0;
  6452. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6453. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6454. }
  6455. /// <summary>
  6456. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6457. /// </summary>
  6458. /// <returns></returns>
  6459. [HttpPost]
  6460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6461. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6462. {
  6463. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6464. int portId = dto.PortType;
  6465. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6466. string whereSql = string.Empty;
  6467. if (!string.IsNullOrEmpty(dto.Country))
  6468. {
  6469. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6470. }
  6471. if (!string.IsNullOrEmpty(dto.City))
  6472. {
  6473. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6474. }
  6475. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6476. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6477. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6478. From Grp_NationalTravelFee gntf
  6479. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6480. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6481. Where gntf.Isdel = 0 {0} ", whereSql);
  6482. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6483. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6484. }
  6485. /// <summary>
  6486. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6487. /// </summary>
  6488. /// <returns></returns>
  6489. [HttpPost]
  6490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6491. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6492. {
  6493. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6494. if (data.Code != 0)
  6495. {
  6496. return Ok(JsonView(false, data.Msg));
  6497. }
  6498. return Ok(JsonView(true, "操作成功!", data.Data));
  6499. }
  6500. /// <summary>
  6501. /// 团组模块 - 出入境国家费用标准 - Del
  6502. /// </summary>
  6503. /// <returns></returns>
  6504. [HttpPost]
  6505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6506. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6507. {
  6508. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6509. {
  6510. Id = dto.Id,
  6511. DeleteUserId = dto.DeleteUserId,
  6512. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6513. IsDel = 1
  6514. };
  6515. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6516. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6517. .WhereColumns(it => new { it.Id })
  6518. .ExecuteCommandAsync();
  6519. if (delStatus <= 0)
  6520. {
  6521. return Ok(JsonView(false, "删除失败!"));
  6522. }
  6523. return Ok(JsonView(true, "操作成功!"));
  6524. }
  6525. /// <summary>
  6526. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6527. /// 注:Get 请求Headers 加 Token
  6528. /// </summary>
  6529. /// <param name="groupId"></param>
  6530. /// <returns></returns>
  6531. [HttpGet("{groupId}")]
  6532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6533. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6534. {
  6535. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6536. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6537. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6538. data.ForEach(x =>
  6539. {
  6540. x.CreateUserId = _currUserInfo.UserId;
  6541. });
  6542. if (data.Any())
  6543. {
  6544. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6545. if (add > 0)
  6546. {
  6547. return Ok(JsonView(true, "操作成功!"));
  6548. }
  6549. }
  6550. return Ok(JsonView(false, "未操作!"));
  6551. }
  6552. #endregion
  6553. #region 团组经理模块 出入境费用-草稿
  6554. /// <summary>
  6555. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6556. /// </summary>
  6557. /// <returns></returns>
  6558. [HttpPost]
  6559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6560. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6561. {
  6562. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6563. .Where(x => x.IsDel == 0)
  6564. .OrderByDescending(x => x.CreateTime)
  6565. .Select(x => new { x.Id, x.DraftName })
  6566. .ToListAsync();
  6567. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6568. //SetDataInfoView
  6569. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6570. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6571. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6572. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6573. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6574. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6575. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6576. //默认币种显示
  6577. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6578. {
  6579. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6580. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6581. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6582. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6583. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6584. };
  6585. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  6586. if (_currencyRate.Count > 0)
  6587. {
  6588. foreach (var item in _currencyInfos)
  6589. {
  6590. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6591. if (rateInfo != null)
  6592. {
  6593. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6594. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  6595. else rate1 *= 1.035M;
  6596. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6597. }
  6598. }
  6599. }
  6600. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6601. return Ok(JsonView(true, "查询成功!", new
  6602. {
  6603. DraftNameDatas = draftNameDatas,
  6604. CurrencyData = _CurrencyData,
  6605. WordTypeData = _WordTypeData,
  6606. ExcelTypeData = _ExcelTypeData,
  6607. CurrencyInit = _currencyInfos,
  6608. ViewPermissionData = viewPermissionData
  6609. }));
  6610. }
  6611. /// <summary>
  6612. /// 团组模块 - 出入境费用-草稿
  6613. /// 实时汇率 tips
  6614. /// 签证费用 tips
  6615. /// 机票费用 tips
  6616. /// </summary>
  6617. /// <returns></returns>
  6618. [HttpPost]
  6619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6620. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6621. {
  6622. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6623. //默认币种显示
  6624. var _currencyInfos = _currencyInit;
  6625. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  6626. List<dynamic> reteInfos = new List<dynamic>();
  6627. if (_currencyRate.Count > 0)
  6628. {
  6629. foreach (var item in _currencyInfos)
  6630. {
  6631. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6632. if (rateInfo != null)
  6633. {
  6634. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6635. decimal rate1 = item.Rate;
  6636. rate1 *= 1.03M;
  6637. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6638. reteInfos.Add(new
  6639. {
  6640. currCode = item.CurrencyCode,
  6641. currName = item.CurrencyName,
  6642. rate = rate2,
  6643. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6644. });
  6645. }
  6646. }
  6647. }
  6648. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6649. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6650. return Ok(JsonView(true, "查询成功!", new
  6651. {
  6652. //GroupNameData = groupNameData.Data,
  6653. //visaData = visaData.Data,
  6654. //airData = airData.Data,
  6655. reteInfos = reteInfos
  6656. }));
  6657. }
  6658. /// <summary>
  6659. /// 团组模块 - 出入境费用-草稿 - Info
  6660. /// </summary>
  6661. /// <returns></returns>
  6662. [HttpPost]
  6663. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6665. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6666. {
  6667. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6668. }
  6669. /// <summary>
  6670. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6671. /// </summary>
  6672. /// <returns></returns>
  6673. [HttpPost]
  6674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6675. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6676. {
  6677. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6678. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6679. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6680. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6681. foreach (var userId in dto.UserIds)
  6682. {
  6683. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6684. }
  6685. if (permissions.Any())
  6686. {
  6687. _sqlSugar.BeginTran();
  6688. try
  6689. {
  6690. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6691. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6692. if (result < 1)
  6693. {
  6694. _sqlSugar.RollbackTran();
  6695. return Ok(JsonView(false));
  6696. }
  6697. }
  6698. catch (Exception ex)
  6699. {
  6700. _sqlSugar.RollbackTran();
  6701. return Ok(JsonView(false, ex.Message));
  6702. }
  6703. _sqlSugar.CommitTran();
  6704. return Ok(JsonView(true));
  6705. }
  6706. return Ok(JsonView(false));
  6707. }
  6708. /// <summary>
  6709. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6710. /// </summary>
  6711. /// <returns></returns>
  6712. [HttpPost]
  6713. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6715. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6716. {
  6717. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6718. if (data.Code != 0)
  6719. {
  6720. return Ok(JsonView(false, data.Msg));
  6721. }
  6722. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6723. //汇率信息记录
  6724. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6725. return Ok(JsonView(true, data.Msg, data.Data));
  6726. }
  6727. /// <summary>
  6728. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6729. /// </summary>
  6730. /// <param name="dto"></param>
  6731. /// <returns></returns>
  6732. [HttpPost]
  6733. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6735. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6736. {
  6737. try
  6738. {
  6739. var id = dto.Id;
  6740. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6741. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6742. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6743. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6744. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6745. 3 团组成员名单 1 团组成员名单", ""));
  6746. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6747. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6748. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6749. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6750. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6751. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6752. //数据源
  6753. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6754. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6755. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6756. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6757. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6758. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6759. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6760. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6761. .Select((x, a, b) => new
  6762. {
  6763. x.Index,
  6764. itemName = a.Name,
  6765. CurrencyStr = b.Name,
  6766. x.Cost,
  6767. x.SubTotal,
  6768. x.Remark
  6769. })
  6770. .OrderBy((x) => x.Index)
  6771. .ToList(); //其他款项费用
  6772. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6773. var peiceItemCurrencys = new List<string>();
  6774. if (_DayAndCosts.Any())
  6775. {
  6776. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6777. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6778. }
  6779. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6780. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6781. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6782. {
  6783. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6784. }
  6785. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6786. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6787. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6788. if (dto.ExportType == 1) //明细表
  6789. {
  6790. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6791. {
  6792. //获取模板
  6793. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6794. //载入模板
  6795. Document doc = new Document(tempPath);
  6796. DocumentBuilder builder = new DocumentBuilder(doc);
  6797. //利用键值对存放数据
  6798. Dictionary<string, string> dic = new Dictionary<string, string>();
  6799. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6800. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6801. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6802. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6803. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6804. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6805. //境内费用(其他费用)
  6806. if (_EnterExitCosts.ChoiceOne == 1)
  6807. {
  6808. string row1_1 = "";
  6809. if (_EnterExitCosts.Visa > 0)
  6810. {
  6811. //insidePayTotal += _EnterExitCosts.Visa;
  6812. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6813. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6814. {
  6815. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6816. }
  6817. }
  6818. string row1_2 = "";
  6819. if (_EnterExitCosts.YiMiao > 0)
  6820. {
  6821. //insidePayTotal += _EnterExitCosts.YiMiao;
  6822. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6823. }
  6824. if (_EnterExitCosts.HeSuan > 0)
  6825. {
  6826. //insidePayTotal += _EnterExitCosts.HeSuan;
  6827. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6828. }
  6829. if (_EnterExitCosts.Service > 0)
  6830. {
  6831. //insidePayTotal += _EnterExitCosts.Service;
  6832. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6833. }
  6834. string row1_3 = "";
  6835. if (_EnterExitCosts.Safe > 0)
  6836. {
  6837. //insidePayTotal += _EnterExitCosts.Safe;
  6838. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6839. }
  6840. if (_EnterExitCosts.Ticket > 0)
  6841. {
  6842. //insidePayTotal += _EnterExitCosts.Ticket;
  6843. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6844. }
  6845. string row1 = "";
  6846. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6847. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6848. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6849. row1 += $"备注:{_EnterExitCosts.Remark}";
  6850. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6851. dic.Add("Row1Str", row1);
  6852. }
  6853. string airTotalStr = string.Empty,
  6854. airPriceStr = string.Empty;
  6855. //经济舱
  6856. if (_EnterExitCosts.SumJJC == 1)
  6857. {
  6858. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6859. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6860. }
  6861. //公务舱
  6862. if (_EnterExitCosts.SumGWC == 1)
  6863. {
  6864. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6865. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6866. }
  6867. //头等舱
  6868. if (_EnterExitCosts.SumTDC == 1)
  6869. {
  6870. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6871. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6872. }
  6873. //汇率描述
  6874. string rateStr = "";
  6875. if (peiceItemCurrencyInfos.Any())
  6876. {
  6877. rateStr = "\r\n汇率描述:";
  6878. foreach (var item in peiceItemCurrencyInfos)
  6879. {
  6880. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6881. }
  6882. }
  6883. string twoItemRemark = "备注:";
  6884. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6885. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6886. dic.Add("AirTotalStr", airTotalStr);
  6887. dic.Add("AirPriceStr", airPriceStr);
  6888. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6889. dic.Add("TwoItemRemark", twoItemRemark);
  6890. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6891. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6892. int table1Row = 0,
  6893. table2Row = 0,
  6894. table3Row = 0,
  6895. table4Row = 0,
  6896. table5Row = 0;
  6897. //住宿费
  6898. if (_EnterExitCosts.ChoiceThree == 1)
  6899. {
  6900. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6901. table1Row = dac1.Count;
  6902. #region 填充word表格内容
  6903. for (int i = 0; i < dac1.Count; i++)
  6904. {
  6905. var dac = dac1[i];
  6906. if (dac == null) continue;
  6907. builder.MoveToCell(0, i, 0, 0);
  6908. builder.Write("第" + dac.Days.ToString() + "晚:");
  6909. builder.MoveToCell(0, i, 1, 0);
  6910. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6911. //builder.Write(dac.Place == null ? "" : dac.Place);
  6912. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6913. builder.MoveToCell(0, i, 2, 0);
  6914. builder.Write("费用标准:");
  6915. string curr = "";
  6916. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6917. if (currData != null)
  6918. {
  6919. curr = currData.Name;
  6920. }
  6921. builder.MoveToCell(0, i, 3, 0);
  6922. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6923. builder.MoveToCell(0, i, 4, 0);
  6924. builder.Write("费用小计:");
  6925. builder.MoveToCell(0, i, 5, 0);
  6926. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6927. }
  6928. #endregion
  6929. }
  6930. else dic.Add("SubZS", "0.00");
  6931. //删除多余行
  6932. while (table1.Rows.Count > table1Row)
  6933. {
  6934. table1.Rows.RemoveAt(table1Row);
  6935. }
  6936. //伙食费
  6937. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6938. if (_EnterExitCosts.ChoiceFour == 1)
  6939. {
  6940. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6941. table2Row = dac2.Count;
  6942. #region 填充word表格内容
  6943. for (int i = 0; i < dac2.Count; i++)
  6944. {
  6945. var dac = dac2[i];
  6946. if (dac == null) continue;
  6947. builder.MoveToCell(1, i, 0, 0);
  6948. builder.Write("第" + dac.Days.ToString() + "天:");
  6949. builder.MoveToCell(1, i, 1, 0);
  6950. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6951. builder.MoveToCell(1, i, 2, 0);
  6952. builder.Write("费用标准:");
  6953. string curr = "";
  6954. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6955. if (currData != null)
  6956. {
  6957. curr = currData.Name;
  6958. }
  6959. builder.MoveToCell(1, i, 3, 0);
  6960. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6961. builder.MoveToCell(1, i, 4, 0);
  6962. builder.Write("费用小计:");
  6963. builder.MoveToCell(1, i, 5, 0);
  6964. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6965. }
  6966. #endregion
  6967. }
  6968. else dic.Add("SubHS", "0.00");
  6969. //删除多余行
  6970. while (table2.Rows.Count > table2Row)
  6971. {
  6972. table2.Rows.RemoveAt(table2Row);
  6973. }
  6974. //公杂费
  6975. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6976. if (_EnterExitCosts.ChoiceFive == 1)
  6977. {
  6978. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6979. table3Row = dac3.Count;
  6980. #region 填充word表格内容
  6981. for (int i = 0; i < dac3.Count; i++)
  6982. {
  6983. var dac = dac3[i];
  6984. if (dac == null) continue;
  6985. builder.MoveToCell(2, i, 0, 0);
  6986. builder.Write("第" + dac.Days.ToString() + "天:");
  6987. builder.MoveToCell(2, i, 1, 0);
  6988. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6989. builder.MoveToCell(2, i, 2, 0);
  6990. builder.Write("费用标准:");
  6991. string curr = "";
  6992. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6993. if (currData != null)
  6994. {
  6995. curr = currData.Name;
  6996. }
  6997. builder.MoveToCell(2, i, 3, 0);
  6998. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6999. builder.MoveToCell(2, i, 4, 0);
  7000. builder.Write("费用小计:");
  7001. builder.MoveToCell(2, i, 5, 0);
  7002. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7003. }
  7004. //删除多余行
  7005. while (table3.Rows.Count > table3Row)
  7006. {
  7007. table3.Rows.RemoveAt(table3Row);
  7008. }
  7009. #endregion
  7010. }
  7011. else dic.Add("SubGZF", "0.00");
  7012. //删除多余行
  7013. while (table3.Rows.Count > table3Row)
  7014. {
  7015. table3.Rows.RemoveAt(table3Row);
  7016. }
  7017. //培训费
  7018. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7019. if (_EnterExitCosts.ChoiceSix == 1)
  7020. {
  7021. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7022. dic.Add("SubPX", pxStr);
  7023. table4Row = dac4.Count;
  7024. #region 填充word表格内容
  7025. for (int i = 0; i < dac4.Count; i++)
  7026. {
  7027. var dac = dac4[i];
  7028. if (dac == null) continue;
  7029. builder.MoveToCell(3, i, 0, 0);
  7030. builder.Write("第" + dac.Days.ToString() + "天:");
  7031. builder.MoveToCell(3, i, 1, 0);
  7032. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7033. builder.MoveToCell(3, i, 2, 0);
  7034. builder.Write("费用标准:");
  7035. string curr = "";
  7036. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7037. if (currData != null)
  7038. {
  7039. curr = currData.Name;
  7040. }
  7041. builder.MoveToCell(3, i, 3, 0);
  7042. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7043. builder.MoveToCell(3, i, 4, 0);
  7044. builder.Write("费用小计:");
  7045. builder.MoveToCell(3, i, 5, 0);
  7046. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7047. }
  7048. #endregion
  7049. }
  7050. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7051. //删除多余行
  7052. while (table4.Rows.Count > table4Row)
  7053. {
  7054. table4.Rows.RemoveAt(table4Row);
  7055. }
  7056. //其他费用
  7057. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7058. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7059. {
  7060. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7061. dic.Add("titleQi", qtStr);
  7062. table5Row = dac5.Count;
  7063. #region 填充word表格内容
  7064. for (int i = 0; i < dac5.Count; i++)
  7065. {
  7066. var dac = dac5[i];
  7067. if (dac == null) continue;
  7068. builder.MoveToCell(4, i, 0, 0);
  7069. builder.Write("第" + dac.Index.ToString() + "项:");
  7070. builder.MoveToCell(4, i, 1, 0);
  7071. builder.Write(dac.itemName);
  7072. builder.MoveToCell(4, i, 2, 0);
  7073. builder.Write("费用标准:");
  7074. builder.MoveToCell(4, i, 3, 0);
  7075. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7076. builder.MoveToCell(4, i, 4, 0);
  7077. builder.Write("费用小计:");
  7078. builder.MoveToCell(4, i, 5, 0);
  7079. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7080. builder.MoveToCell(4, i, 6, 0);
  7081. builder.Write("备注:");
  7082. builder.MoveToCell(4, i, 7, 0);
  7083. builder.Write(dac.Remark);
  7084. }
  7085. #endregion
  7086. }
  7087. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7088. //删除多余行
  7089. while (table5.Rows.Count > table5Row)
  7090. {
  7091. table5.Rows.RemoveAt(table5Row);
  7092. }
  7093. //加上其他费用
  7094. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7095. decimal subJJC = 0.00M,
  7096. subGWC = 0.00M,
  7097. subTDC = 0.00M;
  7098. //经济舱
  7099. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7100. //公务舱
  7101. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7102. //头等舱
  7103. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7104. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7105. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7106. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7107. #region 填充word模板书签内容
  7108. foreach (var key in dic.Keys)
  7109. {
  7110. Bookmark bookmark = doc.Range.Bookmarks[key];
  7111. if (bookmark != null)
  7112. {
  7113. builder.MoveToBookmark(key);
  7114. builder.Write(dic[key]);
  7115. }
  7116. }
  7117. #endregion
  7118. //文件名
  7119. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7120. strFileName = CommonFun.ValidFileName(strFileName);
  7121. AsposeHelper.removewatermark_v2180();
  7122. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7123. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7124. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7125. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7126. }
  7127. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7128. {
  7129. //获取模板
  7130. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7131. //载入模板
  7132. Document doc = new Document(tempPath);
  7133. DocumentBuilder builder = new DocumentBuilder(doc);
  7134. Dictionary<string, string> dic = new Dictionary<string, string>();
  7135. string returnCodeLabel = string.Empty;
  7136. if (nationalTravelFeeData.Any())
  7137. {
  7138. List<string> list = new List<string>();
  7139. foreach (var item in nationalTravelFeeData)
  7140. {
  7141. list.Add($"{item.Country}({item.City})");
  7142. }
  7143. list = list.Distinct().ToList();
  7144. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7145. }
  7146. var countryLabel = string.Empty;
  7147. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7148. if (countryData.Any())
  7149. {
  7150. countryLabel = string.Join("、", countryData);
  7151. }
  7152. dic.Add("ReturnCodeAir", returnCodeLabel);
  7153. dic.Add("VisitStartDate", "-");
  7154. dic.Add("VisitEndDate", "-");
  7155. dic.Add("Day", "-");
  7156. dic.Add("VisitCountry", countryLabel);
  7157. dic.Add("ClientUnit", "-");
  7158. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7159. //dic.Add("Names", Names);
  7160. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7161. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7162. decimal dac1totalPrice = 0.00M;
  7163. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7164. foreach (var dac in dac1)
  7165. {
  7166. if (dac.SubTotal == 0.00M)
  7167. {
  7168. continue;
  7169. }
  7170. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7171. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7172. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7173. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7174. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7175. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7176. builder.Write(currency);//币种
  7177. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7178. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7179. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7180. builder.Write("");//人数
  7181. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7182. builder.Write("");//天数
  7183. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7184. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7185. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7186. decimal rate = 0.00M;
  7187. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7188. builder.Write(rate.ToString("#0.0000"));//汇率
  7189. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7190. decimal rbmPrice = dac.SubTotal;
  7191. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7192. accommodationStartIndex++;
  7193. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7194. }
  7195. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7196. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7197. {
  7198. table1.Rows.RemoveAt(i - 1);
  7199. foodandotherStartIndex--;
  7200. }
  7201. if (dac2.Count == dac3.Count)//国家 币种 金额
  7202. {
  7203. for (int i = 0; i < dac2.Count; i++)
  7204. {
  7205. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7206. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7207. }
  7208. }
  7209. decimal dac2totalPrice = 0.00M;
  7210. foreach (var dac in dac2)
  7211. {
  7212. if (dac.SubTotal == 0)
  7213. {
  7214. continue;
  7215. }
  7216. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7217. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7218. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7219. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7220. builder.Write(currency);//币种
  7221. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7222. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7223. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7224. builder.Write("");//人数
  7225. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7226. builder.Write("");//天数
  7227. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7228. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7229. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7230. decimal rate = 0.00M;
  7231. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7232. builder.Write(rate.ToString("#0.0000"));//汇率
  7233. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7234. decimal rbmPrice = dac.SubTotal;
  7235. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7236. foodandotherStartIndex++;
  7237. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7238. }
  7239. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7240. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7241. {
  7242. table1.Rows.RemoveAt(i - 1);
  7243. }
  7244. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7245. string otherFeeStr = "";
  7246. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7247. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7248. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7249. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7250. foreach (var otherInfo in dac5)
  7251. {
  7252. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7253. }
  7254. #endregion
  7255. if (otherFeeStr.Length > 0)
  7256. {
  7257. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7258. otherFeeStr = $"({otherFeeStr})";
  7259. dic.Add("OtherFeeStr", otherFeeStr);
  7260. }
  7261. //总计
  7262. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7263. //国际旅费
  7264. string outsideAir = string.Empty;
  7265. string allPriceAir = string.Empty;
  7266. if (_EnterExitCosts.SumJJC == 1)
  7267. {
  7268. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7269. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7270. }
  7271. if (_EnterExitCosts.SumGWC == 1)
  7272. {
  7273. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7274. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7275. }
  7276. if (_EnterExitCosts.SumTDC == 1)
  7277. {
  7278. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7279. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7280. }
  7281. dic.Add("InTravelPrice", $"({outsideAir})");
  7282. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7283. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7284. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7285. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7286. foreach (var key in dic.Keys)
  7287. {
  7288. builder.MoveToBookmark(key);
  7289. builder.Write(dic[key]);
  7290. }
  7291. //模板文件名
  7292. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7293. strFileName = CommonFun.ValidFileName(strFileName);
  7294. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7295. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7296. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7297. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7298. }
  7299. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7300. {
  7301. //获取模板
  7302. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7303. //载入模板
  7304. WorkbookDesigner designer = new WorkbookDesigner();
  7305. designer.Workbook = new Workbook(tempPath);
  7306. Dictionary<string, string> dic = new Dictionary<string, string>();
  7307. string returnCodeLabel = string.Empty;
  7308. if (nationalTravelFeeData.Any())
  7309. {
  7310. List<string> list = new List<string>();
  7311. foreach (var item in nationalTravelFeeData)
  7312. {
  7313. list.Add($"{item.Country}({item.City})");
  7314. }
  7315. list = list.Distinct().ToList();
  7316. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7317. }
  7318. var countryLabel = string.Empty;
  7319. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7320. if (countryData.Any())
  7321. {
  7322. countryLabel = string.Join("、", countryData);
  7323. }
  7324. dic.Add("ReturnCodeAir", returnCodeLabel);
  7325. dic.Add("VisitStartDate", "-");
  7326. dic.Add("VisitEndDate", "-");
  7327. dic.Add("Day", "0");
  7328. dic.Add("VisitCountry", countryLabel);
  7329. dic.Add("ClientUnit", "-");
  7330. designer.SetDataSource("ClientUnit", "-");
  7331. designer.SetDataSource("VisitCountry", countryLabel);
  7332. designer.SetDataSource("Group", "-");
  7333. designer.SetDataSource("ClientUnitTitle", "-");
  7334. designer.SetDataSource("Name", "-");
  7335. designer.SetDataSource("VisitStartDate", "-");
  7336. designer.SetDataSource("Day", "0");
  7337. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7338. designer.SetDataSource("ReturnCodeAir", "-");
  7339. int startIndex = 10;
  7340. const int startIndexcopy = 10;
  7341. if (dac2.Count == dac3.Count)//国家 币种 金额
  7342. {
  7343. for (int i = 0; i < dac2.Count; i++)
  7344. {
  7345. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7346. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7347. }
  7348. }
  7349. DataTable dtdac1 = new DataTable();
  7350. List<string> place = new List<string>();
  7351. dtdac1.Columns.AddRange(new DataColumn[] {
  7352. new DataColumn(){ ColumnName = "city"},
  7353. new DataColumn(){ ColumnName = "curr"},
  7354. new DataColumn(){ ColumnName = "criterion"},
  7355. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7356. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7357. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7358. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7359. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7360. });
  7361. DataTable dtdac2 = new DataTable();
  7362. dtdac2.Columns.AddRange(new DataColumn[] {
  7363. new DataColumn(){ ColumnName = "city"},
  7364. new DataColumn(){ ColumnName = "curr"},
  7365. new DataColumn(){ ColumnName = "criterion"},
  7366. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7367. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7368. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7369. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7370. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7371. });
  7372. dtdac1.TableName = "tb1";
  7373. dtdac2.TableName = "tb2";
  7374. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7375. foreach (var item in dac1)
  7376. {
  7377. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7378. if (place.Contains(item.Place))
  7379. {
  7380. continue;
  7381. }
  7382. DataRow row = dtdac1.NewRow();
  7383. row["city"] = item.Place;
  7384. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7385. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7386. row["curr"] = currency;
  7387. row["rate"] = rate.ToString("#0.0000");
  7388. row["criterion"] = item.Cost.ToString("#0.00");
  7389. row["number"] = 1;
  7390. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7391. //row["costRMB"] = rbmPrice;
  7392. dtdac1.Rows.Add(row);
  7393. place.Add(item.Place);
  7394. }
  7395. place = new List<string>();
  7396. foreach (var item in dac2)
  7397. {
  7398. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7399. if (place.Contains(item.Place))
  7400. {
  7401. continue;
  7402. }
  7403. DataRow row = dtdac2.NewRow();
  7404. row["city"] = item.Place;
  7405. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7406. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7407. row["curr"] = currency;
  7408. row["rate"] = rate.ToString("#0.0000");
  7409. row["criterion"] = item.Cost.ToString("#0.00");
  7410. row["number"] = 1;
  7411. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7412. //row["cost"] = item.SubTotal;
  7413. //row["costRMB"] = rbmPrice;
  7414. dtdac2.Rows.Add(row);
  7415. place.Add(item.Place);
  7416. //dac2totalPrice += rbmPrice;
  7417. }
  7418. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7419. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7420. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7421. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7422. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7423. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7424. string cell4Str1 = string.Empty;
  7425. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7426. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7427. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7428. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7429. string cellStr = $" 5.其他费用(";
  7430. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7431. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7432. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7433. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7434. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7435. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7436. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7437. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7438. foreach (var otherInfo in dac5)
  7439. {
  7440. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7441. }
  7442. #endregion
  7443. if (cellStr.Length > 8)
  7444. {
  7445. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7446. }
  7447. cellStr += ")";
  7448. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7449. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7450. decimal pxFee = dac4.Sum(it => it.Cost);
  7451. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7452. string celllastStr1 = "";
  7453. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7454. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7455. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7456. celllastStr1 += $",国际旅费 元";
  7457. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7458. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7459. designer.SetDataSource("cell4Str", cell4Str);
  7460. designer.SetDataSource("cellStr", cellStr);
  7461. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7462. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7463. designer.SetDataSource("celllastStr", celllastStr);
  7464. Workbook wb = designer.Workbook;
  7465. var sheet = wb.Worksheets[0];
  7466. //绑定datatable数据集
  7467. designer.SetDataSource(dtdac1);
  7468. designer.SetDataSource(dtdac2);
  7469. designer.Process();
  7470. var rowStart = dtdac1.Rows.Count;
  7471. while (rowStart > 0)
  7472. {
  7473. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7474. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7475. startIndex++;
  7476. rowStart--;
  7477. }
  7478. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7479. startIndex += 1; //总计行
  7480. rowStart = dtdac2.Rows.Count;
  7481. while (rowStart > 0)
  7482. {
  7483. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7484. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7485. startIndex++;
  7486. rowStart--;
  7487. }
  7488. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7489. wb.CalculateFormula(true);
  7490. //模板文件名
  7491. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7492. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7493. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7494. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7495. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7496. }
  7497. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7498. {
  7499. //获取模板
  7500. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7501. //载入模板
  7502. Document doc = new Document(tempPath);
  7503. DocumentBuilder builder = new DocumentBuilder(doc);
  7504. Dictionary<string, string> dic = new Dictionary<string, string>();
  7505. dic.Add("GroupName", "-");
  7506. dic.Add("ClientUnit", "-");
  7507. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7508. //string missionLeaderJob = "";//负责人job
  7509. //int groupNumber = 0; //团人数
  7510. dic.Add("MissionLeader", "-"); //团负责人
  7511. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7512. dic.Add("GroupNumber", "0"); //团人数
  7513. dic.Add("Day", "0");
  7514. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7515. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7516. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7517. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7518. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7519. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7520. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7521. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7522. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7523. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7524. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7525. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7526. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7527. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7528. //其他费用
  7529. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7530. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7531. //其他费用合计
  7532. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7533. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7534. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7535. //公务舱合计
  7536. //国际旅费
  7537. //string outsideJJ = "";
  7538. //string allPriceJJ = "";
  7539. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7540. {
  7541. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7542. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7543. }
  7544. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7545. {
  7546. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7547. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7548. }
  7549. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7550. {
  7551. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7552. dic.Add("AirFeeTotal", airFeeTotalStr);
  7553. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7554. dic.Add("FeeTotal", feeTotalStr);
  7555. }
  7556. foreach (var key in dic.Keys)
  7557. {
  7558. builder.MoveToBookmark(key);
  7559. builder.Write(dic[key]);
  7560. }
  7561. //模板文件名
  7562. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7563. strFileName = CommonFun.ValidFileName(strFileName);
  7564. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7565. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7566. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7567. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7568. }
  7569. }
  7570. else if (dto.ExportType == 2) //表格
  7571. {
  7572. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7573. }
  7574. else if (dto.ExportType == 3)
  7575. {
  7576. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7577. }
  7578. return Ok(JsonView(400, "只可导出明细表!", ""));
  7579. }
  7580. catch (Exception ex)
  7581. {
  7582. return Ok(JsonView(400, ex.Message, ""));
  7583. }
  7584. }
  7585. /// <summary>
  7586. /// 获取三公费用标准city
  7587. /// </summary>
  7588. /// <param name="placeData"></param>
  7589. /// <param name="nationalTravelFeeId"></param>
  7590. /// <returns></returns>
  7591. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7592. {
  7593. string _city = string.Empty;
  7594. if (!placeData.Any()) return _city;
  7595. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7596. if (data == null) return _city;
  7597. string country = data.Country;
  7598. string city = data.City;
  7599. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7600. else _city = city;
  7601. return _city;
  7602. }
  7603. /// <summary>
  7604. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7605. /// </summary>
  7606. /// <returns></returns>
  7607. [HttpPost]
  7608. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7610. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7611. {
  7612. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7613. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7614. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7615. if (_view.Code == 0)
  7616. {
  7617. return Ok(JsonView(true, "操作成功"));
  7618. }
  7619. return Ok(JsonView(false, "操作失败"));
  7620. }
  7621. /// <summary>
  7622. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7623. /// </summary>
  7624. /// <returns></returns>
  7625. [HttpPost]
  7626. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7628. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7629. {
  7630. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7631. if (data.Code != 0)
  7632. {
  7633. return Ok(JsonView(false, data.Msg));
  7634. }
  7635. return Ok(JsonView(true, "操作成功!", data.Data));
  7636. }
  7637. /// <summary>
  7638. /// 三公其他费用草稿 删除
  7639. /// </summary>
  7640. /// <param name="dto"></param>
  7641. /// <returns></returns>
  7642. [HttpPost]
  7643. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7644. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7645. {
  7646. var jw = JsonView(false, "删除失败!");
  7647. var data = new Grp_DayOtherPriceDraft()
  7648. {
  7649. Id = dto.Id,
  7650. IsDel = 1,
  7651. DeleteUserId = dto.DeleteUserId,
  7652. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7653. };
  7654. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7655. if (del > 0)
  7656. {
  7657. jw.Code = 200;
  7658. jw.Msg = "删除成功!";
  7659. }
  7660. return Ok(jw);
  7661. }
  7662. /// <summary>
  7663. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7664. /// </summary>
  7665. /// <returns></returns>
  7666. [HttpPost]
  7667. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7668. {
  7669. var jw = JsonView(false);
  7670. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7671. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7672. jw.Code = StatusCodes.Status200OK;
  7673. jw.Msg = "操作成功!";
  7674. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7675. return Ok(jw);
  7676. }
  7677. /// <summary>
  7678. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7679. /// </summary>
  7680. /// <param name="dto"></param>
  7681. /// <returns></returns>
  7682. [HttpPost]
  7683. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7684. {
  7685. int userId = dto.UserId,
  7686. portId = dto.PortType,
  7687. groupId = dto.GroupId,
  7688. draftId = dto.DraftId;
  7689. _portTypeData.Add(1);
  7690. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7691. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7692. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7693. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7694. _sqlSugar.BeginTran();
  7695. try
  7696. {
  7697. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7698. if (draftDatas == null)
  7699. {
  7700. _sqlSugar.RollbackTran();
  7701. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7702. }
  7703. //验证可覆盖已有数据 两边创建人需为同一人;
  7704. int draftCreateUserId = draftDatas.CreateUserId,
  7705. formalCreateUserId = 0;
  7706. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7707. if (formalData != null)
  7708. {
  7709. formalCreateUserId = formalData.CreateUserId;
  7710. if (draftCreateUserId != formalCreateUserId)
  7711. {
  7712. _sqlSugar.RollbackTran();
  7713. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7714. }
  7715. }
  7716. //默认添加查看、编辑权限(创建人、自己)
  7717. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7718. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7719. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7720. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7721. newExterData.DiId = groupId;
  7722. newExterData.CreateUserId = userId;
  7723. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7724. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7725. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7726. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7727. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7728. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7729. //数据如果存在执行删除
  7730. if (enterExitCostInfo != null)
  7731. {
  7732. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7733. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7734. .Where(x => x.Id == enterExitCostInfo.Id)
  7735. .ExecuteCommand();
  7736. _sqlSugar.Updateable<Grp_DayAndCost>()
  7737. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7738. .Where(x => x.DiId == groupId)
  7739. .ExecuteCommand();
  7740. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7741. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7742. .Where(x => x.Diid == groupId)
  7743. .ExecuteCommand();
  7744. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7745. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7746. .Where(x => x.GroupId == groupId)
  7747. .ExecuteCommand();
  7748. }
  7749. //执行insert
  7750. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7751. if (insertId < 1)
  7752. {
  7753. _sqlSugar.RollbackTran();
  7754. return Ok(JsonView(false, "草稿数据导入失败!"));
  7755. }
  7756. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7757. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7758. #region 默认添加权限
  7759. #endregion
  7760. _sqlSugar.CommitTran();
  7761. //执行操作之后
  7762. //生成默认文件pdf并且通知人员
  7763. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7764. {
  7765. DiId = groupId,
  7766. ExportType = 1,
  7767. SubTypeId = 1005
  7768. }, "pdf");
  7769. //发送通知
  7770. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7771. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7772. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7773. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7774. //汇率信息记录
  7775. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7776. return Ok(JsonView(true));
  7777. }
  7778. catch (Exception ex)
  7779. {
  7780. _sqlSugar.RollbackTran();
  7781. return Ok(JsonView(false, ex.Message));
  7782. }
  7783. }
  7784. #endregion
  7785. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7786. /// <summary>
  7787. /// 获取币种基础数据(含逻辑处理)
  7788. /// </summary>
  7789. /// <returns></returns>
  7790. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7791. {
  7792. //默认币种显示
  7793. var _currencyInfos = _currencyInit;
  7794. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7795. if (_currencyRate.Count > 0)
  7796. {
  7797. foreach (var item in _currencyInfos)
  7798. {
  7799. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7800. if (rateInfo != null)
  7801. {
  7802. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7803. rate1 *= 1.035M;
  7804. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7805. }
  7806. }
  7807. }
  7808. return _currencyInfos;
  7809. }
  7810. /// <summary>
  7811. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7812. /// </summary>
  7813. /// <returns></returns>
  7814. [HttpPost]
  7815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7816. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7817. {
  7818. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7819. //SetDataInfoView
  7820. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7821. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7822. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7823. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7824. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7825. //默认币种显示
  7826. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7827. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7828. return Ok(JsonView(true, "查询成功!", new
  7829. {
  7830. WordTypeData = _WordTypeData,
  7831. ExcelTypeData = _ExcelTypeData,
  7832. CurrencyInit = _currencyInfos,
  7833. viewPermissionData = viewPermissionData
  7834. }));
  7835. }
  7836. /// <summary>
  7837. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7838. /// </summary>
  7839. /// <returns></returns>
  7840. [HttpPost]
  7841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7842. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7843. {
  7844. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7845. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7846. RefAsync<int> total = 0;
  7847. int diId = 0;
  7848. var status = int.TryParse(dto.GroupName, out diId);
  7849. string sql = string.Format(@"SELECT
  7850. Id,
  7851. TeamName GroupName,
  7852. CASE WHEN EXISTS (
  7853. SELECT
  7854. 1
  7855. FROM
  7856. Grp_EnterExitCost
  7857. WHERE
  7858. IsDel = 0
  7859. AND DiId = di.Id
  7860. ) THEN 1 ELSE 0 END AS [IsNull],
  7861. CASE WHEN EXISTS(
  7862. SELECT
  7863. TOP 1 *
  7864. FROM
  7865. Grp_EnterExitCost
  7866. WHERE
  7867. IsDel = 0
  7868. AND DiId = di.Id
  7869. AND CreateUserId = {0}
  7870. ORDER BY
  7871. CreateTime DESC
  7872. ) THEN 1 ELSE 0 END AS [IsEdit],
  7873. CASE WHEN EXISTS(
  7874. SELECT
  7875. TOP 1 *
  7876. FROM
  7877. Grp_EnterExitCost
  7878. WHERE
  7879. IsDel = 0
  7880. AND DiId = di.Id
  7881. AND CreateUserId = {0}
  7882. ORDER BY
  7883. CreateTime DESC
  7884. ) THEN 1 WHEN EXISTS(
  7885. SELECT
  7886. TOP 1 *
  7887. FROM
  7888. Grp_EnterExitCostPermission
  7889. WHERE
  7890. IsDel = 0
  7891. AND GroupId = di.Id
  7892. AND Permission = 1
  7893. AND UserId = {0}
  7894. ORDER BY
  7895. CreateTime DESC
  7896. ) THEN 1 ELSE 0 END AS [IsView]
  7897. FROM
  7898. Grp_DelegationInfo di
  7899. WHERE
  7900. di.Isdel = 0 ", dto.CurrUserId);
  7901. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7902. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7903. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7904. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7905. .OrderByDescending(x => x.Id)
  7906. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7907. return Ok(JsonView(true, "查询成功!", data, total));
  7908. }
  7909. /// <summary>
  7910. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7911. /// </summary>
  7912. /// <returns></returns>
  7913. [HttpPost]
  7914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7915. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7916. {
  7917. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7918. RefAsync<int> total = 0;
  7919. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7920. .Where(x => x.IsDel == 0 && x.STid == 66)
  7921. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7922. .Select(x => new
  7923. {
  7924. id = x.Id,
  7925. name = x.Name,
  7926. remark = x.Remark,
  7927. })
  7928. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7929. return Ok(JsonView(true, "查询成功!", data, total));
  7930. }
  7931. /// <summary>
  7932. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7933. /// </summary>
  7934. /// <returns></returns>
  7935. [HttpPost]
  7936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7937. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7938. {
  7939. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7940. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7941. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7942. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7943. var groupOtherRateData = groupRateData.TeamRates;
  7944. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7945. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7946. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7947. groupOtherRateData = groupOtherRateData
  7948. .Select(x => new TeamRateDescAddCurrencyIdView
  7949. {
  7950. CurrencyId = x.CurrencyId,
  7951. CurrencyName = x.CurrencyName,
  7952. CurrencyCode = x.CurrencyCode,
  7953. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7954. }).ToList();
  7955. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7956. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7957. }
  7958. /// <summary>
  7959. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7960. /// </summary>
  7961. /// <returns></returns>
  7962. [HttpPost]
  7963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7964. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7965. {
  7966. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7967. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7968. var tipsData = new List<int>() { 1, 2, 3 };
  7969. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7970. if (dto.TipsType == 1)
  7971. {
  7972. //默认币种显示
  7973. var _currencyInfos = _currencyInit;
  7974. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7975. List<dynamic> reteInfos = new List<dynamic>();
  7976. if (_currencyRate.Count > 0)
  7977. {
  7978. foreach (var item in _currencyInfos)
  7979. {
  7980. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7981. if (rateInfo != null)
  7982. {
  7983. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7984. decimal rate1 = item.Rate;
  7985. rate1 *= 1.03M;
  7986. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7987. reteInfos.Add(new
  7988. {
  7989. currCode = item.CurrencyCode,
  7990. currName = item.CurrencyName,
  7991. rate = rate2,
  7992. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7993. });
  7994. }
  7995. }
  7996. }
  7997. return Ok(JsonView(true, "查询成功!", reteInfos));
  7998. }
  7999. else if (dto.TipsType == 2)
  8000. {
  8001. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  8002. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8003. }
  8004. else if (dto.TipsType == 3)
  8005. {
  8006. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8007. return Ok(JsonView(true, "查询成功!", airData.Data));
  8008. }
  8009. return Ok(JsonView(false));
  8010. }
  8011. /// <summary>
  8012. /// 团组模块 - 出入境国家费用标准-移动端 List
  8013. /// </summary>
  8014. /// <returns></returns>
  8015. [HttpPost]
  8016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8017. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8018. {
  8019. Stopwatch sw = new Stopwatch();
  8020. sw.Start();
  8021. RefAsync<int> total = 0;
  8022. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8023. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8024. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8025. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8026. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8027. .Select((ntf, sd, u) => new
  8028. {
  8029. Id = ntf.Id,
  8030. Area = $"{ntf.Country}-{ntf.City}",
  8031. Currency = ntf.Currency,
  8032. CurrencyCode = sd.Name,
  8033. CurrencyName = sd.Remark,
  8034. RoomCost = ntf.RoomCost,
  8035. FoodCost = ntf.FoodCost,
  8036. PublicCost = ntf.PublicCost,
  8037. LastUpdateUserId = ntf.LastUpdateUserId,
  8038. LastUpdateUserName = u.CnName,
  8039. LastUpdateTime = ntf.LastUpdateTime,
  8040. })
  8041. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8042. sw.Stop();
  8043. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8044. }
  8045. /// <summary>
  8046. /// 团组模块 - 出入境费用-移动端 - Info
  8047. /// </summary>
  8048. /// <returns></returns>
  8049. [HttpPost]
  8050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8051. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8052. {
  8053. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8054. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8055. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8056. return Ok(data);
  8057. }
  8058. /// <summary>
  8059. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8060. /// </summary>
  8061. /// <returns></returns>
  8062. [HttpPost]
  8063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8064. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8065. {
  8066. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8067. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8068. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8069. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8070. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8071. mobileInfo.DiId = dto.DiId;
  8072. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8073. if (eecInfo == null) return Ok(mobileInfo);
  8074. //验证查看权限
  8075. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8076. //if (!isView) return Ok(JsonView(false, msg));
  8077. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8078. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8079. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8080. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8081. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8082. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8083. {
  8084. SubId = dac.Id,
  8085. DiId = dac.DiId,
  8086. Type = dac.Type,
  8087. Days = dac.Days,
  8088. NationalTravelFeeId = dac.NationalTravelFeeId,
  8089. Arae = $"{ntf.Country}-{ntf.City}",
  8090. Cost = dac.Cost,
  8091. Currency = dac.Currency,
  8092. CurrencyName = sd.Name,
  8093. SubTotal = dac.SubTotal,
  8094. })
  8095. .ToList();
  8096. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8097. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8098. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8099. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8100. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8101. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8102. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8103. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8104. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8105. //其他款项
  8106. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8107. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8108. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8109. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8110. .OrderBy((dop, sd1, sd2) => dop.Index)
  8111. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8112. {
  8113. SubId = dop.Id,
  8114. DiId = dop.Diid,
  8115. Index = dop.Index,
  8116. SetDataId = dop.SetDataId,
  8117. SetDataName = sd1.Name,
  8118. Cost = dop.Cost,
  8119. Currency = dop.Currency,
  8120. CurrencyName = sd2.Remark,
  8121. SubTotal = dop.SubTotal,
  8122. Remark = dop.Remark,
  8123. })
  8124. .ToArray();
  8125. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8126. return Ok(mobileInfo);
  8127. }
  8128. /// <summary>
  8129. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8130. /// </summary>
  8131. /// <returns></returns>
  8132. [HttpPost]
  8133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8134. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8135. {
  8136. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8137. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8138. //验证查看权限
  8139. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8140. if (!isView) return Ok(JsonView(false, msg));
  8141. var userIds = Array.Empty<int>();
  8142. userIds = await _sqlSugar
  8143. .Queryable<Grp_EnterExitCostPermission>()
  8144. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8145. .Select(x => x.UserId)
  8146. .ToArrayAsync();
  8147. return Ok(userIds);
  8148. }
  8149. /// <summary>
  8150. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8151. /// </summary>
  8152. /// <returns></returns>
  8153. [HttpPost]
  8154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8155. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8156. {
  8157. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8158. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8159. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8160. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8161. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8162. //验证查看权限
  8163. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8164. //if (!isView) return Ok(JsonView(false, msg));
  8165. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8166. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8167. var subType = dto.SubType;
  8168. if (subType == 1) //1:境内费用
  8169. {
  8170. var oneData = new ChoiceOneMobileSubInfoView()
  8171. {
  8172. Id = eecInfo.Id,
  8173. ChoiceOne = eecInfo.ChoiceOne,
  8174. ChoiceOneTotalCost = eecInfo.InsidePay,
  8175. Visa = eecInfo.Visa,
  8176. VisaRemark = eecInfo.VisaRemark,
  8177. YiMiao = eecInfo.YiMiao,
  8178. HeSuan = eecInfo.HeSuan,
  8179. Service = eecInfo.Service,
  8180. Ticket = eecInfo.Ticket,
  8181. Safe = eecInfo.Safe,
  8182. FirstItemRemark = eecInfo.FirstItemRemark
  8183. };
  8184. return Ok(JsonView(oneData));
  8185. }
  8186. else if (subType == 2) //2:国际旅费
  8187. {
  8188. var twoData = new ChoiceTwoMobileSubInfoView()
  8189. {
  8190. Id = eecInfo.Id,
  8191. ChoiceTwoJJ = eecInfo.SumJJC,
  8192. OutsideJJPay = eecInfo.OutsideJJPay,
  8193. ChoiceTwoGW = eecInfo.SumGWC,
  8194. OutsideGWPay = eecInfo.OutsideGWPay,
  8195. ChoiceTwoTD = eecInfo.SumTDC,
  8196. OutsideTDPay = eecInfo.OutsideTDPay,
  8197. AirJJ = eecInfo.AirJJ,
  8198. AirGW = eecInfo.AirGW,
  8199. AirTD = eecInfo.AirTD,
  8200. CityTranffic = eecInfo.CityTranffic,
  8201. TwoItemRemark = eecInfo.TwoItemRemark
  8202. };
  8203. return Ok(JsonView(twoData));
  8204. }
  8205. else if (subType == 3) //3:住宿费
  8206. {
  8207. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8208. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8209. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8210. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8211. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8212. {
  8213. SubId = dac.Id,
  8214. DiId = dac.DiId,
  8215. Type = dac.Type,
  8216. Days = dac.Days,
  8217. NationalTravelFeeId = dac.NationalTravelFeeId,
  8218. Arae = $"{ntf.Country}-{ntf.City}",
  8219. Cost = dac.Cost,
  8220. Currency = dac.Currency,
  8221. CurrencyName = sd.Name,
  8222. SubTotal = dac.SubTotal,
  8223. })
  8224. .ToArray();
  8225. var data = new ChoiceMobileSubInfo3To6View()
  8226. {
  8227. ParentId = eecInfo.Id,
  8228. Choice = eecInfo.ChoiceThree,
  8229. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8230. Details = dayAndCostDatas
  8231. };
  8232. return Ok(JsonView(data));
  8233. }
  8234. else if (subType == 4) //4:伙食费
  8235. {
  8236. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8237. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8238. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8239. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8240. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8241. {
  8242. SubId = dac.Id,
  8243. DiId = dac.DiId,
  8244. Type = dac.Type,
  8245. Days = dac.Days,
  8246. NationalTravelFeeId = dac.NationalTravelFeeId,
  8247. Arae = $"{ntf.Country}-{ntf.City}",
  8248. Cost = dac.Cost,
  8249. Currency = dac.Currency,
  8250. CurrencyName = sd.Name,
  8251. SubTotal = dac.SubTotal,
  8252. })
  8253. .ToArray();
  8254. var data = new ChoiceMobileSubInfo3To6View()
  8255. {
  8256. ParentId = eecInfo.Id,
  8257. Choice = eecInfo.ChoiceFour,
  8258. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8259. Details = dayAndCostDatas
  8260. };
  8261. return Ok(JsonView(data));
  8262. }
  8263. else if (subType == 5) //5:公杂费
  8264. {
  8265. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8266. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8267. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8268. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8269. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8270. {
  8271. SubId = dac.Id,
  8272. DiId = dac.DiId,
  8273. Type = dac.Type,
  8274. Days = dac.Days,
  8275. NationalTravelFeeId = dac.NationalTravelFeeId,
  8276. Arae = $"{ntf.Country}-{ntf.City}",
  8277. Cost = dac.Cost,
  8278. Currency = dac.Currency,
  8279. CurrencyName = sd.Name,
  8280. SubTotal = dac.SubTotal,
  8281. })
  8282. .ToArray();
  8283. var data = new ChoiceMobileSubInfo3To6View()
  8284. {
  8285. ParentId = eecInfo.Id,
  8286. Choice = eecInfo.ChoiceFive,
  8287. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8288. Details = dayAndCostDatas
  8289. };
  8290. return Ok(JsonView(data));
  8291. }
  8292. else if (subType == 6) //6:培训费
  8293. {
  8294. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8295. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8296. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8297. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8298. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8299. {
  8300. SubId = dac.Id,
  8301. DiId = dac.DiId,
  8302. Type = dac.Type,
  8303. Days = dac.Days,
  8304. NationalTravelFeeId = dac.NationalTravelFeeId,
  8305. Arae = $"{ntf.Country}-{ntf.City}",
  8306. Cost = dac.Cost,
  8307. Currency = dac.Currency,
  8308. CurrencyName = sd.Name,
  8309. SubTotal = dac.SubTotal,
  8310. })
  8311. .ToArray();
  8312. var data = new ChoiceMobileSubInfo3To6View()
  8313. {
  8314. ParentId = eecInfo.Id,
  8315. Choice = eecInfo.ChoiceSix,
  8316. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8317. Details = dayAndCostDatas
  8318. };
  8319. return Ok(JsonView(data));
  8320. }
  8321. else if (subType == 7) //7:其他
  8322. {
  8323. //其他款项
  8324. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8325. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8326. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8327. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8328. .OrderBy((dop, sd1, sd2) => dop.Index)
  8329. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8330. {
  8331. SubId = dop.Id,
  8332. DiId = dop.Diid,
  8333. Index = dop.Index,
  8334. SetDataId = dop.SetDataId,
  8335. SetDataName = sd1.Name,
  8336. Cost = dop.Cost,
  8337. Currency = dop.Currency,
  8338. CurrencyName = sd2.Name,
  8339. SubTotal = dop.SubTotal,
  8340. Remark = dop.Remark,
  8341. })
  8342. .ToArray();
  8343. var data = new ChoiceSevenMobileSubInfoView()
  8344. {
  8345. ParentId = eecInfo.Id,
  8346. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8347. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8348. Details = otherData
  8349. };
  8350. return Ok(JsonView(data));
  8351. }
  8352. return Ok(JsonView(false));
  8353. }
  8354. #region op
  8355. /// <summary>
  8356. /// 移动端更新费用消息通知
  8357. /// </summary>
  8358. /// <param name="diid"></param>
  8359. /// <param name="id"></param>
  8360. /// <param name="currUserId"></param>
  8361. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8362. {
  8363. try
  8364. {
  8365. ////生成默认文件pdf并且通知人员
  8366. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8367. //{
  8368. // DiId = diid,
  8369. // ExportType = 1,
  8370. // SubTypeId = 1005
  8371. //}, "pdf");
  8372. ////发送通知
  8373. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8374. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8375. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8376. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8377. ////汇率信息记录
  8378. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8379. }
  8380. catch (Exception ex)
  8381. {
  8382. //记录日志
  8383. throw;
  8384. }
  8385. }
  8386. /// <summary>
  8387. /// 验证出入境费用数据是否存在
  8388. /// 不存在添加
  8389. /// </summary>
  8390. /// <param name="diId"></param>
  8391. /// <param name="currUserId"></param>
  8392. /// <returns></returns>
  8393. /// <exception cref="CustomException"></exception>
  8394. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8395. {
  8396. var parentId = 0;
  8397. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8398. if (info != null)
  8399. {
  8400. parentId = info.Id;
  8401. }
  8402. else
  8403. {
  8404. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8405. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8406. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8407. parentId = addId;
  8408. }
  8409. return parentId;
  8410. }
  8411. /// <summary>
  8412. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8413. /// </summary>
  8414. /// <returns></returns>
  8415. [HttpPost]
  8416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8417. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8418. {
  8419. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8420. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8421. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8422. //验证编辑权限
  8423. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8424. //if (!isEdit) return Ok(JsonView(false, msg));
  8425. var permissions = new List<Grp_EnterExitCostPermission>();
  8426. foreach (var userId in dto.UserIds)
  8427. {
  8428. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8429. }
  8430. if (permissions.Any())
  8431. {
  8432. _sqlSugar.BeginTran();
  8433. try
  8434. {
  8435. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8436. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8437. if (result < 1)
  8438. {
  8439. _sqlSugar.RollbackTran();
  8440. return Ok(JsonView(false));
  8441. }
  8442. }
  8443. catch (Exception ex)
  8444. {
  8445. _sqlSugar.RollbackTran();
  8446. return Ok(JsonView(false, ex.Message));
  8447. }
  8448. _sqlSugar.CommitTran();
  8449. return Ok(JsonView(true));
  8450. }
  8451. return Ok(JsonView(false));
  8452. }
  8453. /// <summary>
  8454. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8455. /// </summary>
  8456. /// <returns></returns>
  8457. [HttpPost]
  8458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8459. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8460. {
  8461. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8462. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8463. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8464. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8465. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8466. int id = dto.Id;
  8467. if (id <= 0) //add
  8468. {
  8469. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8470. if (add < 1) return Ok(JsonView(false));
  8471. id = add;
  8472. }
  8473. else //update
  8474. {
  8475. ////验证编辑权限
  8476. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8477. //if (!isEdit) return Ok(JsonView(false, msg));
  8478. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8479. if (upd < 1) return Ok(JsonView(false));
  8480. }
  8481. #region 汇率变更时更改币种相关费用
  8482. var opDayCosts = new List<Grp_DayAndCost>();
  8483. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8484. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8485. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8486. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8487. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8488. .Select((dac, sd) => new
  8489. {
  8490. dac.Id,
  8491. dac.DiId,
  8492. CurrencyCode = sd.Name,
  8493. dac.Cost
  8494. })
  8495. .ToList();
  8496. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8497. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8498. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8499. .Select((dop, sd) => new
  8500. {
  8501. dop.Id,
  8502. dop.Diid,
  8503. CurrencyCode = sd.Name,
  8504. dop.Cost
  8505. })
  8506. .ToList();
  8507. if (dayCosts.Count > 0)
  8508. {
  8509. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8510. foreach (var dc in new_dayCosts)
  8511. {
  8512. var thisCurrency = dc.Key.ToUpper();
  8513. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8514. if (thisRate == 0.00M) continue;
  8515. foreach (var dcSub in dc)
  8516. {
  8517. opDayCosts.Add(new Grp_DayAndCost()
  8518. {
  8519. Id = dcSub.Id,
  8520. DiId = dcSub.DiId,
  8521. Cost = dcSub.Cost,
  8522. SubTotal = dcSub.Cost * thisRate,
  8523. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8524. });
  8525. }
  8526. }
  8527. if (opDayCosts.Count > 0)
  8528. {
  8529. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8530. }
  8531. }
  8532. if (dayOtherCosts.Count > 0)
  8533. {
  8534. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8535. foreach (var dc in new_dayOtherCosts)
  8536. {
  8537. var thisCurrency = dc.Key.ToUpper();
  8538. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8539. if (thisRate == 0.00M) continue;
  8540. foreach (var dcSub in dc)
  8541. {
  8542. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8543. {
  8544. Id = dcSub.Id,
  8545. Diid = dcSub.Diid,
  8546. Cost = dcSub.Cost,
  8547. SubTotal = dcSub.Cost * thisRate,
  8548. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8549. });
  8550. }
  8551. }
  8552. if (opDayOtherCosts.Count > 0)
  8553. {
  8554. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8555. }
  8556. }
  8557. #endregion
  8558. //消息通知
  8559. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8560. //汇率信息记录
  8561. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8562. return Ok(JsonView(new { parentId = id }));
  8563. }
  8564. /// <summary>
  8565. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8566. /// </summary>
  8567. /// <returns></returns>
  8568. [HttpPost]
  8569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8570. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8571. {
  8572. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8573. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8574. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8575. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8576. int id = dto.Id;
  8577. if (id <= 0) //add
  8578. {
  8579. checkboxInfo.CreateUserId = dto.CurrUserId;
  8580. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8581. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8582. if (add < 1) return Ok(JsonView(false));
  8583. }
  8584. else //update
  8585. {
  8586. ////验证编辑权限
  8587. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8588. //if (!isEdit) return Ok(JsonView(false, msg));
  8589. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8590. .UpdateColumns(x => new
  8591. {
  8592. x.ChoiceOne,
  8593. x.ChoiceTwo,
  8594. x.SumJJC,
  8595. x.SumGWC,
  8596. x.SumTDC,
  8597. x.ChoiceThree,
  8598. x.ChoiceFour,
  8599. x.ChoiceFive,
  8600. x.ChoiceSix,
  8601. x.OtherExpenses_Checked
  8602. })
  8603. .Where(x => x.Id == id)
  8604. .ExecuteCommandAsync();
  8605. if (upd < 1) return Ok(JsonView(false));
  8606. }
  8607. return Ok(JsonView(new { parentId = id }));
  8608. }
  8609. /// <summary>
  8610. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8611. /// </summary>
  8612. /// <returns></returns>
  8613. [HttpPost]
  8614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8615. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8616. {
  8617. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8618. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8619. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8620. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8621. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8622. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8623. var checkboxInfo = new Grp_EnterExitCost()
  8624. {
  8625. Id = id,
  8626. DiId = diId,
  8627. CreateUserId = currUserId
  8628. };
  8629. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8630. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8631. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8632. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8633. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8634. if (id <= 0) //add
  8635. {
  8636. checkboxInfo.CreateUserId = dto.CurrUserId;
  8637. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8638. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8639. if (add < 1) return Ok(JsonView(false));
  8640. }
  8641. else //update
  8642. {
  8643. ////验证编辑权限
  8644. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8645. //if (!isEdit) return Ok(JsonView(false, msg));
  8646. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8647. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8648. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8649. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8650. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8651. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8652. .Where(x => x.Id == id)
  8653. .ExecuteCommandAsync();
  8654. if (upd < 1) return Ok(JsonView(false));
  8655. }
  8656. return Ok(JsonView(new { parentId = id }));
  8657. }
  8658. /// <summary>
  8659. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8660. /// </summary>
  8661. /// <returns></returns>
  8662. [HttpPost]
  8663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8664. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8665. {
  8666. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8667. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8668. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8669. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8670. info.FirstItemRemark = dto.FirstItemRemark;
  8671. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8672. int id = dto.Id;
  8673. if (id <= 0) //add
  8674. {
  8675. info.CreateUserId = dto.CurrUserId;
  8676. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8677. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8678. if (add < 1) return Ok(JsonView(false));
  8679. id = add;
  8680. }
  8681. else //update
  8682. {
  8683. ////验证编辑权限
  8684. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8685. //if (!isEdit) return Ok(JsonView(false, msg));
  8686. var upd = await _sqlSugar.Updateable(info)
  8687. .UpdateColumns(x => new
  8688. {
  8689. x.ChoiceOne,
  8690. x.InsidePay,
  8691. x.VisaRemark,
  8692. x.Visa,
  8693. x.Service,
  8694. x.Safe,
  8695. x.Ticket,
  8696. x.HeSuan,
  8697. x.YiMiao,
  8698. x.FirstItemRemark
  8699. })
  8700. .Where(x => x.Id == id)
  8701. .ExecuteCommandAsync();
  8702. if (upd < 1) return Ok(JsonView(false));
  8703. }
  8704. //消息通知
  8705. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8706. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8707. }
  8708. /// <summary>
  8709. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8710. /// </summary>
  8711. /// <returns></returns>
  8712. [HttpPost]
  8713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8714. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8715. {
  8716. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8717. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8718. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8719. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8720. info.OutsideJJPay = dto.OutsideJJPay;
  8721. info.OutsideGWPay = dto.OutsideGWPay;
  8722. info.OutsideTDPay = dto.OutsideTDPay;
  8723. info.AirJJ = dto.AirJJ;
  8724. info.AirGW = dto.AirGW;
  8725. info.AirTD = dto.AirTD;
  8726. info.CityTranffic = dto.CityTranffic;
  8727. info.TwoItemRemark = dto.TwoItemRemark;
  8728. info.SumJJC = dto.ChoiceTwoJJ;
  8729. info.SumGWC = dto.ChoiceTwoGW;
  8730. info.SumTDC = dto.ChoiceTwoTD;
  8731. int id = dto.Id;
  8732. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8733. if (id <= 0) //add
  8734. {
  8735. info.CreateUserId = dto.CurrUserId;
  8736. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8737. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8738. if (addId <= 0) return Ok(JsonView(false));
  8739. id = addId;
  8740. }
  8741. else //update
  8742. {
  8743. ////验证编辑权限
  8744. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8745. //if (!isEdit) return Ok(JsonView(false, msg));
  8746. var upd = await _sqlSugar.Updateable(info)
  8747. .UpdateColumns(x => new
  8748. {
  8749. x.SumJJC,
  8750. x.OutsideJJPay,
  8751. x.SumGWC,
  8752. x.OutsideGWPay,
  8753. x.SumTDC,
  8754. x.OutsideTDPay,
  8755. x.AirJJ,
  8756. x.AirGW,
  8757. x.AirTD,
  8758. x.CityTranffic,
  8759. x.TwoItemRemark
  8760. })
  8761. .Where(x => x.Id == id)
  8762. .ExecuteCommandAsync();
  8763. if (upd < 1) return Ok(JsonView(false));
  8764. }
  8765. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8766. gwcItemTotal = info.AirGW + info.CityTranffic;
  8767. tdcItemTotal = info.AirTD + info.CityTranffic;
  8768. //消息通知
  8769. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8770. return Ok(JsonView(new
  8771. {
  8772. parentId = id,
  8773. choiceTwoJJ = dto.ChoiceTwoJJ,
  8774. jjcItemTotal = jjcItemTotal,
  8775. choiceTwoGW = dto.ChoiceTwoGW,
  8776. gwcItemTotal = gwcItemTotal,
  8777. choiceTwoTD = dto.ChoiceTwoTD,
  8778. tdcItemTotal = tdcItemTotal
  8779. }));
  8780. }
  8781. /// <summary>
  8782. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8783. /// </summary>
  8784. /// <returns></returns>
  8785. [HttpPost]
  8786. [ApiExplorerSettings(IgnoreApi = true)]
  8787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8788. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8789. {
  8790. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8791. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8792. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8793. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8794. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8795. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8796. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8797. var infos = infos1.Select(x => new Grp_DayAndCost
  8798. {
  8799. Id = x.Id,
  8800. DiId = dto.DiId,
  8801. Type = dto.FeeType,
  8802. Days = x.Days,
  8803. NationalTravelFeeId = x.NationalTravelFeeId,
  8804. Cost = x.Cost,
  8805. Currency = x.Currency,
  8806. SubTotal = x.SubTotal,
  8807. CreateUserId = dto.CurrUserId
  8808. })
  8809. .ToList();
  8810. var adds = infos.Where(x => x.Id <= 0).ToList();
  8811. var upds = infos.Where(x => x.Id > 0).ToList();
  8812. if (adds.Count > 0)
  8813. {
  8814. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8815. if (add < 1) return Ok(JsonView(false));
  8816. }
  8817. if (upds.Count > 0)
  8818. {
  8819. var upd = await _sqlSugar.Updateable(adds)
  8820. .UpdateColumns(x => new
  8821. {
  8822. x.Days,
  8823. x.NationalTravelFeeId,
  8824. x.Cost,
  8825. x.Currency,
  8826. x.SubTotal
  8827. })
  8828. .WhereColumns(x => new { x.Id })
  8829. .ExecuteCommandAsync();
  8830. if (upd < 1) return Ok(JsonView(false));
  8831. }
  8832. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8833. //消息通知
  8834. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8835. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8836. return Ok(JsonView(new { itemTotal = itemTotal }));
  8837. }
  8838. /// <summary>
  8839. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8840. /// </summary>
  8841. /// <returns></returns>
  8842. [HttpPost]
  8843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8844. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8845. {
  8846. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8847. int subId = dto.SubId, feeType = dto.FeeType;
  8848. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8849. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8850. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8851. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8852. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8853. subInfo.Id = subId;
  8854. subInfo.DiId = dto.DiId;
  8855. if (feeType == 3) subInfo.Type = 1;
  8856. else if (feeType == 4) subInfo.Type = 2;
  8857. else if (feeType == 5) subInfo.Type = 3;
  8858. else if (feeType == 6) subInfo.Type = 4;
  8859. subInfo.CreateUserId = dto.CurrUserId;
  8860. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8861. if (parentId < 1) return Ok(JsonView(false));
  8862. //子表op
  8863. if (subId < 1)
  8864. {
  8865. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8866. if (subAdd < 1) return Ok(JsonView(false));
  8867. }
  8868. else
  8869. {
  8870. ////验证编辑权限
  8871. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8872. //if (!isEdit) return Ok(JsonView(false, msg));
  8873. var subUpd = await _sqlSugar.Updateable(subInfo)
  8874. .UpdateColumns(x => new
  8875. {
  8876. x.Days,
  8877. x.NationalTravelFeeId,
  8878. x.Cost,
  8879. x.Currency,
  8880. x.SubTotal
  8881. })
  8882. .WhereColumns(x => new { x.Id })
  8883. .ExecuteCommandAsync();
  8884. if (subUpd < 1) return Ok(JsonView(false));
  8885. }
  8886. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8887. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8888. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8889. }
  8890. /// <summary>
  8891. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8892. /// </summary>
  8893. /// <returns></returns>
  8894. [HttpPost]
  8895. [ApiExplorerSettings(IgnoreApi = true)]
  8896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8897. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8898. {
  8899. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8900. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8901. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8902. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8903. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8904. {
  8905. Id = x.Id,
  8906. Diid = dto.DiId,
  8907. SetDataId = x.SetDataId,
  8908. Index = x.Index,
  8909. Cost = x.Cost,
  8910. Currency = x.Currency,
  8911. SubTotal = x.SubTotal,
  8912. CreateUserId = dto.CurrUserId,
  8913. Remark = x.Remark
  8914. }).ToList();
  8915. var adds = infos.Where(x => x.Id <= 0).ToList();
  8916. var upds = infos.Where(x => x.Id > 0).ToList();
  8917. if (adds.Count > 0)
  8918. {
  8919. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8920. if (add < 1) return Ok(JsonView(false));
  8921. }
  8922. if (upds.Count > 0)
  8923. {
  8924. var upd = await _sqlSugar.Updateable(adds)
  8925. .UpdateColumns(x => new
  8926. {
  8927. x.Index,
  8928. x.SetDataId,
  8929. x.Cost,
  8930. x.Currency,
  8931. x.SubTotal,
  8932. x.Remark
  8933. })
  8934. .WhereColumns(x => new { x.Id })
  8935. .ExecuteCommandAsync();
  8936. if (upd < 1) return Ok(JsonView(false));
  8937. }
  8938. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8939. //消息通知
  8940. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8941. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8942. return Ok(JsonView(new { itemTotal = itemTotal }));
  8943. }
  8944. /// <summary>
  8945. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8946. /// </summary>
  8947. /// <returns></returns>
  8948. [HttpPost]
  8949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8950. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8951. {
  8952. int subId = dto.SubId;
  8953. int diId = dto.Diid;
  8954. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8955. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8956. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8957. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8958. subInfo.Id = subId;
  8959. subInfo.Diid = dto.Diid;
  8960. subInfo.CreateUserId = dto.CurrUserId;
  8961. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8962. if (parentId < 1) return Ok(JsonView(false));
  8963. #region 子表op
  8964. if (subId < 1)//add
  8965. {
  8966. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8967. if (subAdd < 1) return Ok(JsonView(false));
  8968. }
  8969. else //upd
  8970. {
  8971. ////验证编辑权限
  8972. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8973. //if (!isEdit) return Ok(JsonView(false, msg));
  8974. var subUpd = await _sqlSugar.Updateable(subInfo)
  8975. .UpdateColumns(x => new
  8976. {
  8977. x.Index,
  8978. x.SetDataId,
  8979. x.Cost,
  8980. x.Currency,
  8981. x.SubTotal,
  8982. x.Remark
  8983. })
  8984. .WhereColumns(x => new { x.Id })
  8985. .ExecuteCommandAsync();
  8986. if (subUpd < 1) return Ok(JsonView(false));
  8987. }
  8988. #endregion
  8989. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8990. //消息通知
  8991. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8992. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8993. }
  8994. /// <summary>
  8995. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8996. /// </summary>
  8997. /// <returns></returns>
  8998. [HttpPost]
  8999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9000. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9001. {
  9002. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9003. if (data.Code != 0)
  9004. {
  9005. return Ok(JsonView(false, data.Msg));
  9006. }
  9007. return Ok(JsonView(true, "操作成功!", data.Data));
  9008. }
  9009. /// <summary>
  9010. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9011. /// </summary>
  9012. /// <param name="dto"></param>
  9013. /// <returns></returns>
  9014. [HttpPost]
  9015. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9016. {
  9017. var data = new Grp_DayOtherPrice()
  9018. {
  9019. Id = dto.Id,
  9020. IsDel = 1,
  9021. DeleteUserId = dto.DeleteUserId,
  9022. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9023. };
  9024. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9025. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9026. return Ok(JsonView(false, "删除失败!"));
  9027. }
  9028. #endregion
  9029. #endregion
  9030. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9031. /// <summary>
  9032. /// 出入境费用-草稿 移动端
  9033. /// 获取币种基础数据(含逻辑处理)
  9034. /// </summary>
  9035. /// <returns></returns>
  9036. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9037. {
  9038. //默认币种显示
  9039. var _currencyInfos = _currencyInit;
  9040. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9041. if (_currencyRate.Count > 0)
  9042. {
  9043. foreach (var item in _currencyInfos)
  9044. {
  9045. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9046. if (rateInfo != null)
  9047. {
  9048. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  9049. rate1 *= 1.035M;
  9050. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9051. }
  9052. }
  9053. }
  9054. return _currencyInfos;
  9055. }
  9056. /// <summary>
  9057. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9058. /// </summary>
  9059. /// <returns></returns>
  9060. [HttpPost]
  9061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9062. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9063. {
  9064. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9065. //SetDataInfoView
  9066. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9067. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9068. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9069. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9070. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9071. //默认币种显示
  9072. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9073. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9074. return Ok(JsonView(true, "查询成功!", new
  9075. {
  9076. WordTypeData = _WordTypeData,
  9077. ExcelTypeData = _ExcelTypeData,
  9078. CurrencyInit = _currencyInfos,
  9079. viewPermissionData = viewPermissionData
  9080. }));
  9081. }
  9082. /// <summary>
  9083. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9084. /// </summary>
  9085. /// <returns></returns>
  9086. [HttpPost]
  9087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9088. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9089. {
  9090. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9091. RefAsync<int> total = 0;
  9092. int diId = 0;
  9093. var status = int.TryParse(dto.GroupName, out diId);
  9094. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9095. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9096. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9097. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9098. .Select(x => new
  9099. {
  9100. Id = x.Id,
  9101. GroupName = x.TeamName
  9102. })
  9103. .OrderByDescending(x => x.Id)
  9104. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9105. return Ok(JsonView(true, "查询成功!", data, total));
  9106. }
  9107. /// <summary>
  9108. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9109. /// </summary>
  9110. /// <returns></returns>
  9111. [HttpPost]
  9112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9113. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9114. {
  9115. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9116. RefAsync<int> total = 0;
  9117. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9118. .Where(x => x.IsDel == 0 && x.STid == 66)
  9119. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9120. .Select(x => new
  9121. {
  9122. id = x.Id,
  9123. name = x.Name,
  9124. remark = x.Remark,
  9125. })
  9126. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9127. return Ok(JsonView(true, "查询成功!", data, total));
  9128. }
  9129. /// <summary>
  9130. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9131. /// </summary>
  9132. /// <returns></returns>
  9133. [HttpPost]
  9134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9135. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9136. {
  9137. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9138. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9139. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9140. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9141. var groupOtherRateData = groupRateData.TeamRates;
  9142. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9143. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9144. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9145. groupOtherRateData = groupOtherRateData
  9146. .Select(x => new TeamRateDescAddCurrencyIdView
  9147. {
  9148. CurrencyId = x.CurrencyId,
  9149. CurrencyName = x.CurrencyName,
  9150. CurrencyCode = x.CurrencyCode,
  9151. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9152. }).ToList();
  9153. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9154. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9155. }
  9156. /// <summary>
  9157. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9158. /// </summary>
  9159. /// <returns></returns>
  9160. [HttpPost]
  9161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9162. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9163. {
  9164. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9165. var tipsData = new List<int>() { 1, 2, 3 };
  9166. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9167. if (dto.TipsType == 1)
  9168. {
  9169. //默认币种显示
  9170. var _currencyInfos = _currencyInit;
  9171. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9172. List<dynamic> reteInfos = new List<dynamic>();
  9173. if (_currencyRate.Count > 0)
  9174. {
  9175. foreach (var item in _currencyInfos)
  9176. {
  9177. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9178. if (rateInfo != null)
  9179. {
  9180. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9181. decimal rate1 = item.Rate;
  9182. rate1 *= 1.03M;
  9183. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9184. reteInfos.Add(new
  9185. {
  9186. currCode = item.CurrencyCode,
  9187. currName = item.CurrencyName,
  9188. rate = rate2,
  9189. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9190. });
  9191. }
  9192. }
  9193. }
  9194. return Ok(JsonView(true, "查询成功!", reteInfos));
  9195. }
  9196. else if (dto.TipsType == 2)
  9197. {
  9198. }
  9199. else if (dto.TipsType == 3)
  9200. {
  9201. }
  9202. return Ok(JsonView(false));
  9203. }
  9204. /// <summary>
  9205. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9206. /// </summary>
  9207. /// <returns></returns>
  9208. [HttpPost]
  9209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9210. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9211. {
  9212. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9213. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9214. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9215. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9216. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9217. if (eecInfo == null) return Ok(mobileInfo);
  9218. //验证查看权限
  9219. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9220. if (!isView) return Ok(JsonView(false, msg));
  9221. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9222. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9223. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9224. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9225. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9226. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9227. {
  9228. ParentId = dac.ParentId,
  9229. SubId = dac.Id,
  9230. Type = dac.Type,
  9231. Days = dac.Days,
  9232. NationalTravelFeeId = dac.NationalTravelFeeId,
  9233. Arae = $"{ntf.Country}-{ntf.City}",
  9234. Cost = dac.Cost,
  9235. Currency = dac.Currency,
  9236. CurrencyName = sd.Name,
  9237. SubTotal = dac.SubTotal,
  9238. })
  9239. .ToList();
  9240. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9241. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9242. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9243. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9244. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9245. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9246. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9247. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9248. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9249. //其他款项
  9250. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9251. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9252. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9253. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9254. .OrderBy((dop, sd1, sd2) => dop.Index)
  9255. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9256. {
  9257. ParentId = dop.ParentId,
  9258. SubId = dop.Id,
  9259. Index = dop.Index,
  9260. SetDataId = dop.SetDataId,
  9261. SetDataName = sd1.Name,
  9262. Cost = dop.Cost,
  9263. Currency = dop.Currency,
  9264. CurrencyName = sd2.Remark,
  9265. SubTotal = dop.SubTotal,
  9266. Remark = dop.Remark,
  9267. })
  9268. .ToArray();
  9269. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9270. return Ok(mobileInfo);
  9271. }
  9272. /// <summary>
  9273. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9274. /// </summary>
  9275. /// <returns></returns>
  9276. [HttpPost]
  9277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9278. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9279. {
  9280. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9281. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9282. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9283. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9284. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9285. //验证查看权限
  9286. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9287. if (!isView) return Ok(JsonView(false, msg));
  9288. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9289. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9290. var subType = dto.SubType;
  9291. if (subType == 1) //1:境内费用
  9292. {
  9293. var oneData = new ChoiceOneMobileSubInfoView()
  9294. {
  9295. Id = eecInfo.Id,
  9296. ChoiceOne = eecInfo.ChoiceOne,
  9297. ChoiceOneTotalCost = eecInfo.InsidePay,
  9298. Visa = eecInfo.Visa,
  9299. VisaRemark = eecInfo.VisaRemark,
  9300. YiMiao = eecInfo.YiMiao,
  9301. HeSuan = eecInfo.HeSuan,
  9302. Service = eecInfo.Service,
  9303. Ticket = eecInfo.Ticket,
  9304. Safe = eecInfo.Safe,
  9305. FirstItemRemark = eecInfo.FirstItemRemark
  9306. };
  9307. return Ok(JsonView(oneData));
  9308. }
  9309. else if (subType == 2) //2:国际旅费
  9310. {
  9311. var twoData = new ChoiceTwoMobileSubInfoView()
  9312. {
  9313. Id = eecInfo.Id,
  9314. ChoiceTwoJJ = eecInfo.SumJJC,
  9315. OutsideJJPay = eecInfo.OutsideJJPay,
  9316. ChoiceTwoGW = eecInfo.SumGWC,
  9317. OutsideGWPay = eecInfo.OutsideGWPay,
  9318. ChoiceTwoTD = eecInfo.SumTDC,
  9319. OutsideTDPay = eecInfo.OutsideTDPay,
  9320. AirJJ = eecInfo.AirJJ,
  9321. AirGW = eecInfo.AirGW,
  9322. AirTD = eecInfo.AirTD,
  9323. CityTranffic = eecInfo.CityTranffic,
  9324. TwoItemRemark = eecInfo.TwoItemRemark
  9325. };
  9326. return Ok(JsonView(twoData));
  9327. }
  9328. else if (subType == 3) //3:住宿费
  9329. {
  9330. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9331. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9332. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9333. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9334. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9335. {
  9336. ParentId = dac.ParentId,
  9337. SubId = dac.Id,
  9338. Type = dac.Type,
  9339. Days = dac.Days,
  9340. NationalTravelFeeId = dac.NationalTravelFeeId,
  9341. Arae = $"{ntf.Country}-{ntf.City}",
  9342. Cost = dac.Cost,
  9343. Currency = dac.Currency,
  9344. CurrencyName = sd.Name,
  9345. SubTotal = dac.SubTotal,
  9346. })
  9347. .ToArray();
  9348. var data = new ChoiceDraftMobileSubInfo3To6View()
  9349. {
  9350. ParentId = eecInfo.Id,
  9351. Choice = eecInfo.ChoiceThree,
  9352. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9353. Details = dayAndCostDatas
  9354. };
  9355. return Ok(JsonView(data));
  9356. }
  9357. else if (subType == 4) //4:伙食费
  9358. {
  9359. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9360. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9361. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9362. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9363. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9364. {
  9365. ParentId = dac.ParentId,
  9366. SubId = dac.Id,
  9367. Type = dac.Type,
  9368. Days = dac.Days,
  9369. NationalTravelFeeId = dac.NationalTravelFeeId,
  9370. Arae = $"{ntf.Country}-{ntf.City}",
  9371. Cost = dac.Cost,
  9372. Currency = dac.Currency,
  9373. CurrencyName = sd.Name,
  9374. SubTotal = dac.SubTotal,
  9375. })
  9376. .ToArray();
  9377. var data = new ChoiceDraftMobileSubInfo3To6View()
  9378. {
  9379. ParentId = eecInfo.Id,
  9380. Choice = eecInfo.ChoiceFour,
  9381. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9382. Details = dayAndCostDatas
  9383. };
  9384. return Ok(JsonView(data));
  9385. }
  9386. else if (subType == 5) //5:公杂费
  9387. {
  9388. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9389. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9390. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9391. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9392. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9393. {
  9394. ParentId = dac.ParentId,
  9395. SubId = dac.Id,
  9396. Type = dac.Type,
  9397. Days = dac.Days,
  9398. NationalTravelFeeId = dac.NationalTravelFeeId,
  9399. Arae = $"{ntf.Country}-{ntf.City}",
  9400. Cost = dac.Cost,
  9401. Currency = dac.Currency,
  9402. CurrencyName = sd.Name,
  9403. SubTotal = dac.SubTotal,
  9404. })
  9405. .ToArray();
  9406. var data = new ChoiceDraftMobileSubInfo3To6View()
  9407. {
  9408. ParentId = eecInfo.Id,
  9409. Choice = eecInfo.ChoiceFive,
  9410. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9411. Details = dayAndCostDatas
  9412. };
  9413. return Ok(JsonView(data));
  9414. }
  9415. else if (subType == 6) //6:培训费
  9416. {
  9417. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9418. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9419. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9420. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9421. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9422. {
  9423. ParentId = dac.ParentId,
  9424. SubId = dac.Id,
  9425. Type = dac.Type,
  9426. Days = dac.Days,
  9427. NationalTravelFeeId = dac.NationalTravelFeeId,
  9428. Arae = $"{ntf.Country}-{ntf.City}",
  9429. Cost = dac.Cost,
  9430. Currency = dac.Currency,
  9431. CurrencyName = sd.Name,
  9432. SubTotal = dac.SubTotal,
  9433. })
  9434. .ToArray();
  9435. var data = new ChoiceDraftMobileSubInfo3To6View()
  9436. {
  9437. ParentId = eecInfo.Id,
  9438. Choice = eecInfo.ChoiceSix,
  9439. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9440. Details = dayAndCostDatas
  9441. };
  9442. return Ok(JsonView(data));
  9443. }
  9444. else if (subType == 7) //7:其他
  9445. {
  9446. //其他款项
  9447. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9448. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9449. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9450. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9451. .OrderBy((dop, sd1, sd2) => dop.Index)
  9452. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9453. {
  9454. ParentId = dop.ParentId,
  9455. SubId = dop.Id,
  9456. Index = dop.Index,
  9457. SetDataId = dop.SetDataId,
  9458. SetDataName = sd1.Name,
  9459. Cost = dop.Cost,
  9460. Currency = dop.Currency,
  9461. CurrencyName = sd2.Name,
  9462. SubTotal = dop.SubTotal,
  9463. Remark = dop.Remark,
  9464. })
  9465. .ToArray();
  9466. var data = new ChoiceSevenDraftMobileSubInfoView()
  9467. {
  9468. ParentId = eecInfo.Id,
  9469. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9470. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9471. Details = otherData
  9472. };
  9473. return Ok(JsonView(data));
  9474. }
  9475. return Ok(JsonView(false));
  9476. }
  9477. #region op
  9478. /// <summary>
  9479. /// 移动端更新费用消息通知
  9480. /// </summary>
  9481. /// <param name="draftId"></param>
  9482. /// <param name="id"></param>
  9483. /// <param name="currUserId"></param>
  9484. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9485. {
  9486. try
  9487. {
  9488. ////生成默认文件pdf并且通知人员
  9489. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9490. //{
  9491. // DiId = draftId,
  9492. // ExportType = 1,
  9493. // SubTypeId = 1005
  9494. //}, "pdf");
  9495. ////发送通知
  9496. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9497. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9498. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9499. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9500. ////汇率信息记录
  9501. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9502. }
  9503. catch (Exception ex)
  9504. {
  9505. //记录日志
  9506. throw;
  9507. }
  9508. }
  9509. /// <summary>
  9510. /// 验证出入境费用数据是否存在
  9511. /// 不存在添加
  9512. /// </summary>
  9513. /// <param name="draftId"></param>
  9514. /// <param name="currUserId"></param>
  9515. /// <returns></returns>
  9516. /// <exception cref="CustomException"></exception>
  9517. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9518. {
  9519. var parentId = 0;
  9520. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9521. if (info != null) parentId = info.Id;
  9522. else
  9523. {
  9524. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9525. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9526. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9527. parentId = addId;
  9528. }
  9529. return parentId;
  9530. }
  9531. /// <summary>
  9532. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9533. /// </summary>
  9534. /// <returns></returns>
  9535. [HttpPost]
  9536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9537. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9538. {
  9539. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9540. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9541. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9542. //验证编辑权限
  9543. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9544. if (!isEdit) return Ok(JsonView(false, msg));
  9545. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9546. foreach (var userId in dto.UserIds)
  9547. {
  9548. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9549. }
  9550. if (permissions.Any())
  9551. {
  9552. _sqlSugar.BeginTran();
  9553. try
  9554. {
  9555. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9556. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9557. if (result < 1)
  9558. {
  9559. _sqlSugar.RollbackTran();
  9560. return Ok(JsonView(false));
  9561. }
  9562. }
  9563. catch (Exception ex)
  9564. {
  9565. _sqlSugar.RollbackTran();
  9566. return Ok(JsonView(false, ex.Message));
  9567. }
  9568. _sqlSugar.CommitTran();
  9569. return Ok(JsonView(true));
  9570. }
  9571. return Ok(JsonView(false));
  9572. }
  9573. /// <summary>
  9574. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9575. /// </summary>
  9576. /// <returns></returns>
  9577. [HttpPost]
  9578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9579. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9580. {
  9581. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9582. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9583. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9584. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9585. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9586. int id = dto.DraftId;
  9587. if (id <= 0) //add
  9588. {
  9589. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9590. if (add < 1) return Ok(JsonView(false));
  9591. id = add;
  9592. }
  9593. else //update
  9594. {
  9595. //验证编辑权限
  9596. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9597. if (!isEdit) return Ok(JsonView(false, msg));
  9598. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9599. if (upd < 1) return Ok(JsonView(false));
  9600. }
  9601. #region 汇率变更时更改币种相关费用
  9602. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9603. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9604. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9605. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9606. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9607. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9608. .Select((dac, sd) => new
  9609. {
  9610. dac.Id,
  9611. dac.ParentId,
  9612. CurrencyCode = sd.Name,
  9613. dac.Cost
  9614. })
  9615. .ToList();
  9616. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9617. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9618. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9619. .Select((dop, sd) => new
  9620. {
  9621. dop.Id,
  9622. dop.ParentId,
  9623. CurrencyCode = sd.Name,
  9624. dop.Cost
  9625. })
  9626. .ToList();
  9627. if (dayCosts.Count > 0)
  9628. {
  9629. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9630. foreach (var dc in new_dayCosts)
  9631. {
  9632. var thisCurrency = dc.Key.ToUpper();
  9633. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9634. if (thisRate == 0.00M) continue;
  9635. foreach (var dcSub in dc)
  9636. {
  9637. opDayCosts.Add(new Grp_DayAndCostDraft()
  9638. {
  9639. Id = dcSub.Id,
  9640. ParentId = dcSub.ParentId,
  9641. Cost = dcSub.Cost,
  9642. SubTotal = dcSub.Cost * thisRate,
  9643. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9644. });
  9645. }
  9646. }
  9647. if (opDayCosts.Count > 0)
  9648. {
  9649. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9650. }
  9651. }
  9652. if (dayOtherCosts.Count > 0)
  9653. {
  9654. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9655. foreach (var dc in new_dayOtherCosts)
  9656. {
  9657. var thisCurrency = dc.Key.ToUpper();
  9658. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9659. if (thisRate == 0.00M) continue;
  9660. foreach (var dcSub in dc)
  9661. {
  9662. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9663. {
  9664. Id = dcSub.Id,
  9665. ParentId = dcSub.ParentId,
  9666. Cost = dcSub.Cost,
  9667. SubTotal = dcSub.Cost * thisRate,
  9668. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9669. });
  9670. }
  9671. }
  9672. if (opDayOtherCosts.Count > 0)
  9673. {
  9674. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9675. }
  9676. }
  9677. #endregion
  9678. ////消息通知
  9679. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9680. ////汇率信息记录
  9681. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9682. return Ok(JsonView(new { parentId = id }));
  9683. }
  9684. /// <summary>
  9685. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9686. /// </summary>
  9687. /// <returns></returns>
  9688. [HttpPost]
  9689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9690. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9691. {
  9692. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9693. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9694. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9695. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9696. int id = dto.DraftId;
  9697. if (id <= 0) //add
  9698. {
  9699. checkboxInfo.CreateUserId = dto.CurrUserId;
  9700. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9701. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9702. if (add < 1) return Ok(JsonView(false));
  9703. }
  9704. else //update
  9705. {
  9706. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9707. .UpdateColumns(x => new
  9708. {
  9709. x.ChoiceOne,
  9710. x.ChoiceTwo,
  9711. x.SumJJC,
  9712. x.SumGWC,
  9713. x.SumTDC,
  9714. x.ChoiceThree,
  9715. x.ChoiceFour,
  9716. x.ChoiceFive,
  9717. x.ChoiceSix,
  9718. x.OtherExpenses_Checked
  9719. })
  9720. .Where(x => x.Id == id)
  9721. .ExecuteCommandAsync();
  9722. if (upd < 1) return Ok(JsonView(false));
  9723. }
  9724. return Ok(JsonView(new { parentId = id }));
  9725. }
  9726. /// <summary>
  9727. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9728. /// </summary>
  9729. /// <returns></returns>
  9730. [HttpPost]
  9731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9732. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9733. {
  9734. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9735. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9736. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9737. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9738. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9739. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9740. var checkboxInfo = new Grp_EnterExitCostDraft()
  9741. {
  9742. Id = draftId,
  9743. CreateUserId = currUserId
  9744. };
  9745. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9746. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9747. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9748. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9749. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9750. if (draftId <= 0) //add
  9751. {
  9752. checkboxInfo.CreateUserId = dto.CurrUserId;
  9753. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9754. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9755. if (add < 1) return Ok(JsonView(false));
  9756. }
  9757. else //update
  9758. {
  9759. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9760. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9761. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9762. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9763. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9764. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9765. .Where(x => x.Id == draftId)
  9766. .ExecuteCommandAsync();
  9767. if (upd < 1) return Ok(JsonView(false));
  9768. }
  9769. return Ok(JsonView(new { parentId = draftId }));
  9770. }
  9771. /// <summary>
  9772. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9773. /// </summary>
  9774. /// <returns></returns>
  9775. [HttpPost]
  9776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9777. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9778. {
  9779. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9780. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9781. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9782. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9783. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9784. info.FirstItemRemark = dto.FirstItemRemark;
  9785. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9786. if (id <= 0) //add
  9787. {
  9788. info.CreateUserId = dto.CurrUserId;
  9789. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9790. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9791. if (add < 1) return Ok(JsonView(false));
  9792. id = add;
  9793. }
  9794. else //update
  9795. {
  9796. var upd = await _sqlSugar.Updateable(info)
  9797. .UpdateColumns(x => new
  9798. {
  9799. x.ChoiceOne,
  9800. x.InsidePay,
  9801. x.VisaRemark,
  9802. x.Visa,
  9803. x.Service,
  9804. x.Safe,
  9805. x.Ticket,
  9806. x.HeSuan,
  9807. x.YiMiao,
  9808. x.FirstItemRemark
  9809. })
  9810. .Where(x => x.Id == id)
  9811. .ExecuteCommandAsync();
  9812. if (upd < 1) return Ok(JsonView(false));
  9813. }
  9814. ////消息通知
  9815. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9816. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9817. }
  9818. /// <summary>
  9819. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9820. /// </summary>
  9821. /// <returns></returns>
  9822. [HttpPost]
  9823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9824. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9825. {
  9826. int id = dto.DraftId;
  9827. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9828. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9829. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9830. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9831. info.OutsideJJPay = dto.OutsideJJPay;
  9832. info.OutsideGWPay = dto.OutsideGWPay;
  9833. info.OutsideTDPay = dto.OutsideTDPay;
  9834. info.AirJJ = dto.AirJJ;
  9835. info.AirGW = dto.AirGW;
  9836. info.AirTD = dto.AirTD;
  9837. info.CityTranffic = dto.CityTranffic;
  9838. info.TwoItemRemark = dto.TwoItemRemark;
  9839. info.SumJJC = dto.ChoiceTwoJJ;
  9840. info.SumGWC = dto.ChoiceTwoGW;
  9841. info.SumTDC = dto.ChoiceTwoTD;
  9842. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9843. if (id <= 0) //add
  9844. {
  9845. info.CreateUserId = dto.CurrUserId;
  9846. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9847. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9848. if (addId <= 0) return Ok(JsonView(false));
  9849. id = addId;
  9850. }
  9851. else //update
  9852. {
  9853. var upd = await _sqlSugar.Updateable(info)
  9854. .UpdateColumns(x => new
  9855. {
  9856. x.SumJJC,
  9857. x.OutsideJJPay,
  9858. x.SumGWC,
  9859. x.OutsideGWPay,
  9860. x.SumTDC,
  9861. x.OutsideTDPay,
  9862. x.AirJJ,
  9863. x.AirGW,
  9864. x.AirTD,
  9865. x.CityTranffic,
  9866. x.TwoItemRemark
  9867. })
  9868. .Where(x => x.Id == id)
  9869. .ExecuteCommandAsync();
  9870. if (upd < 1) return Ok(JsonView(false));
  9871. }
  9872. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9873. gwcItemTotal = info.AirGW + info.CityTranffic;
  9874. tdcItemTotal = info.AirTD + info.CityTranffic;
  9875. ////消息通知
  9876. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9877. return Ok(JsonView(new
  9878. {
  9879. parentId = id,
  9880. choiceTwoJJ = dto.ChoiceTwoJJ,
  9881. jjcItemTotal = jjcItemTotal,
  9882. choiceTwoGW = dto.ChoiceTwoGW,
  9883. gwcItemTotal = gwcItemTotal,
  9884. choiceTwoTD = dto.ChoiceTwoTD,
  9885. tdcItemTotal = tdcItemTotal
  9886. }));
  9887. }
  9888. /// <summary>
  9889. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9890. /// </summary>
  9891. /// <returns></returns>
  9892. [HttpPost]
  9893. [ApiExplorerSettings(IgnoreApi = true)]
  9894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9895. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9896. {
  9897. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9898. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9899. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9900. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9901. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9902. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9903. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9904. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9905. {
  9906. Id = x.Id,
  9907. ParentId = dto.DraftId,
  9908. Type = dto.FeeType,
  9909. Days = x.Days,
  9910. NationalTravelFeeId = x.NationalTravelFeeId,
  9911. Cost = x.Cost,
  9912. Currency = x.Currency,
  9913. SubTotal = x.SubTotal,
  9914. CreateUserId = dto.CurrUserId
  9915. })
  9916. .ToList();
  9917. var adds = infos.Where(x => x.Id <= 0).ToList();
  9918. var upds = infos.Where(x => x.Id > 0).ToList();
  9919. if (adds.Count > 0)
  9920. {
  9921. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9922. if (add < 1) return Ok(JsonView(false));
  9923. }
  9924. if (upds.Count > 0)
  9925. {
  9926. var upd = await _sqlSugar.Updateable(adds)
  9927. .UpdateColumns(x => new
  9928. {
  9929. x.Days,
  9930. x.NationalTravelFeeId,
  9931. x.Cost,
  9932. x.Currency,
  9933. x.SubTotal
  9934. })
  9935. .WhereColumns(x => new { x.Id })
  9936. .ExecuteCommandAsync();
  9937. if (upd < 1) return Ok(JsonView(false));
  9938. }
  9939. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9940. ////消息通知
  9941. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9942. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9943. return Ok(JsonView(new { itemTotal = itemTotal }));
  9944. }
  9945. /// <summary>
  9946. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9947. /// </summary>
  9948. /// <returns></returns>
  9949. [HttpPost]
  9950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9951. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9952. {
  9953. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9954. int subId = dto.SubId, feeType = dto.FeeType;
  9955. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9956. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9957. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9958. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9959. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9960. subInfo.Id = subId;
  9961. subInfo.ParentId = dto.DraftId;
  9962. if (feeType == 3) subInfo.Type = 1;
  9963. else if (feeType == 4) subInfo.Type = 2;
  9964. else if (feeType == 5) subInfo.Type = 3;
  9965. else if (feeType == 6) subInfo.Type = 4;
  9966. subInfo.CreateUserId = dto.CurrUserId;
  9967. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9968. if (parentId < 1) return Ok(JsonView(false));
  9969. //子表op
  9970. if (subId < 1)
  9971. {
  9972. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9973. if (subAdd < 1) return Ok(JsonView(false));
  9974. }
  9975. else
  9976. {
  9977. var subUpd = await _sqlSugar.Updateable(subInfo)
  9978. .UpdateColumns(x => new
  9979. {
  9980. x.Days,
  9981. x.NationalTravelFeeId,
  9982. x.Cost,
  9983. x.Currency,
  9984. x.SubTotal
  9985. })
  9986. .WhereColumns(x => new { x.Id })
  9987. .ExecuteCommandAsync();
  9988. if (subUpd < 1) return Ok(JsonView(false));
  9989. }
  9990. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9991. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9992. }
  9993. /// <summary>
  9994. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9995. /// </summary>
  9996. /// <returns></returns>
  9997. [HttpPost]
  9998. [ApiExplorerSettings(IgnoreApi = true)]
  9999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10000. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10001. {
  10002. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10003. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10004. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10005. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10006. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10007. {
  10008. Id = x.Id,
  10009. ParentId = dto.DraftId,
  10010. SetDataId = x.SetDataId,
  10011. Index = x.Index,
  10012. Cost = x.Cost,
  10013. Currency = x.Currency,
  10014. SubTotal = x.SubTotal,
  10015. CreateUserId = dto.CurrUserId,
  10016. Remark = x.Remark
  10017. }).ToList();
  10018. var adds = infos.Where(x => x.Id <= 0).ToList();
  10019. var upds = infos.Where(x => x.Id > 0).ToList();
  10020. if (adds.Count > 0)
  10021. {
  10022. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10023. if (add < 1) return Ok(JsonView(false));
  10024. }
  10025. if (upds.Count > 0)
  10026. {
  10027. var upd = await _sqlSugar.Updateable(adds)
  10028. .UpdateColumns(x => new
  10029. {
  10030. x.Index,
  10031. x.SetDataId,
  10032. x.Cost,
  10033. x.Currency,
  10034. x.SubTotal,
  10035. x.Remark
  10036. })
  10037. .WhereColumns(x => new { x.Id })
  10038. .ExecuteCommandAsync();
  10039. if (upd < 1) return Ok(JsonView(false));
  10040. }
  10041. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10042. //消息通知
  10043. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10044. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10045. return Ok(JsonView(new { itemTotal = itemTotal }));
  10046. }
  10047. /// <summary>
  10048. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10049. /// </summary>
  10050. /// <returns></returns>
  10051. [HttpPost]
  10052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10053. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10054. {
  10055. int subId = dto.SubId, id = dto.DarftId;
  10056. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10057. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10058. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10059. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10060. subInfo.Id = subId;
  10061. subInfo.ParentId = dto.DarftId;
  10062. subInfo.CreateUserId = dto.CurrUserId;
  10063. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10064. if (parentId < 1) return Ok(JsonView(false));
  10065. #region 子表op
  10066. if (subId < 1)//add
  10067. {
  10068. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10069. if (subAdd < 1) return Ok(JsonView(false));
  10070. }
  10071. else //upd
  10072. {
  10073. var subUpd = await _sqlSugar.Updateable(subInfo)
  10074. .UpdateColumns(x => new
  10075. {
  10076. x.Index,
  10077. x.SetDataId,
  10078. x.Cost,
  10079. x.Currency,
  10080. x.SubTotal,
  10081. x.Remark
  10082. })
  10083. .WhereColumns(x => new { x.Id })
  10084. .ExecuteCommandAsync();
  10085. if (subUpd < 1) return Ok(JsonView(false));
  10086. }
  10087. #endregion
  10088. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10089. ////消息通知
  10090. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10091. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10092. }
  10093. /// <summary>
  10094. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10095. /// </summary>
  10096. /// <returns></returns>
  10097. [HttpPost]
  10098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10099. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10100. {
  10101. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10102. if (data.Code != 0)
  10103. {
  10104. return Ok(JsonView(false, data.Msg));
  10105. }
  10106. return Ok(JsonView(true, "操作成功!", data.Data));
  10107. }
  10108. /// <summary>
  10109. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10110. /// </summary>
  10111. /// <param name="dto"></param>
  10112. /// <returns></returns>
  10113. [HttpPost]
  10114. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10115. {
  10116. var data = new Grp_DayOtherPriceDraft()
  10117. {
  10118. Id = dto.Id,
  10119. IsDel = 1,
  10120. DeleteUserId = dto.DeleteUserId,
  10121. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10122. };
  10123. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10124. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10125. return Ok(JsonView(false, "删除失败!"));
  10126. }
  10127. #endregion
  10128. #endregion
  10129. #region 签证费用录入
  10130. /// <summary>
  10131. /// 根据diid查询签证费用列表
  10132. /// </summary>
  10133. /// <param name="dto"></param>
  10134. /// <returns></returns>
  10135. [HttpPost]
  10136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10137. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10138. {
  10139. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10140. if (groupData.Code != 0)
  10141. {
  10142. return Ok(JsonView(false, groupData.Msg));
  10143. }
  10144. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10145. }
  10146. /// <summary>
  10147. /// 根据签证费用Id查询单条数据及c表数据
  10148. /// </summary>
  10149. /// <param name="dto"></param>
  10150. /// <returns></returns>
  10151. [HttpPost]
  10152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10153. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10154. {
  10155. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10156. if (groupData.Code != 0)
  10157. {
  10158. return Ok(JsonView(false, groupData.Msg));
  10159. }
  10160. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10161. }
  10162. /// <summary>
  10163. /// 签证费用删除
  10164. /// </summary>
  10165. /// <param name="dto"></param>
  10166. /// <returns></returns>
  10167. [HttpPost]
  10168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10169. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10170. {
  10171. _sqlSugar.BeginTran();
  10172. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10173. if (!res)
  10174. {
  10175. _sqlSugar.RollbackTran();
  10176. return Ok(JsonView(false, "删除失败"));
  10177. }
  10178. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10179. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10180. .SetColumns(a => new Grp_CreditCardPayment()
  10181. {
  10182. IsDel = 1,
  10183. DeleteUserId = dto.DeleteUserId,
  10184. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10185. })
  10186. .ExecuteCommand();
  10187. if (resSub < 1)
  10188. {
  10189. _sqlSugar.RollbackTran();
  10190. return Ok(JsonView(false, "删除失败"));
  10191. }
  10192. _sqlSugar.CommitTran();
  10193. return Ok(JsonView(true, "删除成功!"));
  10194. }
  10195. /// <summary>
  10196. /// 签证费用录入下拉框初始化
  10197. /// </summary>
  10198. /// <returns></returns>
  10199. [HttpPost]
  10200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10201. public async Task<IActionResult> VisaPriceAddSelect()
  10202. {
  10203. //支付方式
  10204. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10205. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10206. //币种
  10207. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10208. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10209. //乘客类型
  10210. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10211. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10212. //卡类型
  10213. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10214. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10215. //代办费类型
  10216. var agencyFeeTypeData = new List<dynamic>() {
  10217. new { id = 0 , Text = "未选择" },
  10218. new { id = 1 , Text = "小公务" },
  10219. new { id = 2 , Text = "大公务" },
  10220. };
  10221. //签证费用标准国家Data
  10222. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10223. var data = new
  10224. {
  10225. Payment = _Payment,
  10226. CurrencyList = _CurrencyList,
  10227. PassengerType = _PassengerType,
  10228. BankCard = _BankCard,
  10229. AgencyFeeType = agencyFeeTypeData,
  10230. CountryFeeData = visaCountryFeeData
  10231. };
  10232. return Ok(JsonView(true, "查询成功!", data));
  10233. }
  10234. /// <summary>
  10235. /// 签证费用录入操作(Status:1.新增,2.修改)
  10236. /// </summary>
  10237. /// <param name="dto"></param>
  10238. /// <returns></returns>
  10239. [HttpPost]
  10240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10241. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10242. {
  10243. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10244. if (groupData.Code != 0)
  10245. {
  10246. return Ok(JsonView(false, groupData.Msg));
  10247. }
  10248. #region 应用推送
  10249. try
  10250. {
  10251. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10252. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10253. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10254. //2024-10-21 新增LZ UID
  10255. var userIds = new List<int>() { 21 };
  10256. string title = $"系统通知";
  10257. string content = "";
  10258. var diId = dto.DiId;
  10259. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10260. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10261. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10262. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10263. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10264. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10265. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10266. }
  10267. catch (Exception ex)
  10268. {
  10269. }
  10270. #endregion
  10271. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10272. }
  10273. #endregion
  10274. #region 签证提成录入
  10275. /// <summary>
  10276. /// 签证提成录入
  10277. /// 基础数据
  10278. /// </summary>
  10279. /// <returns></returns>
  10280. [HttpGet]
  10281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10282. public async Task<IActionResult> VisaCommissionInit()
  10283. {
  10284. return Ok(await _visaCommissionRep.Init());
  10285. }
  10286. /// <summary>
  10287. /// 签证提成录入
  10288. /// Item
  10289. /// </summary>
  10290. /// <param name="_dto"></param>
  10291. /// <returns></returns>
  10292. [HttpPost]
  10293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10294. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10295. {
  10296. var validator = new VisaCommissionItemDtoValidator();
  10297. var validatorRes = await validator.ValidateAsync(_dto);
  10298. if (!validatorRes.IsValid)
  10299. {
  10300. StringBuilder sb = new StringBuilder();
  10301. foreach (var item in validatorRes.Errors)
  10302. {
  10303. sb.AppendLine(item.ErrorMessage);
  10304. }
  10305. return Ok(JsonView(false, sb.ToString()));
  10306. }
  10307. return Ok(await _visaCommissionRep.Item(_dto));
  10308. }
  10309. /// <summary>
  10310. /// 签证提成录入
  10311. /// Save
  10312. /// </summary>
  10313. /// <param name="_dto"></param>
  10314. /// <returns></returns>
  10315. [HttpPost]
  10316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10317. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10318. {
  10319. //参数验证
  10320. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10321. foreach (var item in _dto.Items)
  10322. {
  10323. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10324. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10325. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10326. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10327. }
  10328. return Ok(await _visaCommissionRep.Save(_dto));
  10329. }
  10330. /// <summary>
  10331. /// 签证提成录入
  10332. /// Create
  10333. /// </summary>
  10334. /// <param name="_dto"></param>
  10335. /// <returns></returns>
  10336. [HttpPost]
  10337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10338. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10339. {
  10340. var validator = new VisaCommissionCreateDtoValidator();
  10341. var validatorRes = await validator.ValidateAsync(_dto);
  10342. if (!validatorRes.IsValid)
  10343. {
  10344. StringBuilder sb = new StringBuilder();
  10345. foreach (var item in validatorRes.Errors)
  10346. {
  10347. sb.AppendLine(item.ErrorMessage);
  10348. }
  10349. return Ok(JsonView(false, sb.ToString()));
  10350. }
  10351. return Ok(await _visaCommissionRep.Create(_dto));
  10352. }
  10353. /// <summary>
  10354. /// 签证提成录入
  10355. /// Put(编辑)
  10356. /// </summary>
  10357. /// <param name="id"></param>
  10358. /// <param name="_dto"></param>
  10359. /// <returns></returns>
  10360. [HttpPut]
  10361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10362. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10363. {
  10364. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10365. var validator = new VisaCommissionCreateDtoValidator();
  10366. var validatorRes = await validator.ValidateAsync(_dto);
  10367. if (!validatorRes.IsValid)
  10368. {
  10369. StringBuilder sb = new StringBuilder();
  10370. foreach (var item in validatorRes.Errors)
  10371. {
  10372. sb.AppendLine(item.ErrorMessage);
  10373. }
  10374. return Ok(JsonView(false, sb.ToString()));
  10375. }
  10376. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10377. }
  10378. /// <summary>
  10379. /// 签证提成录入
  10380. /// Del
  10381. /// </summary>
  10382. /// <param name="id"></param>
  10383. /// <param name="currUserId"></param>
  10384. /// <returns></returns>
  10385. [HttpPost]
  10386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10387. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10388. {
  10389. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10390. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10391. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10392. }
  10393. #endregion
  10394. #region op费用录入
  10395. /// <summary>
  10396. /// 根据diid查询op费用列表
  10397. /// </summary>
  10398. /// <param name="dto"></param>
  10399. /// <returns></returns>
  10400. [HttpPost]
  10401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10402. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10403. {
  10404. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10405. if (groupData.Code != 0)
  10406. {
  10407. return Ok(JsonView(false, groupData.Msg));
  10408. }
  10409. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10410. }
  10411. /// <summary>
  10412. /// 根据op费用Id查询单条数据及c表数据
  10413. /// </summary>
  10414. /// <param name="dto"></param>
  10415. /// <returns></returns>
  10416. [HttpPost]
  10417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10418. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10419. {
  10420. try
  10421. {
  10422. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10423. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10424. var data = new
  10425. {
  10426. CarTouristGuideGround = _groupData,
  10427. CreditCardPayment = _creditCardPayment
  10428. };
  10429. return Ok(JsonView(true, "查询成功!", data));
  10430. }
  10431. catch (Exception ex)
  10432. {
  10433. return Ok(JsonView(false, "程序错误!"));
  10434. }
  10435. }
  10436. /// <summary>
  10437. /// op费用删除
  10438. /// </summary>
  10439. /// <param name="dto"></param>
  10440. /// <returns></returns>
  10441. [HttpPost]
  10442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10443. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10444. {
  10445. try
  10446. {
  10447. _sqlSugar.BeginTran();
  10448. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10449. if (!res)
  10450. {
  10451. return Ok(JsonView(false, "删除失败"));
  10452. }
  10453. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10454. {
  10455. IsDel = 1,
  10456. DeleteUserId = dto.DeleteUserId,
  10457. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10458. }).ExecuteCommandAsync();
  10459. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10460. {
  10461. IsDel = 1,
  10462. DeleteUserId = dto.DeleteUserId,
  10463. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10464. }).ExecuteCommandAsync();
  10465. #region 删除超支相关数据
  10466. //删除导入的超支数据
  10467. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10468. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10469. {
  10470. IsDel = 1,
  10471. DeleteUserId = dto.DeleteUserId,
  10472. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10473. }).ExecuteCommand();
  10474. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10475. {
  10476. IsDel = 1,
  10477. DeleteUserId = dto.DeleteUserId,
  10478. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10479. }).ExecuteCommand();
  10480. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10481. {
  10482. IsDel = 1,
  10483. DeleteUserId = dto.DeleteUserId,
  10484. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10485. }).ExecuteCommand();
  10486. #endregion
  10487. _sqlSugar.CommitTran();
  10488. return Ok(JsonView(true, "删除成功!"));
  10489. }
  10490. catch (Exception ex)
  10491. {
  10492. _sqlSugar.RollbackTran();
  10493. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10494. }
  10495. }
  10496. /// <summary>
  10497. /// op费用录入操作(Status:1.新增,2.修改)
  10498. /// </summary>
  10499. /// <param name="dto"></param>
  10500. /// <returns></returns>
  10501. [HttpPost]
  10502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10503. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10504. {
  10505. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10506. if (groupData.Code != 0)
  10507. {
  10508. return Ok(JsonView(false, groupData.Msg));
  10509. }
  10510. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10511. }
  10512. /// <summary>
  10513. /// 填写费用详细页面初始化绑定
  10514. /// </summary>
  10515. /// <param name="dto"></param>
  10516. /// <returns></returns>
  10517. [HttpPost]
  10518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10519. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10520. {
  10521. try
  10522. {
  10523. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10524. if (groupData.Code != 0)
  10525. {
  10526. return Ok(JsonView(false, groupData.Msg));
  10527. }
  10528. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10529. }
  10530. catch (Exception ex)
  10531. {
  10532. return Ok(JsonView(false, ex.Message));
  10533. }
  10534. }
  10535. /// <summary>
  10536. /// 根据op费用Id查询详细数据
  10537. /// </summary>
  10538. /// <param name="dto"></param>
  10539. /// <returns></returns>
  10540. [HttpPost]
  10541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10542. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10543. {
  10544. try
  10545. {
  10546. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10547. if (groupData.Code != 0)
  10548. {
  10549. return Ok(JsonView(false, groupData.Msg));
  10550. }
  10551. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10552. }
  10553. catch (Exception ex)
  10554. {
  10555. return Ok(JsonView(false, ex.Message));
  10556. }
  10557. }
  10558. /// <summary>
  10559. /// OP费用录入填写详情
  10560. /// </summary>
  10561. /// <param name="dto"></param>
  10562. /// <returns></returns>
  10563. [HttpPost]
  10564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10565. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10566. {
  10567. try
  10568. {
  10569. #region 参数校验
  10570. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10571. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10572. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10573. #endregion
  10574. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10575. if (groupData.Code != 0)
  10576. {
  10577. return Ok(JsonView(false, groupData.Msg));
  10578. }
  10579. //自动审核
  10580. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10581. #region 应用推送
  10582. try
  10583. {
  10584. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10585. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10586. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10587. //2024-10-21 新增LZ UID
  10588. var userIds = new List<int>() { 21 };
  10589. string title = $"系统通知";
  10590. var diId = dto.DiId;
  10591. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10592. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10593. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  10594. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10595. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10596. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10597. }
  10598. catch (Exception ex)
  10599. {
  10600. }
  10601. #endregion
  10602. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10603. }
  10604. catch (Exception ex)
  10605. {
  10606. return Ok(JsonView(false, ex.Message));
  10607. }
  10608. }
  10609. /// <summary>
  10610. /// 获取三公详细所有城市
  10611. /// </summary>
  10612. /// <returns></returns>
  10613. [HttpGet]
  10614. public IActionResult OpCarCityResult()
  10615. {
  10616. var jw = JsonView(false);
  10617. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10618. {
  10619. x.Id,
  10620. x.Country,
  10621. x.City,
  10622. }).ToList();
  10623. if (data.Count > 0)
  10624. {
  10625. jw = JsonView(true, "获取成功!", data);
  10626. }
  10627. else
  10628. {
  10629. jw.Msg = "城市数据为空!";
  10630. jw.Data = new string[0];
  10631. }
  10632. return Ok(jw);
  10633. }
  10634. /// <summary>
  10635. /// 导出地接费用明细
  10636. /// </summary>
  10637. /// <param name="dto"></param>
  10638. /// <returns></returns>
  10639. [HttpPost]
  10640. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10641. {
  10642. var jw = JsonView(false);
  10643. if (dto.Diid < 1)
  10644. {
  10645. jw.Msg = "请输入正确的diid!";
  10646. return Ok(jw);
  10647. }
  10648. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10649. if (group == null)
  10650. {
  10651. jw.Msg = "未找到团组信息!";
  10652. return Ok(jw);
  10653. }
  10654. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10655. if (localGuideArr.Count == 0)
  10656. {
  10657. jw.Msg = "该团组暂无地接信息!";
  10658. return Ok(jw);
  10659. }
  10660. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10661. var overspendSoure = new Dictionary<int, int>
  10662. {
  10663. { 91, 982 }, //车
  10664. { 92 , 1059} ,//导游
  10665. { 994 , 1073}, //翻译
  10666. { 988 , 1074 }, //早餐
  10667. { 93 , 1075 }, //午餐
  10668. { 989 , 1076 }, //晚餐
  10669. };
  10670. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10671. foreach (var groupArr in localGroup)
  10672. {
  10673. var keyValue = groupArr.Key;
  10674. if (int.TryParse(keyValue, out int cityid))
  10675. {
  10676. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10677. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10678. }
  10679. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10680. foreach (var item in groupArr)
  10681. {
  10682. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10683. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10684. new Grp_CarTouristGuideGroundReservationsContentExtend
  10685. {
  10686. Count = a.Count,
  10687. CreateTime = a.CreateTime,
  10688. CreateUserId = a.CreateUserId,
  10689. CTGGRId = a.CTGGRId,
  10690. Currency = a.Currency,
  10691. DatePrice = a.DatePrice,
  10692. DeleteTime = a.DeleteTime,
  10693. DeleteUserId = a.DeleteUserId,
  10694. DiId = a.DiId,
  10695. Id = a.Id,
  10696. IsDel = a.IsDel,
  10697. Price = a.Price,
  10698. PriceContent = a.PriceContent,
  10699. Remark = a.Remark,
  10700. SId = a.SId,
  10701. SidName = b.Name,
  10702. Units = a.Units,
  10703. }
  10704. ).ToList();
  10705. if (content.Count > 0)
  10706. {
  10707. contentArr.Add(content);
  10708. }
  10709. }
  10710. //open excel
  10711. //set excel
  10712. //save excel
  10713. try
  10714. {
  10715. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10716. IWorkbook workbook;
  10717. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10718. {
  10719. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10720. }
  10721. else
  10722. {
  10723. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10724. }
  10725. ISheet sheet = workbook.GetSheetAt(0);
  10726. var rowStartIndex = 2;
  10727. var clounmCount = 10;
  10728. var initStyleRow = sheet.GetRow(2);
  10729. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10730. //var overspendArrDetail =
  10731. var existsId = new List<CarCompare>();
  10732. var lastElem = arr.Last();
  10733. var thisSid = -1;
  10734. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10735. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10736. {
  10737. Name = "未知币种!",
  10738. Remark = "未知币种!",
  10739. };
  10740. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10741. Action cloneRowFn = () =>
  10742. {
  10743. rowStartIndex++;
  10744. var cloneRow = sheet.CreateRow(rowStartIndex);
  10745. // 复制样式
  10746. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10747. {
  10748. ICell sourceCell = initStyleRow.GetCell(i);
  10749. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10750. // 确保单元格存在样式
  10751. if (sourceCell.CellStyle != null)
  10752. {
  10753. targetCell.CellStyle = sourceCell.CellStyle;
  10754. }
  10755. }
  10756. };
  10757. var mergeRow = () =>
  10758. {
  10759. for (int i = 2; i < sheet.LastRowNum; i++)
  10760. {
  10761. var row = sheet.GetRow(i);
  10762. var cellFirst = row.GetCell(0);
  10763. var thisIndex = i + 1;
  10764. while (thisIndex < sheet.LastRowNum)
  10765. {
  10766. var nextRow = sheet.GetRow(thisIndex);
  10767. var nextCellFirst = nextRow.GetCell(0);
  10768. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10769. {
  10770. thisIndex++;
  10771. }
  10772. else
  10773. {
  10774. break;
  10775. }
  10776. }
  10777. thisIndex--;
  10778. if (thisIndex != i)
  10779. {
  10780. //合并row
  10781. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10782. i, // 起始行索引(0-based)
  10783. thisIndex, // 结束行索引(0-based)
  10784. 0, // 起始列索引(0-based)
  10785. 0 // 结束列索引(0-based)
  10786. );
  10787. sheet.AddMergedRegion(cellRangeAddress);
  10788. i = thisIndex;
  10789. }
  10790. }
  10791. };
  10792. var chaoshiNumber = 0;
  10793. var totalNumber = 0.00M;
  10794. string lastStr = "";
  10795. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10796. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10797. {
  10798. b.IsAuditGM,
  10799. x.Id,
  10800. x.Area,
  10801. b.PayPercentage,
  10802. b.PayMoney,
  10803. }).ToList();
  10804. string yesPayment = "", noPayment = "";
  10805. foreach (var item in queryCarArrByCityAndDiid)
  10806. {
  10807. if (item.IsAuditGM == 1)
  10808. {
  10809. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10810. }
  10811. else
  10812. {
  10813. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10814. }
  10815. }
  10816. lastStr = yesPayment + noPayment;
  10817. foreach (var item in arr)
  10818. {
  10819. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10820. {
  10821. if (thisSid != item.SId)
  10822. {
  10823. if (thisSid == -1)
  10824. {
  10825. thisSid = item.SId;
  10826. }
  10827. else
  10828. {
  10829. //合并小计行
  10830. //创建合并区域的实例
  10831. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10832. rowStartIndex, // 起始行索引(0-based)
  10833. rowStartIndex, // 结束行索引(0-based)
  10834. 0, // 起始列索引(0-based)
  10835. 3 // 结束列索引(0-based)
  10836. );
  10837. sheet.AddMergedRegion(cellRangeAddress);
  10838. var CellStyle = workbook.CreateCellStyle();
  10839. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10840. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10841. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10842. for (int i = 0; i <= clounmCount; i++)
  10843. {
  10844. if (i > 6)
  10845. {
  10846. var CellStyle1 = workbook.CreateCellStyle();
  10847. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10848. IFont Font = workbook.CreateFont(); // 创建字体
  10849. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10850. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10851. CellStyle1.SetFont(Font);
  10852. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10853. }
  10854. else
  10855. {
  10856. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10857. }
  10858. }
  10859. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10860. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10861. //超时合计
  10862. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10863. //超时数
  10864. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10865. //超时合计费用
  10866. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10867. thisSid = item.SId;
  10868. cloneRowFn();
  10869. chaoshiNumber = 0;
  10870. totalNumber = 0;
  10871. }
  10872. }
  10873. IRow row = sheet.GetRow(rowStartIndex);
  10874. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10875. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10876. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10877. if (isOpenOverspendSoure)
  10878. {
  10879. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10880. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10881. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10882. }
  10883. for (int i = 0; i <= clounmCount; i++)
  10884. {
  10885. var cell = row.GetCell(i);
  10886. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10887. if (cell == null)
  10888. {
  10889. cell = row.CreateCell(i);
  10890. }
  10891. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10892. fontRed.CloneStyleFrom(cell.CellStyle);
  10893. IFont Font = workbook.CreateFont(); // 创建字体
  10894. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10895. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10896. fontRed.SetFont(Font);
  10897. byte[] rgb = new byte[3] { 255, 242, 204 };
  10898. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10899. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10900. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10901. if (workbook is XSSFWorkbook)
  10902. {
  10903. BackgroundColor255_242_204.FillForegroundColor = 0;
  10904. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10905. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10906. }
  10907. else
  10908. {
  10909. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10910. }
  10911. if (i == 1 || i > 6)
  10912. {
  10913. if (i > 6)
  10914. {
  10915. fontRed.FillForegroundColor = 0;
  10916. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10917. fontRed.FillPattern = FillPattern.SolidForeground;
  10918. }
  10919. cell.CellStyle = fontRed;
  10920. }
  10921. if (i > 2 && i < 7)
  10922. {
  10923. cell.CellStyle = BackgroundColor255_242_204;
  10924. }
  10925. cell.SetCellValue(setCellValue); //写入单元格
  10926. }
  10927. if (overspendSoure.ContainsKey(thisSid))
  10928. {
  10929. var overspendId = overspendSoure[thisSid];
  10930. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10931. }
  10932. cloneRowFn();
  10933. existsId.Add(new CarCompare
  10934. {
  10935. DataPrice = item.DatePrice.ObjToDate(),
  10936. Sid = item.SId
  10937. });
  10938. }
  10939. if (item.Equals(lastElem))
  10940. {
  10941. //合并小计行
  10942. //创建合并区域的实例
  10943. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10944. rowStartIndex, // 起始行索引(0-based)
  10945. rowStartIndex, // 结束行索引(0-based)
  10946. 0, // 起始列索引(0-based)
  10947. 3 // 结束列索引(0-based)
  10948. );
  10949. sheet.AddMergedRegion(cellRangeAddress);
  10950. var CellStyle = workbook.CreateCellStyle();
  10951. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10952. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10953. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10954. for (int i = 0; i <= clounmCount; i++)
  10955. {
  10956. if (i > 6)
  10957. {
  10958. var CellStyle1 = workbook.CreateCellStyle();
  10959. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10960. IFont Font = workbook.CreateFont(); // 创建字体
  10961. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10962. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10963. CellStyle1.SetFont(Font);
  10964. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10965. }
  10966. else
  10967. {
  10968. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10969. }
  10970. }
  10971. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10972. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10973. //超时合计
  10974. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10975. //超时数
  10976. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10977. //超时合计费用
  10978. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10979. cloneRowFn();
  10980. // 创建合并区域的实例
  10981. cellRangeAddress = new CellRangeAddress(
  10982. rowStartIndex, // 起始行索引(0-based)
  10983. rowStartIndex, // 结束行索引(0-based)
  10984. 0, // 起始列索引(0-based)
  10985. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10986. );
  10987. // 添加合并区域
  10988. sheet.AddMergedRegion(cellRangeAddress);
  10989. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  10990. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  10991. }
  10992. }
  10993. mergeRow();
  10994. // 保存修改后的Excel文件到新文件
  10995. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  10996. // new FileStream(newFilePath, FileMode.CreateNew)
  10997. using (var stream = new MemoryStream())
  10998. {
  10999. workbook.Write(stream, true);
  11000. stream.Flush();
  11001. stream.Seek(0, SeekOrigin.Begin);
  11002. MemoryStream memoryStream = new MemoryStream();
  11003. stream.CopyTo(memoryStream);
  11004. memoryStream.Seek(0, SeekOrigin.Begin);
  11005. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11006. }
  11007. workbook.Close();
  11008. workbook.Dispose();
  11009. }
  11010. catch (Exception ex)
  11011. {
  11012. jw.Msg = "出现异常!" + ex.Message;
  11013. return Ok(jw);
  11014. }
  11015. }
  11016. if (Zips.Count > 0)
  11017. {
  11018. IOOperatorHelper io = new IOOperatorHelper();
  11019. var byts = io.ConvertZipStream(Zips);
  11020. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11021. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11022. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11023. }
  11024. else
  11025. {
  11026. jw.Msg = "暂无生成文件!";
  11027. }
  11028. return Ok(jw);
  11029. }
  11030. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11031. {
  11032. string outStr = string.Empty;
  11033. switch (i)
  11034. {
  11035. case 0:
  11036. outStr = arr[0].SidName;
  11037. break;
  11038. case 1:
  11039. outStr = arr[0].DataPriceStr;
  11040. break;
  11041. case 2:
  11042. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11043. break;
  11044. case 4:
  11045. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11046. break;
  11047. case 7:
  11048. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11049. {
  11050. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11051. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11052. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11053. }
  11054. break;
  11055. case 8:
  11056. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11057. {
  11058. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11059. }
  11060. break;
  11061. case 9:
  11062. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11063. {
  11064. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11065. }
  11066. break;
  11067. case 10:
  11068. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11069. {
  11070. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11071. }
  11072. break;
  11073. }
  11074. return outStr;
  11075. }
  11076. #region OP行程单
  11077. /// <summary>
  11078. /// OP行程单初始化
  11079. /// </summary>
  11080. /// <param name="dto"></param>
  11081. /// <returns></returns>
  11082. [HttpPost]
  11083. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11084. {
  11085. var jw = JsonView(false);
  11086. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11087. var group = groupList.First();
  11088. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11089. if (group == null)
  11090. {
  11091. jw.Msg = "暂无团组!";
  11092. return Ok(jw);
  11093. }
  11094. group = groupList.Find(x => x.Id == diid);
  11095. if (group == null)
  11096. {
  11097. jw.Msg = "请输入正确的团组ID!";
  11098. return Ok(jw);
  11099. }
  11100. string city = string.Empty;
  11101. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11102. if (blackCode.Count > 0)
  11103. {
  11104. var black = blackCode.First();
  11105. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11106. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11107. if (blackSp.Length > 0)
  11108. {
  11109. try
  11110. {
  11111. var cityArrCode = new List<string>(20);
  11112. foreach (var item in blackSp)
  11113. {
  11114. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11115. var IndexSelect = itemSp[2];
  11116. var cityArrCodeLength = cityArrCode.Count - 1;
  11117. var startCity = IndexSelect.Substring(0, 3);
  11118. if (cityArrCodeLength > 0)
  11119. {
  11120. var arrEndCity = cityArrCode[cityArrCodeLength];
  11121. if (arrEndCity != startCity)
  11122. {
  11123. cityArrCode.Add(startCity.ToUpper());
  11124. }
  11125. }
  11126. else
  11127. {
  11128. cityArrCode.Add(startCity.ToUpper());
  11129. }
  11130. var endCity = IndexSelect.Substring(3, 3);
  11131. cityArrCode.Add(endCity.ToUpper());
  11132. }
  11133. var cityThree = string.Empty;
  11134. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11135. cityThree = cityThree.TrimEnd(',');
  11136. if (string.IsNullOrWhiteSpace(cityThree))
  11137. {
  11138. throw new
  11139. Exception("error");
  11140. }
  11141. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11142. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11143. foreach (var item in cityArrCode)
  11144. {
  11145. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11146. if (find != null)
  11147. {
  11148. city += find.City + "/";
  11149. }
  11150. else
  11151. {
  11152. city += item + "三字码未收入/";
  11153. }
  11154. }
  11155. city = city.TrimEnd('/');
  11156. }
  11157. catch (Exception e)
  11158. {
  11159. city = "黑屏代码格式不正确!";
  11160. }
  11161. }
  11162. }
  11163. else
  11164. {
  11165. city = "未录入黑屏代码";
  11166. }
  11167. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11168. {
  11169. Date = x.Date,
  11170. Days = x.Days,
  11171. Diffgroup = x.Diffgroup,
  11172. Diid = x.Diid,
  11173. Traffic_First = x.Traffic_First,
  11174. Traffic_Second = x.Traffic_Second,
  11175. Trip = x.Trip,
  11176. WeekDay = x.WeekDay,
  11177. Id = x.Id
  11178. }).ToList();
  11179. jw.Data = new
  11180. {
  11181. groupList = groupList.Select(x => new
  11182. {
  11183. x.Id,
  11184. x.TeamName,
  11185. x.TourCode
  11186. }).ToList(),
  11187. groupInfo = new
  11188. {
  11189. group.VisitDays,
  11190. group.TourCode,
  11191. group.VisitPNumber,
  11192. group.TeamName,
  11193. city
  11194. },
  11195. OpTravelList
  11196. };
  11197. jw.Code = 200;
  11198. jw.Msg = "操作成功!";
  11199. return Ok(jw);
  11200. }
  11201. /// <summary>
  11202. /// 删除团组行程单
  11203. /// </summary>
  11204. /// <returns></returns>
  11205. [HttpPost]
  11206. public IActionResult DelTravel(DelOpTravelDto dto)
  11207. {
  11208. var jw = JsonView(false);
  11209. if (dto.UserId <= 0 || dto.Diid <= 0)
  11210. {
  11211. jw.Msg = "请输入正确的参数!";
  11212. return Ok(jw);
  11213. }
  11214. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11215. .SetColumns(x => new Grp_TravelList
  11216. {
  11217. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11218. DeleteUserId = dto.UserId,
  11219. IsDel = 1,
  11220. }).ExecuteCommand();
  11221. jw = JsonView(true);
  11222. return Ok(jw);
  11223. }
  11224. /// <summary>
  11225. /// 行程单保存
  11226. /// </summary>
  11227. /// <returns></returns>
  11228. [HttpPost]
  11229. public IActionResult TravelSave(TravelSaveDto dto)
  11230. {
  11231. var jw = JsonView(false);
  11232. if (dto.Arr.Count > 0)
  11233. {
  11234. try
  11235. {
  11236. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11237. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11238. .ToList();
  11239. _sqlSugar.BeginTran();
  11240. foreach (var item in dto.Arr)
  11241. {
  11242. if (item.Id == 0)
  11243. {
  11244. throw new Exception("请传入正确的Id");
  11245. }
  11246. //比较上一次的差异
  11247. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11248. if (findTravel != null)
  11249. {
  11250. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11251. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11252. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11253. }
  11254. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11255. .SetColumns(x => new Grp_TravelList
  11256. {
  11257. Trip = item.Trip
  11258. }).ExecuteCommand();
  11259. }
  11260. _sqlSugar.CommitTran();
  11261. jw = JsonView(true);
  11262. }
  11263. catch (Exception ex)
  11264. {
  11265. _sqlSugar.RollbackTran();
  11266. jw.Msg = "程序异常!" + ex.Message;
  11267. }
  11268. }
  11269. else
  11270. {
  11271. jw.Msg = "请传入正确的参数!";
  11272. }
  11273. return Ok(jw);
  11274. }
  11275. private string CheckStr(string original, string changed)
  11276. {
  11277. // 创建diff_match_patch对象
  11278. var dmp = new diff_match_patch();
  11279. // 计算差异
  11280. List<Diff> diffs = dmp.diff_main(original, changed);
  11281. // 清理和合并差异
  11282. dmp.diff_cleanupSemantic(diffs);
  11283. // 使用StringBuilder构建最终的字符串
  11284. StringBuilder finalString = new StringBuilder();
  11285. // 输出差异结果,并构建变动后的字符串
  11286. foreach (Diff diff in diffs)
  11287. {
  11288. switch (diff.operation)
  11289. {
  11290. case Operation.EQUAL:
  11291. // 相等的部分,直接添加到最终字符串
  11292. finalString.Append(diff.text);
  11293. break;
  11294. case Operation.INSERT:
  11295. // 插入的部分,添加标记并添加到最终字符串
  11296. finalString.Append("[++]" + diff.text + "[++]");
  11297. break;
  11298. case Operation.DELETE:
  11299. // 删除的部分,不添加到最终字符串
  11300. //finalString.Append("[++]" + diff.text + "[++]");
  11301. break;
  11302. }
  11303. }
  11304. // 输出变动后的字符串
  11305. return finalString.ToString();
  11306. }
  11307. private class tagContent
  11308. {
  11309. public DateTime Date { get; set; }
  11310. public string StartTag { get; set; }
  11311. public string EndTag { get; set; }
  11312. public string Content { get; set; }
  11313. public static int tagLength { get { return 3; } }
  11314. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11315. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11316. public bool IsFinally { get; set; }
  11317. }
  11318. private List<string> ExtractContentBetweenTags(string input, string tag)
  11319. {
  11320. List<string> results = new List<string>();
  11321. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11322. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11323. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11324. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11325. string[] strValueArr = new string[1];
  11326. foreach (System.Text.RegularExpressions.Match match in matches)
  11327. {
  11328. var strValue = match.Groups[1].Value;
  11329. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11330. }
  11331. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11332. return results;
  11333. }
  11334. /// <summary>
  11335. /// 导出行程单
  11336. /// </summary>
  11337. /// <param name="dto"></param>
  11338. /// <returns></returns>
  11339. [HttpPost]
  11340. public IActionResult ExportTravel(ExportTravelDto dto)
  11341. {
  11342. var jw = JsonView(false);
  11343. jw.Data = "";
  11344. int diid = 0;
  11345. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11346. if (Find == null)
  11347. {
  11348. jw.Msg = "请选择正确的团组!";
  11349. return Ok(jw);
  11350. }
  11351. else
  11352. {
  11353. diid = Find.Id;
  11354. }
  11355. //数据源
  11356. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11357. DataTable dtBlack = null;
  11358. try
  11359. {
  11360. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11361. }
  11362. catch (Exception)
  11363. {
  11364. jw.Msg = "机票黑屏代码有误!";
  11365. return Ok(jw);
  11366. }
  11367. string CityStr = string.Empty;
  11368. if (dtBlack.Rows.Count == 0)
  11369. {
  11370. jw.Msg = "机票黑屏代码有误!";
  11371. return Ok(jw);
  11372. }
  11373. else
  11374. {
  11375. foreach (DataRow row in dtBlack.Rows)
  11376. {
  11377. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11378. {
  11379. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11380. return Ok(jw);
  11381. }
  11382. }
  11383. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11384. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11385. }
  11386. // 指定的文字
  11387. var targetTextDic = new Dictionary<string, List<string>>();
  11388. //创建数据源Table
  11389. DataTable dtSource = new DataTable();
  11390. dtSource.Columns.Add("Days", typeof(string));
  11391. dtSource.Columns.Add("Date", typeof(string));
  11392. dtSource.Columns.Add("Week", typeof(string));
  11393. dtSource.Columns.Add("Traffic", typeof(string));
  11394. dtSource.Columns.Add("Trip", typeof(string));
  11395. //获取数据,放到datatable
  11396. foreach (var item in _travelList)
  11397. {
  11398. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11399. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11400. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11401. .Replace("[++]", string.Empty);
  11402. DataRow dr = dtSource.NewRow();
  11403. dr["Days"] = item.Days;
  11404. dr["Date"] = item.Date;
  11405. dr["Week"] = item.WeekDay;
  11406. dr["Traffic"] = item.Traffic_First
  11407. + "\r\n"
  11408. + item.Traffic_Second;
  11409. dr["Trip"] = item.Trip;
  11410. dtSource.Rows.Add(dr);
  11411. }
  11412. Dictionary<string, string> dic = new Dictionary<string, string>();
  11413. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11414. dic.Add("City", CityStr);
  11415. dic.Add("Days", Find.VisitDays.ToString());
  11416. dic.Add("DeleCode", Find.TourCode);
  11417. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11418. //模板路径
  11419. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11420. //载入模板
  11421. Document doc = null;
  11422. DocumentBuilder builder = null;
  11423. try
  11424. {
  11425. //载入模板
  11426. doc = new Document(tempPath);
  11427. builder = new DocumentBuilder(doc);
  11428. }
  11429. catch (Exception)
  11430. {
  11431. jw.Msg = "模板位置不存在!";
  11432. return Ok(jw);
  11433. }
  11434. foreach (var key in dic.Keys)
  11435. {
  11436. Bookmark bookmark = doc.Range.Bookmarks[key];
  11437. if (bookmark != null)
  11438. {
  11439. builder.MoveToBookmark(key);
  11440. builder.Write(dic[key]);
  11441. }
  11442. }
  11443. //获取word里所有表格
  11444. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11445. //获取所填表格的序数
  11446. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11447. try
  11448. {
  11449. //循环赋值
  11450. for (int i = 0; i < dtSource.Rows.Count; i++)
  11451. {
  11452. builder.MoveToCell(0, i + 1, 0, 0);
  11453. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11454. builder.MoveToCell(0, i + 1, 1, 0);
  11455. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11456. builder.MoveToCell(0, i + 1, 2, 0);
  11457. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11458. var trip = dtSource.Rows[i]["Trip"].ToString();
  11459. builder.MoveToCell(0, i + 1, 3, 0);
  11460. builder.Write(trip);
  11461. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11462. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11463. // 获取特定索引的段落
  11464. Paragraph paragraph = (Paragraph)paragraphs[0];
  11465. Run run = paragraph.Runs[0];
  11466. Aspose.Words.Font font = run.Font;
  11467. font.Name = "黑体";
  11468. //设置双休红色
  11469. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11470. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11471. paragraph = (Paragraph)paragraphs[1];
  11472. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11473. {
  11474. run = paragraph.Runs[0];
  11475. font = run.Font;
  11476. font.Color = Color.Red;
  11477. }
  11478. }
  11479. }
  11480. catch (Exception ex)
  11481. {
  11482. }
  11483. //删除多余行
  11484. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11485. {
  11486. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11487. }
  11488. var targetTextList = new List<string>();
  11489. // 遍历文档中的表格
  11490. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11491. {
  11492. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11493. {
  11494. var cellIndex = 0;
  11495. foreach (Cell cell in row.Cells)
  11496. {
  11497. if (cellIndex == 1 && row.Cells.Count == 4)
  11498. {
  11499. foreach (var target in targetTextDic.Keys)
  11500. {
  11501. if (cell.GetText().Contains(target))
  11502. {
  11503. targetTextList = targetTextDic[target];
  11504. break;
  11505. }
  11506. }
  11507. }
  11508. // 遍历单元格中的所有段落
  11509. foreach (Paragraph paragraph in cell.Paragraphs)
  11510. {
  11511. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11512. List<Run> runs = new List<Run>();
  11513. foreach (Run run in paragraph.Runs)
  11514. {
  11515. runs.Add(run);
  11516. }
  11517. foreach (Run run in runs)
  11518. {
  11519. foreach (var targetText in targetTextList)
  11520. {
  11521. // 检查文字是否包含指定文字
  11522. if (run.Text.Contains(targetText))
  11523. {
  11524. // 将包含的部分设置为红色
  11525. HighlightText(run, targetText, Color.Red);
  11526. }
  11527. }
  11528. }
  11529. }
  11530. cellIndex++;
  11531. }
  11532. }
  11533. }
  11534. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11535. if (!Directory.Exists(savePath))
  11536. {
  11537. try
  11538. {
  11539. Directory.CreateDirectory(savePath);
  11540. }
  11541. catch
  11542. {
  11543. }
  11544. }
  11545. string path = savePath + Find.TeamName + "出访日程";
  11546. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11547. try
  11548. {
  11549. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11550. string postfix = ".docx";
  11551. if (dto.IsPDF == 1)
  11552. {
  11553. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11554. postfix = ".pdf";
  11555. }
  11556. doc.Save(path + postfix, saveFormat);
  11557. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11558. }
  11559. catch (Exception)
  11560. {
  11561. jw = JsonView(false);
  11562. }
  11563. return Ok(jw);
  11564. }
  11565. /// <summary>
  11566. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11567. /// </summary>
  11568. /// <param name="num"></param>
  11569. /// <returns></returns>
  11570. string GetNum(string num)
  11571. {
  11572. string str = "";
  11573. switch (num)
  11574. {
  11575. case "1":
  11576. str = "一";
  11577. break;
  11578. case "2":
  11579. str = "二";
  11580. break;
  11581. case "3":
  11582. str = "三";
  11583. break;
  11584. case "4":
  11585. str = "四";
  11586. break;
  11587. case "5":
  11588. str = "五";
  11589. break;
  11590. case "6":
  11591. str = "六";
  11592. break;
  11593. case "7":
  11594. str = "七";
  11595. break;
  11596. case "8":
  11597. str = "八";
  11598. break;
  11599. case "9":
  11600. str = "九";
  11601. break;
  11602. case "10":
  11603. str = "十";
  11604. break;
  11605. case "11":
  11606. str = "十一";
  11607. break;
  11608. case "12":
  11609. str = "十二";
  11610. break;
  11611. case "一":
  11612. str = "1";
  11613. break;
  11614. case "二":
  11615. str = "2";
  11616. break;
  11617. case "三":
  11618. str = "3";
  11619. break;
  11620. case "四":
  11621. str = "4";
  11622. break;
  11623. case "五":
  11624. str = "5";
  11625. break;
  11626. case "六":
  11627. str = "6";
  11628. break;
  11629. case "七":
  11630. str = "7";
  11631. break;
  11632. case "八":
  11633. str = "8";
  11634. break;
  11635. case "九":
  11636. str = "9";
  11637. break;
  11638. case "十":
  11639. str = "10";
  11640. break;
  11641. case "十一":
  11642. str = "11";
  11643. break;
  11644. case "十二":
  11645. str = "12";
  11646. break;
  11647. }
  11648. return str;
  11649. }
  11650. // 高亮包含指定文字的部分
  11651. void HighlightText(Run run, string targetText, Color color)
  11652. {
  11653. string text = run.Text;
  11654. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11655. if (startIndex >= 0)
  11656. {
  11657. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11658. // 前部分
  11659. if (startIndex > 0)
  11660. {
  11661. Run beforeRun = (Run)run.Clone(true);
  11662. beforeRun.Text = text.Substring(0, startIndex);
  11663. parentParagraph.InsertBefore(beforeRun, run);
  11664. }
  11665. // 匹配部分
  11666. Run matchRun = (Run)run.Clone(true);
  11667. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11668. matchRun.Font.Color = color;
  11669. parentParagraph.InsertBefore(matchRun, run);
  11670. // 后部分
  11671. if (startIndex + targetText.Length < text.Length)
  11672. {
  11673. Run afterRun = (Run)run.Clone(true);
  11674. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11675. parentParagraph.InsertBefore(afterRun, run);
  11676. }
  11677. // 删除原始Run
  11678. run.Remove();
  11679. }
  11680. }
  11681. #endregion
  11682. #endregion
  11683. #region 团组成本
  11684. /// <summary>
  11685. /// 团组成本数据初始化
  11686. /// </summary>
  11687. /// <param name="dto"></param>
  11688. /// <returns></returns>
  11689. [HttpPost]
  11690. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11691. {
  11692. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11693. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11694. WHEN COUNT(*) >= 0 THEN 'True'
  11695. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11696. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11697. ").ToList(); //团组列表
  11698. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11699. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11700. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11701. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11702. if (groupinfoValue != null)
  11703. {
  11704. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11705. var spArr = new string[1] { countryArr };
  11706. if (countryArr.Contains("|"))
  11707. {
  11708. spArr = countryArr.Split("|");
  11709. }
  11710. else if (countryArr.Contains("、"))
  11711. {
  11712. spArr = countryArr.Split("、");
  11713. }
  11714. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11715. {
  11716. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11717. if (dbQueryCountry != null)
  11718. {
  11719. visaCountryInfoArr.Add(dbQueryCountry);
  11720. }
  11721. }
  11722. }
  11723. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11724. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11725. var create = _GroupCostRepository.
  11726. CreateGroupCostByBlackCode(dto.Diid);
  11727. if (groupCost.Count == 0 && create.Code == 0)
  11728. {
  11729. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11730. }
  11731. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11732. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11733. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11734. groupCostMap = groupCostMap.Select(x =>
  11735. {
  11736. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11737. {
  11738. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11739. }
  11740. return x;
  11741. }).ToList();
  11742. //GroupCostParameter.Add(new
  11743. // Grp_GroupCostParameter());
  11744. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11745. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11746. return Ok(JsonView(new
  11747. {
  11748. groupList,
  11749. groupInfo,
  11750. groupChecks,
  11751. groupCost = groupCostMap,
  11752. hotelNumber,
  11753. GroupCostParameter = GroupCostParameterMap,
  11754. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11755. {
  11756. x.VisaCountry,
  11757. x.VisaPrice,
  11758. x.Id,
  11759. }).ToList(),
  11760. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11761. blackCodeIsTrue = create.Code == 0 ? true : false,
  11762. hotelIsTrue = hotelIsTrue,
  11763. }));
  11764. }
  11765. /// <summary>
  11766. /// 团组成本信息保存
  11767. /// </summary>
  11768. /// <param name="dto"></param>
  11769. /// <returns></returns>
  11770. [HttpPost]
  11771. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11772. {
  11773. if (dto.Diid <= 0 || dto.Userid <= 0)
  11774. {
  11775. return Ok(JsonView(false));
  11776. }
  11777. JsonView jw = null;
  11778. bool isTrue = false;
  11779. #region 复制团组成本
  11780. //if (dto.Diid == 2581)
  11781. //{
  11782. // dto.Diid = 2599;
  11783. // dto.CheckBoxs.ForEach(x =>
  11784. // {
  11785. // x.Diid = 2599;
  11786. // });
  11787. // dto.GroupCosts.ForEach(x =>
  11788. // {
  11789. // x.Diid = 2599;
  11790. // });
  11791. // dto.CostTypeHotelNumbers.ForEach(x =>
  11792. // {
  11793. // x.Diid = 2599;
  11794. // });
  11795. // dto.GroupCostParameters.ForEach(x =>
  11796. // {
  11797. // x.DiId = 2599;
  11798. // });
  11799. //}
  11800. #endregion
  11801. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11802. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11803. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11804. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11805. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11806. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11807. try
  11808. {
  11809. _sqlSugar.BeginTran();
  11810. isTrue = await _GroupCostRepository.
  11811. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11812. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11813. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11814. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11815. _sqlSugar.CommitTran();
  11816. jw = JsonView(true, "保存成功!", isTrue);
  11817. }
  11818. catch (Exception)
  11819. {
  11820. _sqlSugar.RollbackTran();
  11821. jw = JsonView(false);
  11822. }
  11823. return Ok(jw);
  11824. }
  11825. /// <summary>
  11826. /// 司兼导数据
  11827. /// </summary>
  11828. /// <param name="dto"></param>
  11829. /// <returns></returns>
  11830. [HttpPost]
  11831. public IActionResult GetCarGuides(CarGuidesDto dto)
  11832. {
  11833. JsonView jw = null;
  11834. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11835. jw = JsonView(true, "获取成功!", Data);
  11836. return Ok(jw);
  11837. }
  11838. /// <summary>
  11839. /// 导游数据
  11840. /// </summary>
  11841. /// <param name="dto"></param>
  11842. /// <returns></returns>
  11843. [HttpPost]
  11844. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11845. {
  11846. JsonView jw = null;
  11847. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11848. // 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
  11849. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11850. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11851. jw = JsonView(true, "获取成功!", Data);
  11852. return Ok(jw);
  11853. }
  11854. /// <summary>
  11855. /// 成本车数据
  11856. /// </summary>
  11857. /// <param name="dto"></param>
  11858. /// <returns></returns>
  11859. [HttpPost]
  11860. public IActionResult GetCarInfo(CarGuidesDto dto)
  11861. {
  11862. JsonView jw = null;
  11863. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11864. jw = JsonView(true, "获取成功!", Data);
  11865. return Ok(jw);
  11866. }
  11867. /// <summary>
  11868. /// 景点数据
  11869. /// </summary>
  11870. /// <param name="dto"></param>
  11871. /// <returns></returns>
  11872. [HttpPost]
  11873. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11874. {
  11875. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11876. return Ok(JsonView(true, "获取成功!", Data));
  11877. }
  11878. /// <summary>
  11879. /// 成本通知
  11880. /// </summary>
  11881. /// <param name="dto"></param>
  11882. /// <returns></returns>
  11883. [HttpPost]
  11884. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11885. {
  11886. if (dto.Diid < 0)
  11887. {
  11888. return Ok(JsonView(false));
  11889. }
  11890. JsonView jw = null;
  11891. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11892. if (GroupCostParameter != null)
  11893. {
  11894. int IsShare = 0;
  11895. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11896. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11897. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11898. string msg = string.Empty;
  11899. if (isTrue)
  11900. {
  11901. if (IsShare == 0)
  11902. {
  11903. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11904. }
  11905. else
  11906. {
  11907. #region 企微通知对应岗位用户
  11908. try
  11909. {
  11910. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11911. }
  11912. catch (Exception ex)
  11913. {
  11914. }
  11915. #endregion
  11916. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11917. }
  11918. jw = JsonView(isTrue, msg, new { IsShare });
  11919. }
  11920. else
  11921. {
  11922. msg = "修改失败!";
  11923. jw = JsonView(isTrue, msg);
  11924. }
  11925. }
  11926. else
  11927. {
  11928. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11929. }
  11930. return Ok(jw);
  11931. }
  11932. /// <summary>
  11933. /// 导出报价单
  11934. /// </summary>
  11935. /// <param name="dto"></param>
  11936. /// <returns></returns>
  11937. [HttpPost]
  11938. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11939. {
  11940. if (dto.Diid == 0)
  11941. {
  11942. return Ok(JsonView(false, "请传递团组id"));
  11943. }
  11944. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11945. if (deleInfo.Code != 0)
  11946. {
  11947. return Ok(JsonView(false, "团组信息查询失败!"));
  11948. }
  11949. var di = deleInfo.Data as DelegationInfoWebView;
  11950. if (di != null)
  11951. {
  11952. di.TeamName = di.TeamName.Replace("|", "、");
  11953. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11954. //文件名
  11955. string strFileName = di.TeamName + "-收款账单.doc";
  11956. //获取模板
  11957. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11958. //载入模板
  11959. Document doc = new Document(tmppath);
  11960. decimal TotalPrice = 0.00M;
  11961. string itemStr = string.Empty;
  11962. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11963. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11964. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11965. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11966. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11967. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11968. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11969. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11970. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11971. foreach (var cost in groupCostType)
  11972. {
  11973. var List = cost.ToList();
  11974. if (cost.Key == "A")
  11975. {
  11976. foreach (var ListItem in List)
  11977. {
  11978. if (ListItem.number > 0)
  11979. {
  11980. if (ListItem.code.Contains("TBR"))
  11981. {
  11982. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11983. }
  11984. else
  11985. {
  11986. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11987. }
  11988. TotalPrice += (ListItem.number * ListItem.price);
  11989. }
  11990. }
  11991. }
  11992. else
  11993. {
  11994. itemStr = itemStr.Insert(0, "A段\r\n");
  11995. itemStr += "B段\r\n";
  11996. foreach (var ListItem in List)
  11997. {
  11998. if (ListItem.number > 0)
  11999. {
  12000. if (ListItem.code.Contains("TBR"))
  12001. {
  12002. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12003. }
  12004. else
  12005. {
  12006. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12007. }
  12008. TotalPrice += (ListItem.number * ListItem.price);
  12009. }
  12010. }
  12011. }
  12012. }
  12013. #region 替换Word模板书签内容
  12014. Dictionary<string, string> marks = new Dictionary<string, string>();
  12015. marks.Add("To", di.ClientUnit);//付款方
  12016. marks.Add("ToTel", di.TellPhone);//付款方电话
  12017. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12018. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12019. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12020. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12021. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12022. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12023. marks.Add("PayItemContent", itemStr);//详细信息
  12024. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12025. #endregion
  12026. ////注
  12027. //if (doc.Range.Bookmarks["Attention"] != null)
  12028. //{
  12029. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12030. // mark.Text = frList[0].Attention;
  12031. //}
  12032. foreach (var item in marks.Keys)
  12033. {
  12034. if (doc.Range.Bookmarks[item] != null)
  12035. {
  12036. Bookmark mark = doc.Range.Bookmarks[item];
  12037. mark.Text = marks[item];
  12038. }
  12039. }
  12040. byte[] bytes = null;
  12041. using (MemoryStream stream = new MemoryStream())
  12042. {
  12043. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12044. bytes = stream.ToArray();
  12045. }
  12046. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12047. return Ok(JsonView(true, "", new
  12048. {
  12049. Data = bytes,
  12050. strFileName,
  12051. }));
  12052. }
  12053. else
  12054. {
  12055. return Ok(JsonView(false, "团组信息不存在!"));
  12056. }
  12057. }
  12058. /// <summary>
  12059. /// 导出团组成本
  12060. /// </summary>
  12061. /// <param name="dto"></param>
  12062. /// <returns></returns>
  12063. [HttpPost]
  12064. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12065. {
  12066. var jw = JsonView(false);
  12067. if (dto.Diid == 0)
  12068. {
  12069. return Ok(JsonView(false, "请传递团组id"));
  12070. }
  12071. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12072. if (deleInfo.Code != 0)
  12073. {
  12074. return Ok(JsonView(false, "团组信息查询失败!"));
  12075. }
  12076. var di = deleInfo.Data as DelegationInfoWebView;
  12077. if (di == null)
  12078. {
  12079. return Ok(JsonView(false, "团组信息查询失败!"));
  12080. }
  12081. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12082. WorkbookDesigner designer = new WorkbookDesigner();
  12083. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12084. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12085. for (int i = 0; i < List_GC.Count; i++)
  12086. {
  12087. GroupCost_Excel gc = new GroupCost_Excel();
  12088. gc.Id = List_GC[i].Id;
  12089. gc.Diid = List_GC[i].Diid.ToString();
  12090. gc.DAY = List_GC[i].DAY;
  12091. string week = "";
  12092. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12093. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12094. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12095. gc.ITIN = List_GC[i].ITIN;
  12096. gc.CarType = List_GC[i].CarType;
  12097. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12098. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12099. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12100. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12101. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12102. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12103. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12104. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12105. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12106. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12107. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12108. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12109. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12110. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12111. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12112. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12113. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12114. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12115. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12116. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12117. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12118. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12119. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12120. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12121. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12122. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12123. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12124. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12125. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12126. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12127. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12128. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12129. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12130. List_GC1.Add(gc);
  12131. }
  12132. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12133. dt.TableName = "TB";
  12134. //报表标题等不用dt的值
  12135. designer.SetDataSource("TeamName", dto.title.TeamName);
  12136. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12137. designer.SetDataSource("Tax", dto.title.Tax);
  12138. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12139. designer.SetDataSource("Currency", dto.title.Currency);
  12140. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12141. designer.SetDataSource("Rate", dto.title.Rate);
  12142. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12143. var Aparams = hotels.Find(x => x.Type == "Default");
  12144. if (Aparams == null)
  12145. {
  12146. return Ok(jw);
  12147. }
  12148. //酒店数量
  12149. var txtSGRNumber = Aparams.SGR.ToString();
  12150. var txtTBRNumber = Aparams.TBR.ToString();
  12151. var txtJSESNumber = Aparams.JSES.ToString();
  12152. var txtSUITENumbe = Aparams.SUITE.ToString();
  12153. if (dto.costType == "B")
  12154. {
  12155. Aparams = hotels.Find(x => x.Type == "A");
  12156. var Bparams = hotels.Find(x => x.Type == "B");
  12157. if (Aparams == null || Bparams == null)
  12158. {
  12159. return Ok(jw);
  12160. }
  12161. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12162. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12163. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12164. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12165. }
  12166. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12167. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12168. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12169. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12170. var ws = designer.Workbook.Worksheets[0];
  12171. int Row = List_GC.Count;
  12172. int startIndex = 11;
  12173. int HideRows = 0;
  12174. List<int> hideRowsList = new List<int>();
  12175. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12176. #region A段left数据
  12177. var left = dto.leftInfo.Find(x => x.Type == "A");
  12178. if (left == null)
  12179. {
  12180. return Ok(jw);
  12181. }
  12182. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12183. if (leftBindData != null)
  12184. {
  12185. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12186. designer.SetDataSource("VisaRS", leftBindData.rs);
  12187. designer.SetDataSource("VisaXS", leftBindData.xs);
  12188. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12189. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12190. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12191. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12192. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12193. }
  12194. else
  12195. {
  12196. hideRowsList.Add(Row + startIndex + HideRows);
  12197. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12198. }
  12199. HideRows += 2;
  12200. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12201. if (leftBindData != null)
  12202. {
  12203. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12204. designer.SetDataSource("BXRS", leftBindData.rs);
  12205. designer.SetDataSource("BXXS", leftBindData.xs);
  12206. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12207. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12208. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12209. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12210. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12211. }
  12212. else
  12213. {
  12214. hideRowsList.Add(Row + startIndex + HideRows);
  12215. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12216. }
  12217. HideRows += 2;
  12218. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12219. if (leftBindData != null)
  12220. {
  12221. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12222. designer.SetDataSource("HSRS", leftBindData.rs);
  12223. designer.SetDataSource("HSXS", leftBindData.xs);
  12224. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12225. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12226. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12227. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12228. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12229. }
  12230. else
  12231. {
  12232. hideRowsList.Add(Row + startIndex + HideRows);
  12233. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12234. }
  12235. HideRows += 2;
  12236. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12237. if (leftBindData != null)
  12238. {
  12239. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12240. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12241. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12242. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12243. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12244. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12245. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12246. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12247. }
  12248. else
  12249. {
  12250. hideRowsList.Add(Row + startIndex + HideRows);
  12251. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12252. }
  12253. HideRows += 2;
  12254. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12255. if (leftBindData != null)
  12256. {
  12257. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12258. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12259. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12260. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12261. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12262. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12263. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12264. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12265. }
  12266. else
  12267. {
  12268. hideRowsList.Add(Row + startIndex + HideRows);
  12269. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12270. }
  12271. HideRows += 2;
  12272. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12273. if (leftBindData != null)
  12274. {
  12275. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12276. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12277. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12278. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12279. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12280. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12281. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12282. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12283. }
  12284. else
  12285. {
  12286. hideRowsList.Add(Row + startIndex + HideRows);
  12287. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12288. }
  12289. HideRows += 2;
  12290. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12291. if (leftBindData != null)
  12292. {
  12293. ////TBR
  12294. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12295. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12296. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12297. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12298. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12299. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12300. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12301. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12302. }
  12303. else
  12304. {
  12305. hideRowsList.Add(Row + startIndex + HideRows);
  12306. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12307. }
  12308. HideRows += 2;
  12309. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12310. if (leftBindData != null)
  12311. {
  12312. ////SGR
  12313. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12314. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12315. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12316. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12317. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12318. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12319. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12320. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12321. }
  12322. else
  12323. {
  12324. hideRowsList.Add(Row + startIndex + HideRows);
  12325. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12326. }
  12327. HideRows += 2;
  12328. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12329. if (leftBindData != null)
  12330. {
  12331. ////JS/ES
  12332. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12333. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12334. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12335. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12336. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12337. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12338. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12339. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12340. }
  12341. else
  12342. {
  12343. hideRowsList.Add(Row + startIndex + HideRows);
  12344. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12345. }
  12346. HideRows += 2;
  12347. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12348. if (leftBindData != null)
  12349. {
  12350. ////SUITE
  12351. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12352. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12353. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12354. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12355. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12356. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12357. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12358. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12359. }
  12360. else
  12361. {
  12362. hideRowsList.Add(Row + startIndex + HideRows);
  12363. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12364. }
  12365. HideRows += 2;
  12366. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12367. if (leftBindData != null)
  12368. {
  12369. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12370. designer.SetDataSource("DJRS", leftBindData.rs);
  12371. designer.SetDataSource("DJXS", leftBindData.xs);
  12372. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12373. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12374. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12375. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12376. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12377. }
  12378. else
  12379. {
  12380. hideRowsList.Add(Row + startIndex + HideRows);
  12381. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12382. }
  12383. HideRows += 2;
  12384. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12385. if (leftBindData != null)
  12386. {
  12387. designer.SetDataSource("HCPCB", leftBindData.cb);
  12388. designer.SetDataSource("HCPRS", leftBindData.rs);
  12389. designer.SetDataSource("HCPXS", leftBindData.xs);
  12390. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12391. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12392. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12393. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12394. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12395. }
  12396. else
  12397. {
  12398. hideRowsList.Add(Row + startIndex + HideRows);
  12399. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12400. }
  12401. HideRows += 2;
  12402. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12403. if (leftBindData != null)
  12404. {
  12405. designer.SetDataSource("CPCB", leftBindData.cb);
  12406. designer.SetDataSource("CPRS", leftBindData.rs);
  12407. designer.SetDataSource("CPXS", leftBindData.xs);
  12408. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12409. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12410. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12411. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12412. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12413. }
  12414. else
  12415. {
  12416. hideRowsList.Add(Row + startIndex + HideRows);
  12417. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12418. }
  12419. HideRows += 2;
  12420. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12421. if (leftBindData != null)
  12422. {
  12423. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12424. designer.SetDataSource("GWRS", leftBindData.rs);
  12425. designer.SetDataSource("GWXS", leftBindData.xs);
  12426. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12427. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12428. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12429. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12430. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12431. }
  12432. else
  12433. {
  12434. hideRowsList.Add(Row + startIndex + HideRows);
  12435. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12436. }
  12437. HideRows += 2;
  12438. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12439. if (leftBindData != null)
  12440. {
  12441. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12442. designer.SetDataSource("LYJRS", leftBindData.rs);
  12443. designer.SetDataSource("LYJXS", leftBindData.xs);
  12444. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12445. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12446. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12447. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12448. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12449. }
  12450. else
  12451. {
  12452. hideRowsList.Add(Row + startIndex + HideRows);
  12453. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12454. }
  12455. #endregion
  12456. #region A段Right信息
  12457. var right = dto.rightInfo.Find(x => x.Type == "A");
  12458. if (right == null)
  12459. {
  12460. return Ok(jw);
  12461. }
  12462. HideRows += 4;
  12463. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12464. if (rightBindData != null)
  12465. {
  12466. //经济舱 + 双人间 TBR
  12467. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12468. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12469. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12470. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12471. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12472. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12473. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12474. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12475. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12476. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12477. }
  12478. else
  12479. {
  12480. hideRowsList.Add(Row + startIndex + HideRows);
  12481. }
  12482. HideRows += 2;
  12483. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12484. if (rightBindData != null)
  12485. {
  12486. //经济舱 + 单人间 SGR
  12487. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12488. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12489. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12490. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12491. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12492. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12493. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12494. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12495. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12496. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12497. }
  12498. else
  12499. {
  12500. hideRowsList.Add(Row + startIndex + HideRows);
  12501. }
  12502. HideRows += 2;
  12503. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12504. if (rightBindData != null)
  12505. {
  12506. //公务舱 + 单人间 SGR
  12507. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12508. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12509. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12510. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12511. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12512. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12513. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12514. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12515. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12516. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12517. }
  12518. else
  12519. {
  12520. hideRowsList.Add(Row + startIndex + HideRows);
  12521. }
  12522. HideRows += 2;
  12523. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12524. if (rightBindData != null)
  12525. {
  12526. //公务舱 + 小套房 JSES
  12527. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12528. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12529. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12530. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12531. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12532. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12533. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12534. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12535. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12536. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12537. }
  12538. else
  12539. {
  12540. hideRowsList.Add(Row + startIndex + HideRows);
  12541. }
  12542. HideRows += 2;
  12543. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12544. if (rightBindData != null)
  12545. {
  12546. //公务舱 + 小套房 JSES
  12547. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12548. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12549. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12550. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12551. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12552. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12553. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12554. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12555. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12556. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12557. }
  12558. else
  12559. {
  12560. hideRowsList.Add(Row + startIndex + HideRows);
  12561. }
  12562. HideRows += 2;
  12563. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12564. if (rightBindData != null)
  12565. {
  12566. //经济舱 + 大套房
  12567. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12568. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12569. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12570. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12571. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12572. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12573. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12574. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12575. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12576. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12577. }
  12578. else
  12579. {
  12580. hideRowsList.Add(Row + startIndex + HideRows);
  12581. }
  12582. HideRows += 2;
  12583. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12584. if (rightBindData != null)
  12585. {
  12586. //头等舱 + 小套房 JSES
  12587. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12588. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12589. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12590. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12591. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12592. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12593. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12594. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12595. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12596. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12597. }
  12598. else
  12599. {
  12600. hideRowsList.Add(Row + startIndex + HideRows);
  12601. }
  12602. HideRows += 2;
  12603. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12604. if (rightBindData != null)
  12605. {
  12606. //头等舱 + 大套房
  12607. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12608. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12609. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12610. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12611. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12612. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12613. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12614. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12615. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12616. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12617. }
  12618. else
  12619. {
  12620. hideRowsList.Add(Row + startIndex + HideRows);
  12621. }
  12622. #endregion
  12623. #region B段标题清空
  12624. designer.SetDataSource("CostBDRCB", "");
  12625. designer.SetDataSource("CostBRS", "");
  12626. designer.SetDataSource("CostBXS", "");
  12627. designer.SetDataSource("CostBZCB", "");
  12628. designer.SetDataSource("CostBDRBJ", "");
  12629. designer.SetDataSource("CostBZBJ", "");
  12630. designer.SetDataSource("CostBDRLR", "");
  12631. designer.SetDataSource("CostBZLR", "");
  12632. designer.SetDataSource("CostBDRCBOM", "");
  12633. designer.SetDataSource("CostBRSOM", "");
  12634. designer.SetDataSource("CostBZCBOM", "");
  12635. designer.SetDataSource("CostBDRBJOM", "");
  12636. designer.SetDataSource("CostBZBJOM", "");
  12637. designer.SetDataSource("CostBDRLROM", "");
  12638. designer.SetDataSource("CostBZLROM", "");
  12639. #endregion
  12640. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12641. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12642. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12643. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12644. designer.SetDataSource("DJName", "地接(CNY)");
  12645. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12646. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12647. designer.SetDataSource("GWName", "公务(CNY)");
  12648. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12649. designer.SetDataSource("LYJName", "零用金(CNY)");
  12650. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12651. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12652. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12653. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12654. designer.SetDataSource("BXName", "保险(CNY)");
  12655. designer.SetDataSource("VisaName", "签证(CNY)");
  12656. #region B段基本数据
  12657. if (dto.costType == "B")
  12658. {
  12659. left = dto.leftInfo.Find(x => x.Type == "B");
  12660. if (left == null)
  12661. {
  12662. return Ok(jw);
  12663. }
  12664. #region B段left数据
  12665. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12666. if (leftBindData != null)
  12667. {
  12668. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12669. designer.SetDataSource("BHSRS", leftBindData.rs);
  12670. designer.SetDataSource("BHSXS", leftBindData.xs);
  12671. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12672. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12673. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12674. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12675. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12676. }
  12677. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12678. if (leftBindData != null)
  12679. {
  12680. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12681. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12682. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12683. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12684. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12685. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12686. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12687. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12688. }
  12689. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12690. if (leftBindData != null)
  12691. {
  12692. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12693. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12694. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12695. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12696. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12697. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12698. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12699. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12700. }
  12701. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12702. if (leftBindData != null)
  12703. {
  12704. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12705. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12706. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12707. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12708. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12709. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12710. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12711. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12712. }
  12713. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12714. if (leftBindData != null)
  12715. {
  12716. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12717. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12718. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12719. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12720. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12721. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12722. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12723. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12724. }
  12725. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12726. if (leftBindData != null)
  12727. {
  12728. designer.SetDataSource("BCPCB", leftBindData.cb);
  12729. designer.SetDataSource("BCPRS", leftBindData.rs);
  12730. designer.SetDataSource("BCPXS", leftBindData.xs);
  12731. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12732. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12733. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12734. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12735. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12736. }
  12737. //TBR
  12738. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12739. if (leftBindData != null)
  12740. {
  12741. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12742. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12743. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12744. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12745. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12746. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12747. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12748. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12749. }
  12750. //SGR
  12751. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12752. if (leftBindData != null)
  12753. {
  12754. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12755. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12756. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12757. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12758. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12759. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12760. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12761. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12762. }
  12763. //JS/ES
  12764. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12765. if (leftBindData != null)
  12766. {
  12767. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12768. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12769. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12770. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12771. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12772. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12773. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12774. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12775. }
  12776. //SUITE
  12777. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12778. if (leftBindData != null)
  12779. {
  12780. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12781. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12782. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12783. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12784. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12785. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12786. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12787. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12788. }
  12789. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12790. if (leftBindData != null)
  12791. {
  12792. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12793. designer.SetDataSource("BDJRS", leftBindData.rs);
  12794. designer.SetDataSource("BDJXS", leftBindData.xs);
  12795. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12796. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12797. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12798. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12799. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12800. }
  12801. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12802. if (leftBindData != null)
  12803. {
  12804. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12805. designer.SetDataSource("BGWRS", leftBindData.rs);
  12806. designer.SetDataSource("BGWXS", leftBindData.xs);
  12807. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12808. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12809. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12811. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12812. }
  12813. #region 优化方案
  12814. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12815. //excelBind.Add("零用金", new {
  12816. //cb="",
  12817. //rs="",
  12818. //xs ="",
  12819. //zcb = "",
  12820. //});
  12821. #endregion
  12822. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12823. if (leftBindData != null)
  12824. {
  12825. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12826. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12827. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12828. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12829. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12830. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12831. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12832. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12833. }
  12834. #endregion
  12835. #region B段Right信息
  12836. right = dto.rightInfo.Find(x => x.Type == "B");
  12837. if (right == null)
  12838. {
  12839. return Ok(jw);
  12840. }
  12841. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12842. if (rightBindData != null)
  12843. {
  12844. //经济舱 + 双人间 TBR
  12845. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12846. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12847. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12848. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12849. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12850. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12851. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12852. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12853. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12854. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12855. }
  12856. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12857. if (rightBindData != null)
  12858. {
  12859. //经济舱 + 单人间 SGR
  12860. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12861. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12862. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12863. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12864. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12865. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12866. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12867. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12868. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12869. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12870. }
  12871. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12872. if (rightBindData != null)
  12873. {
  12874. //公务舱 + 单人间 SGR
  12875. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12876. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12877. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12878. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12879. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12880. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12881. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12882. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12883. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12884. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12885. }
  12886. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12887. if (rightBindData != null)
  12888. {
  12889. //公务舱 + 小套房 JSES
  12890. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12891. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12892. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12893. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12894. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12895. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12896. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12897. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12898. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12899. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12900. }
  12901. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12902. if (rightBindData != null)
  12903. {
  12904. //公务舱 + 小套房 JSES
  12905. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12906. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12907. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12908. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12909. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12910. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12911. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12912. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12913. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12914. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12915. }
  12916. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12917. if (rightBindData != null)
  12918. {
  12919. //经济舱 + 大套房
  12920. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12921. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12922. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12923. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12924. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12925. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12926. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12927. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12928. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12929. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12930. }
  12931. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12932. if (rightBindData != null)
  12933. {
  12934. //头等舱 + 小套房 JSES
  12935. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12936. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12937. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12938. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12939. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12940. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12941. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12942. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12943. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12944. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12945. }
  12946. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12947. if (rightBindData != null)
  12948. {
  12949. //头等舱 + 大套房
  12950. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12951. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12952. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12953. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12954. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12955. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12956. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12957. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12958. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12959. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12960. }
  12961. #endregion
  12962. #region 标题
  12963. designer.SetDataSource("CostBDRCB", "单人成本");
  12964. designer.SetDataSource("CostBRS", "人数");
  12965. designer.SetDataSource("CostBXS", "系数");
  12966. designer.SetDataSource("CostBZCB", "总成本");
  12967. designer.SetDataSource("CostBDRBJ", "单人报价");
  12968. designer.SetDataSource("CostBZBJ", "总报价");
  12969. designer.SetDataSource("CostBDRLR", "单人利润");
  12970. designer.SetDataSource("CostBZLR", "总利润");
  12971. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12972. designer.SetDataSource("CostBRSOM", "人数");
  12973. designer.SetDataSource("CostBZCBOM", "总成本");
  12974. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12975. designer.SetDataSource("CostBZBJOM", "总报价");
  12976. designer.SetDataSource("CostBDRLROM", "单人利润");
  12977. designer.SetDataSource("CostBZLROM", "总利润");
  12978. #endregion
  12979. }
  12980. #endregion
  12981. designer.SetDataSource("TzZCB2", TzZCB2);
  12982. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12983. designer.SetDataSource("TzZLR2", TzZLR2);
  12984. string[] dataSourceKeys = new string[]
  12985. {
  12986. "VF",
  12987. "TGS",
  12988. "TGOF",
  12989. "TGM",
  12990. "TGA",
  12991. "TGTF",
  12992. "TGEF",
  12993. "CFM",
  12994. "CFOF",
  12995. "B",
  12996. "L",
  12997. "D",
  12998. "TBR",
  12999. "SGR",
  13000. "JSES",
  13001. "Suite",
  13002. "TV",
  13003. "1L",
  13004. "IF",
  13005. "EF",
  13006. "BRF",
  13007. "TE",
  13008. "TGT",
  13009. "DRVT",
  13010. "PC",
  13011. "TLF",
  13012. "ECT"
  13013. };
  13014. foreach (var item in dataSourceKeys)
  13015. {
  13016. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13017. if (find != null)
  13018. {
  13019. designer.SetDataSource(item, find.text);
  13020. }
  13021. else
  13022. {
  13023. designer.SetDataSource(item, 0);
  13024. }
  13025. }
  13026. designer.SetDataSource(dt);
  13027. //根据数据源处理生成报表内容
  13028. designer.Process();
  13029. designer.Workbook.Worksheets[0].Name = "清单";
  13030. Worksheet sheet = designer.Workbook.Worksheets[0];
  13031. foreach (var Rowindex in hideRowsList)
  13032. {
  13033. ws.Cells.HideRows(Rowindex, 2);
  13034. }
  13035. byte[] bytes = null;
  13036. string strFileName = di.TeamName + "-团组-成本.xls";
  13037. using (MemoryStream stream = new MemoryStream())
  13038. {
  13039. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13040. bytes = stream.ToArray();
  13041. }
  13042. return Ok(JsonView(true, "", new
  13043. {
  13044. Data = bytes,
  13045. strFileName,
  13046. }));
  13047. }
  13048. /// <summary>
  13049. /// 导出客户报表
  13050. /// </summary>
  13051. /// <returns></returns>
  13052. [HttpPost]
  13053. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13054. {
  13055. var jw = JsonView(false);
  13056. if (dto.Diid == 0)
  13057. {
  13058. return Ok(JsonView(false, "请传递团组id"));
  13059. }
  13060. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13061. if (deleInfo.Code != 0)
  13062. {
  13063. return Ok(JsonView(false, "团组信息查询失败!"));
  13064. }
  13065. var di = deleInfo.Data as DelegationInfoWebView;
  13066. if (di == null)
  13067. {
  13068. return Ok(JsonView(false, "团组信息查询失败!"));
  13069. }
  13070. //文件名
  13071. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13072. //获取模板
  13073. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13074. //载入模板
  13075. Document doc = new Document(tmppath);
  13076. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13077. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13078. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13079. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13080. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13081. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13082. if (AParameter == null)
  13083. {
  13084. return Ok(JsonView(false, "系数不存在!"));
  13085. }
  13086. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13087. , TzAirDesc, TzZCost;
  13088. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13089. = TzAirDesc = TzZCost = string.Empty;
  13090. TzNumber = AParameter.CostTypenumber.ToString();
  13091. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13092. CarGuides1 = dto.CarGuides1;
  13093. Meal = dto.Meal;
  13094. SubsidizedMeals = dto.SubsidizedMeals;
  13095. NightRepair = dto.NightRepair;
  13096. AttractionsTickets = dto.AttractionsTickets;
  13097. MiscellaneousFees = dto.MiscellaneousFees;
  13098. ATip = dto.ATip;
  13099. TzHotelDesc = "";
  13100. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13101. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13102. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13103. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13104. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13105. TzAirDesc = "";
  13106. TzZCost = dto.TzZCost;
  13107. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13108. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13109. var index = 1;
  13110. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13111. foreach (var item in TzHotelDescArr)
  13112. {
  13113. if (AinfoArr != null)
  13114. {
  13115. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13116. if (Ainfo != null)
  13117. {
  13118. if (int.Parse(Ainfo.rs) <= 0)
  13119. {
  13120. continue;
  13121. }
  13122. var hotelText = string.Empty;
  13123. switch (item)
  13124. {
  13125. case "SGR":
  13126. hotelText = "单人间";
  13127. break;
  13128. case "JSES":
  13129. hotelText = "小套房";
  13130. break;
  13131. case "SUITE":
  13132. hotelText = "套房";
  13133. break;
  13134. case "TBR":
  13135. hotelText = "双人间";
  13136. break;
  13137. }
  13138. if (item != "TBR")
  13139. {
  13140. 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";
  13141. }
  13142. else
  13143. {
  13144. 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";
  13145. }
  13146. index++;
  13147. }
  13148. }
  13149. }
  13150. index = 1;
  13151. foreach (var item in TzAirDescArr)
  13152. {
  13153. if (AinfoArr != null)
  13154. {
  13155. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13156. if (Ainfo != null)
  13157. {
  13158. if (int.Parse(Ainfo.rs) <= 0)
  13159. {
  13160. continue;
  13161. }
  13162. 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";
  13163. index++;
  13164. }
  13165. }
  13166. }
  13167. if (dto.costType == "B")
  13168. {
  13169. if (BParameter == null)
  13170. {
  13171. return Ok(JsonView(false, "B段系数不存在!"));
  13172. }
  13173. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13174. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13175. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13176. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13177. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13178. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13179. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13180. foreach (var item in TzHotelDescArr)
  13181. {
  13182. if (AinfoArr != null)
  13183. {
  13184. TzHotelDesc += "B段信息 \r\n";
  13185. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13186. if (Ainfo != null)
  13187. {
  13188. if (int.Parse(Ainfo.rs) <= 0)
  13189. {
  13190. continue;
  13191. }
  13192. var hotelText = string.Empty;
  13193. switch (item)
  13194. {
  13195. case "SGR":
  13196. hotelText = "单人间";
  13197. break;
  13198. case "JSES":
  13199. hotelText = "小套房";
  13200. break;
  13201. case "SUITE":
  13202. hotelText = "套房";
  13203. break;
  13204. case "TBR":
  13205. hotelText = "双人间";
  13206. break;
  13207. }
  13208. if (item != "TBR")
  13209. {
  13210. 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";
  13211. }
  13212. else
  13213. {
  13214. 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";
  13215. }
  13216. index++;
  13217. }
  13218. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13219. }
  13220. }
  13221. index = 1;
  13222. foreach (var item in TzAirDescArr)
  13223. {
  13224. if (AinfoArr != null)
  13225. {
  13226. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13227. if (Ainfo != null)
  13228. {
  13229. if (int.Parse(Ainfo.rs) <= 0)
  13230. {
  13231. continue;
  13232. }
  13233. 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";
  13234. index++;
  13235. }
  13236. }
  13237. }
  13238. }
  13239. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13240. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13241. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13242. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13243. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13244. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13245. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13246. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13247. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13248. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13249. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13250. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13251. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13252. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13253. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13254. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13255. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13256. DickeyValue.Add("TzZCost", TzZCost);
  13257. foreach (var key in DickeyValue.Keys)
  13258. {
  13259. if (doc.Range.Bookmarks[key] != null)
  13260. {
  13261. Bookmark mark = doc.Range.Bookmarks[key];
  13262. mark.Text = DickeyValue[key];
  13263. }
  13264. }
  13265. byte[] bytes = null;
  13266. string strFileName = di.TeamName + "-客户报价.doc";
  13267. using (MemoryStream stream = new MemoryStream())
  13268. {
  13269. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13270. bytes = stream.ToArray();
  13271. }
  13272. return Ok(JsonView(true, "", new
  13273. {
  13274. Data = bytes,
  13275. strFileName,
  13276. }));
  13277. }
  13278. /// <summary>
  13279. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13280. /// </summary>
  13281. /// <param name="dto"></param>
  13282. /// <returns></returns>
  13283. [HttpPost]
  13284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13285. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13286. {
  13287. try
  13288. {
  13289. #region 参数验证
  13290. if (dto.DiId < 0)
  13291. {
  13292. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13293. }
  13294. List<int> cTableIds = new List<int>() {
  13295. 76 ,//酒店预订
  13296. 77 ,//行程
  13297. 79 ,//车/导游地接
  13298. 80 ,//签证
  13299. 81 ,//邀请/公务活
  13300. 82 ,//团组客户保险
  13301. 85 ,//机票预订
  13302. 98 ,//其他款项
  13303. 285 ,//收款退还
  13304. 751 ,//酒店早餐
  13305. 1015 // 超支费用
  13306. };
  13307. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13308. {
  13309. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13310. }
  13311. #endregion
  13312. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13313. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13314. if (_GroupCostParameters.Count <= 0)
  13315. {
  13316. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13317. }
  13318. if (_GroupCostParameters[0].IsShare == 0)
  13319. {
  13320. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13321. }
  13322. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13323. //处理date为空问题
  13324. if (_GroupCosts.Count > 0)
  13325. {
  13326. for (int i = 0; i < _GroupCosts.Count; i++)
  13327. {
  13328. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13329. {
  13330. if (i > 0)
  13331. {
  13332. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13333. }
  13334. }
  13335. }
  13336. }
  13337. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13338. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13339. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13340. string currCode = "";
  13341. #region currCode 验证
  13342. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13343. if (isInt)
  13344. {
  13345. var currData = currDatas.Find(it => it.Id == intCurrency);
  13346. if (currData != null)
  13347. {
  13348. currCode = currData.Name;
  13349. }
  13350. }
  13351. else
  13352. {
  13353. currCode = _GroupCostParameters[0].Currency.Trim();
  13354. }
  13355. #endregion
  13356. //op,酒店单段模式存储
  13357. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13358. {
  13359. CurrencyCode = currCode,
  13360. Rate = _GroupCostParameters[0].Rate,
  13361. CostType = _GroupCostParameters[0].CostType,
  13362. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13363. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13364. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13365. };
  13366. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13367. if (_GroupCostParameters.Count == 2)
  13368. {
  13369. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13370. }
  13371. foreach (var item in _GroupCostParameters)
  13372. {
  13373. decimal _rate = 1;
  13374. decimal _rate1 = item.Rate;
  13375. decimal _scale = 1;
  13376. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13377. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13378. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13379. //if (userInfo != null)
  13380. //{
  13381. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13382. // {
  13383. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13384. // {
  13385. // _scale = 1.00M;
  13386. // }
  13387. // }
  13388. //}
  13389. #endregion
  13390. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13391. {
  13392. CurrencyCode = currCode,
  13393. Rate = _rate1,
  13394. CostType = item.CostType,
  13395. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13396. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13397. CostTypeNumber = item.CostTypenumber
  13398. };
  13399. if (_GroupCostParameters.Count > 1)
  13400. {
  13401. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13402. }
  13403. else
  13404. {
  13405. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13406. }
  13407. if (dto.CTable == 79)//
  13408. {
  13409. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13410. modulePromptInfo.TotalCost = item.DJCB;
  13411. }
  13412. List<string> costTypes = new List<string>() { "A", "B" };
  13413. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13414. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13415. if (_GroupCostsDuplicates.Count() == 1)
  13416. {
  13417. _GroupCostsTypeData = _GroupCosts;
  13418. }
  13419. else
  13420. {
  13421. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13422. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13423. }
  13424. /*
  13425. * 76 酒店预订
  13426. * 77 行程
  13427. * 79 车/导游地接
  13428. * 80 签证
  13429. * 81 邀请/公务活动
  13430. * 82 团组客户保险
  13431. * 85 机票预订
  13432. * 98 其他款项
  13433. * 285 收款退还
  13434. * 751 酒店早餐
  13435. * 1015 超支费用
  13436. */
  13437. switch (dto.CTable)
  13438. {
  13439. case 76: // 酒店预订
  13440. _ModuleSubPromptInfo.AddRange(
  13441. _GroupCostsTypeData.Select(it => new
  13442. {
  13443. it.DAY,
  13444. it.Date,
  13445. it.ACCON,
  13446. it.ITIN,
  13447. it.SGR,
  13448. it.TBR,
  13449. it.JS_ES,
  13450. it.Suite
  13451. })
  13452. );
  13453. break;
  13454. case 79: // 车/导游地接
  13455. _ModuleSubPromptInfo.AddRange(
  13456. _GroupCostsTypeData.Select(it => new
  13457. {
  13458. Date = it.Date, //日期
  13459. CarFee = it.CarCost * _rate * _scale, //车费用
  13460. CarType = it.CarType, //车型
  13461. DriverFee = it.CFS * _rate * _scale, //司机工资
  13462. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13463. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13464. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13465. GuideFee = it.TGS * _rate * _scale, //导游费用
  13466. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13467. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13468. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13469. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13470. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13471. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13472. Breakfast = it.B * _rate * _scale, //早餐费
  13473. Lunch = it.L * _rate * _scale, //午餐费
  13474. Dinner = it.D * _rate * _scale, //晚餐费
  13475. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13476. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13477. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13478. TicketFee = it.EF * _rate * _scale, //门票费
  13479. TicketRemark = it.EFR, //门票费描述
  13480. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13481. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13482. SpentCash = it.PC * _rate * _scale, //零用金
  13483. LeadersFee = it.TLF * _rate * _scale, //领队费
  13484. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13485. })
  13486. );
  13487. break;
  13488. case 85: // 机票
  13489. List<dynamic> datas = new List<dynamic>();
  13490. datas.Add(
  13491. new
  13492. {
  13493. AirType = "经济舱",
  13494. AirNum = item.JJCRS,
  13495. AirDRCB = item.JJCCB,
  13496. AirZCB = (item.JJCRS * item.JJCCB)
  13497. }
  13498. );
  13499. datas.Add(
  13500. new
  13501. {
  13502. AirType = "公务舱",
  13503. AirNum = item.GWCRS,
  13504. AirDRCB = item.GWCCB,
  13505. AirZCB = (item.GWCRS * item.GWCCB)
  13506. }
  13507. );
  13508. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13509. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13510. modulePromptInfo.Data = new
  13511. {
  13512. airFeeData = datas,
  13513. airInitData = initDatas
  13514. };
  13515. _ModulePromptInfos.Add(modulePromptInfo);
  13516. break;
  13517. default:
  13518. break;
  13519. }
  13520. }
  13521. if (dto.CTable != 85)
  13522. {
  13523. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13524. _ModulePromptInfos.Add(_ModulePromptInfo);
  13525. }
  13526. _view.ModulePromptInfos = _ModulePromptInfos;
  13527. return Ok(JsonView(true, "操作成功!", _view));
  13528. }
  13529. catch (Exception ex)
  13530. {
  13531. return Ok(JsonView(false, ex.Message));
  13532. }
  13533. }
  13534. /// <summary>
  13535. /// 根据黑屏代码重新生成行程
  13536. /// </summary>
  13537. /// <param name="dto"></param>
  13538. /// <returns></returns>
  13539. [HttpPost]
  13540. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13541. {
  13542. var jw = JsonView(false);
  13543. var Create = _GroupCostRepository.
  13544. CreateGroupCostByBlackCode(dto.Diid);
  13545. jw.Msg = Create.Msg;
  13546. if (Create.Code == 0)
  13547. {
  13548. jw.Code = 200;
  13549. jw.Data = new
  13550. {
  13551. groupCost = Create.Data,
  13552. blackCodeIsTrue = true
  13553. };
  13554. }
  13555. else
  13556. {
  13557. jw.Code = 400;
  13558. jw.Data = new
  13559. {
  13560. groupCost = Create.Data,
  13561. blackCodeIsTrue = false,
  13562. };
  13563. }
  13564. return Ok(jw);
  13565. }
  13566. /// <summary>
  13567. /// 成本获取OP历史车费用
  13568. /// </summary>
  13569. /// <param name="dto"></param>
  13570. /// <returns></returns>
  13571. [HttpPost]
  13572. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13573. {
  13574. var jw = JsonView(false);
  13575. try
  13576. {
  13577. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13578. //获取现有所有车的数据
  13579. if (!dto.Param.IsNullOrWhiteSpace())
  13580. {
  13581. string sql = $@"
  13582. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13583. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13584. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13585. 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
  13586. AND gctggr.ServiceEndTime is not NULL
  13587. ORDER by gctggrc.id DESC
  13588. ";
  13589. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13590. var numeberResult = await Task.Run(() =>
  13591. {
  13592. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13593. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13594. return numberArr;
  13595. });
  13596. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13597. foreach (var item in numeberResult)
  13598. {
  13599. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13600. {
  13601. Country = "数据异常!",
  13602. City = string.Empty,
  13603. };
  13604. item.Area = find.Country + " " + find.City;
  13605. }
  13606. dbResult.AddRange(numeberResult);
  13607. if (dto.Param.Contains("、"))
  13608. {
  13609. var sp = dto.Param.Split("、");
  13610. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13611. .Where(x =>
  13612. {
  13613. return System.Array.Exists(sp, e =>
  13614. {
  13615. bool where = false;
  13616. if (x.Area != null)
  13617. {
  13618. where = x.Area.Contains(e);
  13619. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13620. {
  13621. return false;
  13622. }
  13623. }
  13624. if (x.PriceName != null && !where)
  13625. {
  13626. where = x.PriceName.Contains(e);
  13627. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13628. {
  13629. return false;
  13630. }
  13631. }
  13632. return where;
  13633. });
  13634. }).ToList();
  13635. }
  13636. else
  13637. {
  13638. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13639. .Where(x =>
  13640. {
  13641. bool where = false;
  13642. if (x.Area != null)
  13643. {
  13644. where = x.Area.Contains(dto.Param);
  13645. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13646. {
  13647. return false;
  13648. }
  13649. }
  13650. if (x.PriceName != null && !where)
  13651. {
  13652. where = x.PriceName.Contains(dto.Param);
  13653. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13654. {
  13655. return false;
  13656. }
  13657. }
  13658. return where;
  13659. }
  13660. )
  13661. .ToList();
  13662. }
  13663. }
  13664. var view = dbResult.Select(x =>
  13665. {
  13666. decimal dp = 0.00M;
  13667. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13668. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13669. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13670. {
  13671. if (startB && endB)
  13672. {
  13673. var timesp = endD.Subtract(startD);
  13674. if ((timesp.Days + 1) != 0)
  13675. {
  13676. dp = x.Price / (timesp.Days + 1);
  13677. }
  13678. }
  13679. }
  13680. else
  13681. {
  13682. dp = x.Price;
  13683. }
  13684. return new
  13685. {
  13686. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13687. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13688. x.Area,
  13689. x.id,
  13690. price = x.Price.ToString("F2"),
  13691. x.PriceName,
  13692. x.PriceContent,
  13693. x.TeamName,
  13694. x.DatePrice,
  13695. dayPrice = dp.ToString("F2"),
  13696. };
  13697. }).OrderByDescending(x => x.id).ToList();
  13698. jw = JsonView(true, "获取成功!", view);
  13699. }
  13700. catch (Exception e)
  13701. {
  13702. jw = JsonView(false, e.Message);
  13703. }
  13704. return Ok(jw);
  13705. }
  13706. #endregion
  13707. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13708. /// <summary>
  13709. /// 酒店预订
  13710. /// 酒店费用列表 根据团组Id查询
  13711. /// </summary>
  13712. /// <param name="_dto"></param>
  13713. /// <returns></returns>
  13714. [HttpPost]
  13715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13716. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13717. {
  13718. #region 参数验证
  13719. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13720. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13721. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13722. #region 团组操作权限验证 76 酒店预定模块
  13723. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13724. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13725. #endregion
  13726. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13727. #region 页面操作权限验证
  13728. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13729. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13730. #endregion
  13731. #endregion
  13732. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13733. }
  13734. /// <summary>
  13735. /// 酒店预订
  13736. /// 基础数据
  13737. /// </summary>
  13738. /// <param name="_dto"></param>
  13739. /// <returns></returns>
  13740. [HttpPost]
  13741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13742. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13743. {
  13744. #region 参数验证
  13745. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13746. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13747. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13748. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13749. #region 页面操作权限验证
  13750. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13751. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13752. #endregion
  13753. #region 团组操作权限验证 76 酒店预定模块
  13754. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13755. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13756. #endregion
  13757. #endregion
  13758. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13759. }
  13760. /// <summary>
  13761. /// 酒店预订
  13762. /// 创建 入住卷号码
  13763. /// </summary>
  13764. /// <param name="_dto"></param>
  13765. /// <returns></returns>
  13766. [HttpPost]
  13767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13768. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13769. {
  13770. #region 参数验证
  13771. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13772. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13773. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13774. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13775. #region 页面操作权限验证
  13776. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13777. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13778. #endregion
  13779. #region 团组操作权限验证 76 酒店预定模块
  13780. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13781. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13782. #endregion
  13783. #endregion
  13784. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13785. if (data.Code != 0)
  13786. {
  13787. return Ok(JsonView(false, data.Msg));
  13788. }
  13789. return Ok(JsonView(true, data.Msg, data.Data));
  13790. }
  13791. /// <summary>
  13792. /// 酒店预订
  13793. /// 详情
  13794. /// </summary>
  13795. /// <param name="_dto"></param>
  13796. /// <returns></returns>
  13797. [HttpPost]
  13798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13799. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13800. {
  13801. #region 参数验证
  13802. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13803. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13804. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13805. #region 团组操作权限验证 76 酒店预定模块
  13806. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13807. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13808. #endregion
  13809. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13810. #region 页面操作权限验证
  13811. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13812. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13813. #endregion
  13814. #endregion
  13815. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13816. }
  13817. /// <summary>
  13818. /// 酒店预订
  13819. /// Add Or Edit
  13820. /// </summary>
  13821. /// <param name="_dto"></param>
  13822. /// <returns></returns>
  13823. [HttpPost]
  13824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13825. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13826. {
  13827. #region 参数验证
  13828. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13829. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13830. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13831. #region 团组操作权限验证 76 酒店预定模块
  13832. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13833. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13834. #endregion
  13835. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13836. #region 页面操作权限验证
  13837. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13838. if (_dto.Id == 0) // Add
  13839. {
  13840. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13841. }
  13842. else if (_dto.Id > 1) // Edit
  13843. {
  13844. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13845. }
  13846. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13847. #endregion
  13848. #endregion
  13849. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13850. if (_view.Code != 200)
  13851. {
  13852. return Ok(_view);
  13853. }
  13854. #region 成本无酒店价格数据进入超支
  13855. _sqlSugar.BeginTran();
  13856. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13857. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13858. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13859. for (int i = 0; i < groupCost.Count; i++)
  13860. {
  13861. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13862. {
  13863. groupCost[i].Date = groupCost[i - 1].Date;
  13864. }
  13865. }
  13866. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13867. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13868. List<Fin_GroupExtraCostDto_OP>();
  13869. if (start_Bool && end_Bool)
  13870. {
  13871. while (start_Time < end_Time)
  13872. {
  13873. foreach (var item in groupCost_Grp)
  13874. {
  13875. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13876. {
  13877. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13878. {
  13879. extraCostList.Add(new
  13880. Fin_GroupExtraCostDto_OP
  13881. {
  13882. Area = _dto.AreaId,
  13883. coefficient = 1.5M,
  13884. createUser = _dto.UserId,
  13885. currency = _dto.CardPriceCurrency,
  13886. diId = _dto.DiId,
  13887. ManagerConfirm = 0,
  13888. SupervisorConfirm = 0,
  13889. SYsupervisorConfirm = 0,
  13890. editType = 1,
  13891. PortType = 1,
  13892. price = _dto.CardPrice,
  13893. PriceCount = 1,
  13894. priceType = 1027,
  13895. priceDetailType = 1044,
  13896. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13897. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13898. });
  13899. }
  13900. }
  13901. }
  13902. start_Time = start_Time.AddDays(1);
  13903. }
  13904. }
  13905. if (extraCostList.Any())
  13906. {
  13907. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13908. }
  13909. _sqlSugar.CommitTran();
  13910. #endregion
  13911. #region 应用推送
  13912. try
  13913. {
  13914. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13915. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13916. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13917. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13918. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13919. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13920. var diId = _dto.DiId;
  13921. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13922. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13923. #region 操作记录
  13924. var opInfo = new Crm_TableOperationRecord()
  13925. {
  13926. TableName = "Grp_HotelReservations",
  13927. PortType = _dto.PortType,
  13928. DataId = hotelId,
  13929. CreateUserId = _dto.UserId
  13930. };
  13931. //var opStatus = OperationEnum.NoOperation;
  13932. if (_dto.Id < 1) //添加操作
  13933. {
  13934. opInfo.OperationItem = OperationEnum.Add;
  13935. }
  13936. else if (_dto.Id > 0)
  13937. {
  13938. opInfo.OperationItem = OperationEnum.Edit;
  13939. }
  13940. string opRemark = string.Empty;
  13941. if (ccpInfo != null)
  13942. {
  13943. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13944. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13945. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13946. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13947. }
  13948. opInfo.Remark = opRemark;
  13949. await _tableorRep.AddAsync(opInfo);
  13950. #endregion
  13951. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13952. //2024-10-21 新增LZ UID
  13953. var userIds = new List<int>() { 21 };
  13954. string title = $"费用审核";
  13955. string content = "";
  13956. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13957. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13958. try
  13959. {
  13960. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13961. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13962. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13963. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13964. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13965. }
  13966. catch (Exception ex)
  13967. {
  13968. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13969. }
  13970. }
  13971. catch (Exception ex)
  13972. {
  13973. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13974. }
  13975. try
  13976. {
  13977. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13978. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13979. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13980. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13981. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13982. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13983. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13984. //自动审核
  13985. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13986. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13987. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  13988. //2024-10-21 新增LZ UID
  13989. var userIds = new List<int>() { 21 };
  13990. string title = $"系统通知";
  13991. var diId = _dto.DiId;
  13992. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13993. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13994. string content = "";
  13995. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13996. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13997. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13998. }
  13999. catch (Exception ex)
  14000. {
  14001. }
  14002. #endregion
  14003. return Ok(_view);
  14004. }
  14005. /// <summary>
  14006. /// 酒店自动审核测试
  14007. /// Add Or Edit
  14008. /// </summary>
  14009. /// <param name="diid"></param>
  14010. /// <param name="dataId"></param>
  14011. /// <returns></returns>
  14012. [HttpPost]
  14013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14014. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14015. {
  14016. #region 应用推送
  14017. try
  14018. {
  14019. //自动审核
  14020. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14021. }
  14022. catch (Exception ex)
  14023. {
  14024. return Ok(JsonView(false, "操作失败"));
  14025. }
  14026. #endregion
  14027. return Ok(JsonView(false, "操作成功"));
  14028. }
  14029. /// <summary>
  14030. /// 酒店预订
  14031. /// Del
  14032. /// </summary>
  14033. /// <param name="_dto"></param>
  14034. /// <returns></returns>
  14035. [HttpPost]
  14036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14037. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14038. {
  14039. #region 参数验证
  14040. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14041. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14042. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14043. #region 团组操作权限验证 76 酒店预定模块
  14044. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14045. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14046. #endregion
  14047. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14048. #region 页面操作权限验证
  14049. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14050. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14051. #endregion
  14052. #endregion
  14053. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14054. #region 操作记录
  14055. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14056. {
  14057. TableName = "Grp_HotelReservations",
  14058. PortType = _dto.PortType,
  14059. OperationItem = OperationEnum.Del,
  14060. DataId = _dto.Id,
  14061. CreateUserId = _dto.UserId
  14062. });
  14063. #endregion
  14064. return Ok(data);
  14065. }
  14066. /// <summary>
  14067. /// 酒店预订
  14068. /// 生成VOUCHER
  14069. /// 2024.05.06 之前版本
  14070. /// </summary>
  14071. /// <param name="_dto"></param>
  14072. /// <returns></returns>
  14073. [HttpPost]
  14074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14075. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14076. {
  14077. try
  14078. {
  14079. #region 参数验证
  14080. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14081. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14082. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14083. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14084. #region 团组操作权限验证 76 酒店预定模块
  14085. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14086. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14087. #endregion
  14088. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14089. #region 页面操作权限验证
  14090. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14091. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14092. #endregion
  14093. #endregion
  14094. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14095. //判断数据是否完整
  14096. if (hr != null)
  14097. {
  14098. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14099. {
  14100. string strFileName = "HotelStatement/";
  14101. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14102. if (dele != null)
  14103. strFileName += dele.TourCode;
  14104. //载入模板
  14105. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14106. Document doc = new Document(sss);
  14107. DocumentBuilder builder = new DocumentBuilder(doc);
  14108. #region 替换Word模板书签内容
  14109. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14110. //入住卷预定号码
  14111. if (doc.Range.Bookmarks["VNO"] != null)
  14112. {
  14113. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14114. mark.Text = hr.CheckNumber;
  14115. }
  14116. //酒店时间
  14117. if (doc.Range.Bookmarks["Date"] != null)
  14118. {
  14119. Bookmark mark = doc.Range.Bookmarks["Date"];
  14120. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14121. }
  14122. //团号
  14123. if (doc.Range.Bookmarks["TNo"] != null)
  14124. {
  14125. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14126. mark.Text = dele.TourCode;
  14127. }
  14128. //预定号码
  14129. if (doc.Range.Bookmarks["BookingId"] != null)
  14130. {
  14131. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14132. mark.Text = hr.ReservationsNo;
  14133. }
  14134. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14135. {
  14136. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14137. mark.Text = hr.DetermineNo;
  14138. }
  14139. //酒店城市
  14140. if (doc.Range.Bookmarks["City"] != null)
  14141. {
  14142. Bookmark mark = doc.Range.Bookmarks["City"];
  14143. mark.Text = hr.City;
  14144. }
  14145. //酒店名称
  14146. if (doc.Range.Bookmarks["HName"] != null)
  14147. {
  14148. Bookmark mark = doc.Range.Bookmarks["HName"];
  14149. mark.Text = hr.HotelName;
  14150. }
  14151. //酒店地址
  14152. if (doc.Range.Bookmarks["Address"] != null)
  14153. {
  14154. Bookmark mark = doc.Range.Bookmarks["Address"];
  14155. mark.Text = hr.HotelAddress;
  14156. }
  14157. //酒店电话
  14158. if (doc.Range.Bookmarks["Tel"] != null)
  14159. {
  14160. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14161. mark.Text = hr.HotelTel;
  14162. }
  14163. //酒店传真
  14164. if (doc.Range.Bookmarks["Fax"] != null)
  14165. {
  14166. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14167. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14168. {
  14169. mark.Text = hr.HotelFax;
  14170. }
  14171. }
  14172. //入住时间
  14173. if (doc.Range.Bookmarks["CIn"] != null)
  14174. {
  14175. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14176. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14177. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14178. }
  14179. //退房时间
  14180. if (doc.Range.Bookmarks["COut"] != null)
  14181. {
  14182. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14183. Bookmark mark = doc.Range.Bookmarks["COut"];
  14184. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14185. }
  14186. //客户名称
  14187. if (doc.Range.Bookmarks["GName"] != null)
  14188. {
  14189. string guestName = "";
  14190. string[] clients = new string[] { };
  14191. if (hr.GuestName.Contains(","))
  14192. {
  14193. clients = hr.GuestName.Split(",");
  14194. }
  14195. else
  14196. {
  14197. clients = new string[] { hr.GuestName };
  14198. }
  14199. List<int> clientIds_int = new List<int>();
  14200. if (clients.Length > 0)
  14201. {
  14202. foreach (var item in clients)
  14203. {
  14204. if (item.IsNumeric())
  14205. {
  14206. clientIds_int.Add(int.Parse(item));
  14207. }
  14208. }
  14209. }
  14210. if (clientIds_int.Count > 0)
  14211. {
  14212. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14213. foreach (var client in _clientDatas)
  14214. {
  14215. //男
  14216. if (client.Sex == 0) guestName += $"Mr.";
  14217. //女
  14218. else if (client.Sex == 1) guestName += $"Ms.";
  14219. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14220. {
  14221. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14222. }
  14223. //guestName += $"{client.Pinyin},";
  14224. }
  14225. if (guestName.Length > 0)
  14226. {
  14227. guestName = guestName.Substring(0, guestName.Length - 1);
  14228. }
  14229. }
  14230. else
  14231. {
  14232. guestName = hr.GuestName;
  14233. }
  14234. Bookmark mark = doc.Range.Bookmarks["GName"];
  14235. mark.Text = guestName;
  14236. }
  14237. //房间介绍
  14238. if (doc.Range.Bookmarks["ROOM"] != null)
  14239. {
  14240. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14241. mark.Text = hr.RoomExplanation;
  14242. }
  14243. //报价描述
  14244. if (doc.Range.Bookmarks["NOTE"] != null)
  14245. {
  14246. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14247. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14248. if (ss != null)
  14249. mark.Text = ss.Name;
  14250. }
  14251. //入住时间
  14252. if (doc.Range.Bookmarks["CheckIn"] != null)
  14253. {
  14254. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14255. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14256. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14257. }
  14258. //退房时间
  14259. if (doc.Range.Bookmarks["CheckOut"] != null)
  14260. {
  14261. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14262. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14263. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14264. }
  14265. //日期
  14266. if (doc.Range.Bookmarks["DT"] != null)
  14267. {
  14268. Bookmark mark = doc.Range.Bookmarks["DT"];
  14269. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14270. }
  14271. //名称
  14272. if (doc.Range.Bookmarks["VName"] != null)
  14273. {
  14274. Bookmark mark = doc.Range.Bookmarks["VName"];
  14275. mark.Text = hr.HotelName;
  14276. }
  14277. //号码
  14278. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14279. {
  14280. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14281. mark.Text = hr.CheckNumber;
  14282. }
  14283. #endregion
  14284. strFileName += "VOUCHER.doc";
  14285. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14286. doc.Save(fileDir);
  14287. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14288. return Ok(JsonView(true, "操作成功!", Url));
  14289. }
  14290. else
  14291. {
  14292. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14293. }
  14294. }
  14295. else
  14296. {
  14297. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14298. }
  14299. }
  14300. catch (Exception ex)
  14301. {
  14302. return Ok(JsonView(false, ex.Message));
  14303. }
  14304. }
  14305. /// <summary>
  14306. /// 酒店预订
  14307. /// 生成VOUCHER
  14308. /// 2024.05.06 之后版本
  14309. /// </summary>
  14310. /// <param name="_dto"></param>
  14311. /// <returns></returns>
  14312. [HttpPost]
  14313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14314. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14315. {
  14316. #region 参数验证
  14317. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14318. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14319. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14320. #region 团组操作权限验证 76 酒店预定模块
  14321. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14322. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14323. #endregion
  14324. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14325. #region 页面操作权限验证
  14326. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14327. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14328. #endregion
  14329. #endregion
  14330. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14331. //判断数据是否完整
  14332. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14333. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14334. string strFileName = "HotelStatement/";
  14335. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14336. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14337. #region 数据处理
  14338. List<int> guestIds = new List<int>();
  14339. //int index = 0;
  14340. foreach (var item in hrDtas)
  14341. {
  14342. if (item.GuestName.Contains(","))
  14343. {
  14344. string[] guestIdArr = item.GuestName.Split(',');
  14345. foreach (var guestIdStr in guestIdArr)
  14346. {
  14347. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14348. if (guestBool)
  14349. {
  14350. guestIds.Add(guestId);
  14351. }
  14352. }
  14353. }
  14354. else guestNames += item.GuestName;
  14355. var voucherInfo = new HotelVoucherInfoView()
  14356. {
  14357. HotelName = item.HotelName,
  14358. CheckInDate = item.CheckInDate,
  14359. CheckOutDate = item.CheckOutDate,
  14360. ConfirmationNumber = item.DetermineNo.Trim(),
  14361. RoomType = item.RoomExplanation
  14362. };
  14363. vouchers.Add(voucherInfo);
  14364. }
  14365. if (guestIds.Count > 0)
  14366. {
  14367. guestIds = guestIds.Distinct().ToList();
  14368. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14369. if (guestDatas.Count > 0)
  14370. {
  14371. guestNames = "";
  14372. foreach (var guest in guestDatas)
  14373. {
  14374. string guestName = "";
  14375. if (guest.Sex == 0) guestName += @"MR.";
  14376. else if (guest.Sex == 1) guestName += @"MS.";
  14377. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14378. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14379. guestNames += @$"{guestName.Trim()}、";
  14380. }
  14381. if (guestNames.Length > 0)
  14382. {
  14383. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14384. }
  14385. }
  14386. }
  14387. #endregion
  14388. //载入模板
  14389. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14390. Document doc = new Document(sss);
  14391. DocumentBuilder builder = new DocumentBuilder(doc);
  14392. if (doc.Range.Bookmarks["GuestName"] != null)
  14393. {
  14394. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14395. mark.Text = guestNames;
  14396. }
  14397. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14398. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14399. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14400. for (int i = 1; i <= vouchers.Count; i++)
  14401. {
  14402. HotelVoucherInfoView hviv = vouchers[i - 1];
  14403. builder.MoveToCell(0, i, 0, 0);
  14404. builder.Write(hviv.HotelName);
  14405. builder.MoveToCell(0, i, 1, 0);
  14406. builder.Write(hviv.CheckInDate);
  14407. builder.MoveToCell(0, i, 2, 0);
  14408. builder.Write(hviv.CheckOutDate);
  14409. builder.MoveToCell(0, i, 3, 0);
  14410. builder.Write(hviv.RoomType);
  14411. builder.MoveToCell(0, i, 4, 0);
  14412. builder.Write(hviv.ConfirmationNumber);
  14413. }
  14414. //删除多余行
  14415. int currRowIndex = vouchers.Count + 1;
  14416. int delRows = 21 - currRowIndex;
  14417. if (delRows > 0)
  14418. {
  14419. for (int i = 0; i < delRows; i++)
  14420. {
  14421. table.Rows.RemoveAt(currRowIndex);
  14422. //cultivateRowIndex++;
  14423. }
  14424. }
  14425. strFileName += "VOUCHER.docx";
  14426. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14427. doc.Save(fileDir);
  14428. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14429. return Ok(JsonView(true, "操作成功!", Url));
  14430. }
  14431. /// <summary>
  14432. /// 酒店预订
  14433. /// 生成VOUCHER 批量生成
  14434. /// New
  14435. /// </summary>
  14436. /// <param name="_dto"></param>
  14437. /// <returns></returns>
  14438. [HttpPost]
  14439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14440. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14441. {
  14442. #region 参数验证
  14443. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14444. if (_dto.PageId < 1) _dto.PageId = 28;
  14445. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14446. #region 团组操作权限验证 76 酒店预定模块
  14447. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14448. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14449. #endregion
  14450. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14451. #region 页面操作权限验证
  14452. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14453. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14454. #endregion
  14455. #endregion
  14456. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14457. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14458. .OrderBy(x => x.CheckInDate)
  14459. .ToListAsync();
  14460. //判断数据是否完整
  14461. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14462. string strFileName = "HotelStatement/";
  14463. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14464. if (dele != null)
  14465. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14466. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14467. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14468. .Where(it => it.IsDel == 0)
  14469. .ToListAsync();
  14470. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14471. for (int i = 0; i < hrDtas.Count; i++)
  14472. {
  14473. string guestNames = string.Empty;
  14474. List<int> guestIds = new List<int>();
  14475. var item = hrDtas[i];
  14476. //处理客户姓名
  14477. if (item.GuestName.Contains(","))
  14478. {
  14479. string[] guestIdArr = item.GuestName.Split(',');
  14480. foreach (var guestIdStr in guestIdArr)
  14481. if (int.TryParse(guestIdStr, out int guestId))
  14482. guestIds.Add(guestId);
  14483. }
  14484. else
  14485. {
  14486. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14487. if (guestIdBool)
  14488. {
  14489. guestIds.Add(guestId);
  14490. }
  14491. //NaN
  14492. if (item.GuestName.Contains("NaN"))
  14493. {
  14494. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14495. }
  14496. }
  14497. if (guestIds.Count > 0)
  14498. {
  14499. guestIds = guestIds.Distinct().ToList();
  14500. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14501. if (guestDatas1.Count > 0)
  14502. {
  14503. guestNames = "";
  14504. foreach (var guest in guestDatas1)
  14505. {
  14506. string guestName = "";
  14507. if (guest.Sex == 0) guestName += @"MR.";
  14508. else if (guest.Sex == 1) guestName += @"MS.";
  14509. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14510. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14511. guestNames += @$"{guestName.Trim()}、";
  14512. }
  14513. if (guestNames.Length > 0)
  14514. {
  14515. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14516. }
  14517. }
  14518. }
  14519. //if (!string.IsNullOrEmpty(guestNames))
  14520. //{
  14521. hrDtas[i].GuestName = guestNames;
  14522. //}
  14523. }
  14524. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14525. Document doc = new Document();
  14526. DocumentBuilder builder = new DocumentBuilder(doc);
  14527. try
  14528. {
  14529. builder.MoveToDocumentStart();
  14530. foreach (var item in hrDtas)
  14531. {
  14532. //标题
  14533. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14534. builder.ParagraphFormat.LineSpacing = 1;
  14535. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14536. builder.ParagraphFormat.Style.Font.Size = 9;
  14537. builder.ParagraphFormat.Style.Font.Bold = true;
  14538. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14539. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14540. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14541. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14542. builder.ParagraphFormat.LineSpacing = 1;
  14543. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14544. builder.ParagraphFormat.Style.Font.Size = 9;
  14545. builder.ParagraphFormat.Style.Font.Bold = true;
  14546. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14547. builder.StartTable();
  14548. // 设置边框颜色
  14549. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14550. //设置边框样式
  14551. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14552. //表格
  14553. #region 第一行
  14554. builder.InsertCell();
  14555. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14556. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14557. //builder.CellFormat.AllowAutoFit = false;
  14558. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14559. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14560. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14561. builder.CellFormat.WrapText = true; //自动换行
  14562. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14563. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14564. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14565. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14566. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14567. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14568. builder.Write("TOUR NO:");
  14569. builder.InsertCell();
  14570. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14571. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14572. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14573. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14574. builder.ParagraphFormat.Style.Font.Bold = false;
  14575. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14576. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14577. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14578. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14579. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14580. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14581. builder.Write($"{dele?.TourCode ?? "-"}");
  14582. builder.InsertCell();
  14583. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14584. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14585. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14586. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14587. builder.ParagraphFormat.Style.Font.Bold = false;
  14588. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14589. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14590. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14591. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14592. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14593. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14594. builder.Write($"CITY:");
  14595. builder.InsertCell();
  14596. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14597. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14598. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14599. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14600. builder.ParagraphFormat.Style.Font.Bold = false;
  14601. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14602. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14603. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14604. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14605. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14606. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14607. builder.Write($"{item.City}");
  14608. builder.EndRow();
  14609. #endregion
  14610. #region 第二行
  14611. builder.InsertCell();
  14612. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14613. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14614. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14615. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14616. builder.ParagraphFormat.Style.Font.Bold = false;
  14617. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14618. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14619. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14620. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14621. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14622. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14623. builder.Write("CONFIRMATION NO:");
  14624. builder.InsertCell();
  14625. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14626. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14627. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14628. builder.ParagraphFormat.Style.Font.Bold = false;
  14629. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14630. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14631. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14632. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14633. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14634. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14635. builder.CellFormat.VerticalMerge = CellMerge.None;
  14636. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14637. builder.Write($"{item.DetermineNo}");
  14638. builder.InsertCell();
  14639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14640. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14641. builder.InsertCell();
  14642. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14643. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14644. builder.EndRow();
  14645. #endregion
  14646. #region 第三行
  14647. builder.InsertCell();
  14648. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14649. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14650. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14651. builder.ParagraphFormat.Style.Font.Bold = false;
  14652. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14653. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14654. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14655. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14656. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14657. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14658. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14659. builder.Write($"HOTEL NAME:");
  14660. builder.InsertCell();
  14661. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14662. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14663. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14664. builder.ParagraphFormat.Style.Font.Bold = false;
  14665. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14666. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14667. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14668. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14669. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14670. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14671. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14672. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14673. builder.Write($"{item.HotelName}");
  14674. builder.InsertCell();
  14675. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14676. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14677. builder.InsertCell();
  14678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14679. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14680. builder.EndRow();
  14681. #endregion
  14682. #region 第四行
  14683. builder.InsertCell();
  14684. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14685. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14686. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14687. builder.ParagraphFormat.Style.Font.Bold = false;
  14688. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14689. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14690. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14691. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14692. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14693. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14694. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14695. builder.Write($"HOTEL ADDRESS:");
  14696. builder.InsertCell();
  14697. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14698. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14699. builder.ParagraphFormat.Style.Font.Size = 8;
  14700. builder.ParagraphFormat.Style.Font.Bold = false;
  14701. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14702. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14703. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14704. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14705. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14706. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14707. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14708. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14709. builder.Write($"{item.HotelAddress}");
  14710. builder.InsertCell();
  14711. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14712. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14713. builder.InsertCell();
  14714. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14715. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14716. builder.EndRow();
  14717. #endregion
  14718. #region 第五行
  14719. builder.InsertCell();
  14720. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14721. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14722. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14723. builder.ParagraphFormat.Style.Font.Bold = false;
  14724. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14725. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14726. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14727. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14728. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14729. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14730. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14731. builder.Write("TEL:");
  14732. builder.InsertCell();
  14733. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14734. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14735. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14736. builder.ParagraphFormat.Style.Font.Bold = false;
  14737. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14738. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14739. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14740. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14741. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14742. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14743. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14744. builder.Write($"{item.HotelTel}");
  14745. builder.InsertCell();
  14746. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14747. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14748. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14749. builder.ParagraphFormat.Style.Font.Bold = false;
  14750. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14751. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14752. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14753. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14754. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14755. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14756. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14757. builder.Write($"FAX:");
  14758. builder.InsertCell();
  14759. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14760. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14761. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14762. builder.ParagraphFormat.Style.Font.Bold = false;
  14763. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14764. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14765. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14766. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14767. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14768. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14769. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14770. builder.Write($"{item.HotelFax}");
  14771. builder.EndRow();
  14772. #endregion
  14773. #region 第六行
  14774. builder.InsertCell();
  14775. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14776. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14777. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14778. builder.ParagraphFormat.Style.Font.Bold = false;
  14779. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14780. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14781. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14782. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14783. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14784. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14785. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14786. builder.Write("CHECK IN:");
  14787. builder.InsertCell();
  14788. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14789. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14790. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14791. builder.ParagraphFormat.Style.Font.Bold = false;
  14792. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14793. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14794. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14795. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14796. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14797. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14798. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14799. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14800. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14801. builder.Write($"{checkInStr}");
  14802. builder.InsertCell();
  14803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14804. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14805. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14806. builder.ParagraphFormat.Style.Font.Bold = false;
  14807. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14808. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14809. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14810. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14811. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14812. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14813. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14814. builder.Write($"CHECK OUT:");
  14815. builder.InsertCell();
  14816. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14817. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14818. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14819. builder.ParagraphFormat.Style.Font.Bold = false;
  14820. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14821. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14822. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14823. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14824. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14825. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14826. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14827. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14828. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14829. builder.Write($"{checkOutStr}");
  14830. builder.EndRow();
  14831. #endregion
  14832. #region 第七行
  14833. builder.InsertCell();
  14834. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14835. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14836. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14837. builder.ParagraphFormat.Style.Font.Bold = false;
  14838. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14839. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14840. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14841. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14842. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14843. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14844. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14845. builder.Write($"GUEST NAME:");
  14846. builder.InsertCell();
  14847. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14848. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14849. builder.ParagraphFormat.Style.Font.Size = 8;
  14850. builder.ParagraphFormat.Style.Font.Bold = false;
  14851. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14852. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14853. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14854. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14855. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14856. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14857. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14858. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14859. builder.Write($"{item.GuestName}");
  14860. builder.InsertCell();
  14861. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14862. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14863. builder.InsertCell();
  14864. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14865. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14866. builder.EndRow();
  14867. #endregion
  14868. #region 第八行
  14869. builder.InsertCell();
  14870. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14871. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14872. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14873. builder.ParagraphFormat.Style.Font.Bold = false;
  14874. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14875. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14876. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14877. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14878. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14879. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14880. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14881. builder.Write($"ROOM TYPE:");
  14882. builder.InsertCell();
  14883. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14884. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14885. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14886. builder.ParagraphFormat.Style.Font.Bold = false;
  14887. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14888. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14889. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14890. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14891. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14892. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14893. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14894. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14895. builder.Write($"{item.RoomExplanation}");
  14896. builder.InsertCell();
  14897. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14898. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14899. builder.InsertCell();
  14900. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14901. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14902. builder.EndRow();
  14903. #endregion
  14904. #region 第九行
  14905. builder.InsertCell();
  14906. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14907. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14908. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14909. builder.ParagraphFormat.Style.Font.Bold = false;
  14910. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14911. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14912. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14913. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14914. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14915. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14916. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14917. builder.Write($"NOTE:");
  14918. builder.InsertCell();
  14919. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14920. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14921. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14922. builder.ParagraphFormat.Style.Font.Bold = false;
  14923. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14924. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14925. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14926. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14927. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  14928. builder.InsertCell();
  14929. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14930. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14931. builder.InsertCell();
  14932. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14933. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14934. builder.EndRow();
  14935. #endregion
  14936. builder.EndTable();
  14937. //换行
  14938. builder.Writeln("");
  14939. builder.Writeln("");
  14940. }
  14941. #region 获取文档中的所有表格 设置文字自适应
  14942. // 获取文档中的所有表格。
  14943. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14944. {
  14945. // 遍历表格中的所有行。
  14946. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14947. {
  14948. foreach (Cell cell in row.Cells)
  14949. {
  14950. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14951. cellFormat.Width = 0;
  14952. }
  14953. }
  14954. }
  14955. #endregion
  14956. #region 设置页眉
  14957. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14958. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14959. if (System.IO.File.Exists(voucherHeaderPath))
  14960. {
  14961. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14962. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14963. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14964. Shape shape = builder.InsertImage(imageBytes);
  14965. // 调整图片位置
  14966. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14967. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14968. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14969. shape.Left = 0; // 将图片距离页面左边缘的距离
  14970. shape.Width = 81; // 设置图片宽度
  14971. shape.Height = 36; // 设置图片高度
  14972. }
  14973. //靠右
  14974. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14975. //// 设置页脚上下边距
  14976. //builder.PageSetup.HeaderDistance = 42;
  14977. // 添加页眉线
  14978. Aspose.Words.Border borderHeader = null;
  14979. try
  14980. {
  14981. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14982. }
  14983. catch (Exception e)
  14984. {
  14985. // TODO Auto-generated catch block
  14986. //e.printStackTrace();
  14987. }
  14988. borderHeader.Shadow = true;
  14989. borderHeader.DistanceFromText = 2;
  14990. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  14991. #endregion
  14992. }
  14993. catch (Exception ex)
  14994. {
  14995. }
  14996. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14997. doc.Save(fileDir);
  14998. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14999. return Ok(JsonView(true, "操作成功!", Url));
  15000. }
  15001. /// <summary>
  15002. /// 酒店预订
  15003. /// 生成 预定成本 Excel
  15004. /// </summary>
  15005. /// <param name="_dto"></param>
  15006. /// <returns></returns>
  15007. [HttpPost]
  15008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15009. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15010. {
  15011. #region 参数验证
  15012. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15013. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15014. if (!vadalitorRes.IsValid)
  15015. {
  15016. var errors = new StringBuilder();
  15017. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15018. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15019. }
  15020. #region 团组操作权限验证 76 酒店预定模块
  15021. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15022. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15023. #endregion
  15024. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15025. #region 页面操作权限验证
  15026. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15027. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15028. #endregion
  15029. #endregion
  15030. decimal _rate = 1.00M;
  15031. string _currency = string.Empty;
  15032. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15033. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15034. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15035. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15036. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15037. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15038. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15039. if (_GroupCostParameter == null)
  15040. {
  15041. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15042. bool isIntType = int.TryParse(_currency, out int currId);
  15043. if (isIntType)
  15044. {
  15045. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15046. }
  15047. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15048. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15049. if (currInfo == null)
  15050. {
  15051. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15052. }
  15053. else _rate = currInfo.Rate;
  15054. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15055. {
  15056. _rate = _GroupCostParameter.Rate;
  15057. }
  15058. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15059. //string strFileName = "HotelStatement/";
  15060. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15061. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15062. var rateDatas = new List<dynamic>();
  15063. #region 数据处理
  15064. foreach (var item in hrDtas)
  15065. {
  15066. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15067. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15068. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15069. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15070. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15071. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15072. {
  15073. continue;
  15074. }
  15075. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15076. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15077. string singleRoomFeeStr = string.Empty,
  15078. doubleRoomFeeStr = string.Empty,
  15079. suiteRoomFeeStr = string.Empty,
  15080. otherRoomFeeStr = string.Empty,
  15081. payMoneyStr = string.Empty,
  15082. cardPriceStr = string.Empty;
  15083. if (roomCurr.Equals("CNY"))
  15084. {
  15085. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15086. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15087. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15088. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15089. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15090. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15091. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15092. }
  15093. else
  15094. {
  15095. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15096. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15097. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15098. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15099. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15100. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15101. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15102. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15103. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15104. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15105. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15106. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15107. if (ccpPaymentCurrency.Equals("CNY"))
  15108. {
  15109. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15110. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15111. }
  15112. else
  15113. {
  15114. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15115. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15116. }
  15117. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15118. if (hotelcardPriceCurrency.Equals("CNY"))
  15119. {
  15120. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15121. }
  15122. else
  15123. {
  15124. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15125. }
  15126. }
  15127. string breakfastPriceStr = string.Empty,
  15128. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15129. governmentRentStr = string.Empty,
  15130. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15131. cityTaxStr = string.Empty,
  15132. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15133. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15134. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15135. {
  15136. if (breakfastCurrency1.Equals("CNY"))
  15137. {
  15138. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15139. }
  15140. else
  15141. {
  15142. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15143. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15144. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15145. }
  15146. }
  15147. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15148. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15149. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15150. {
  15151. if (governmentRentCurrency.Equals("CNY"))
  15152. {
  15153. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15154. }
  15155. else
  15156. {
  15157. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15158. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15159. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15160. }
  15161. }
  15162. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15163. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15164. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15165. {
  15166. if (cityTaxStrCurrency1.Equals("CNY"))
  15167. {
  15168. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15169. }
  15170. else
  15171. {
  15172. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15173. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15174. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15175. }
  15176. }
  15177. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15178. int payDId = roomInfo?.PayDId ?? 0;
  15179. pcfds.Add(new HotelReservations_PCFD_View()
  15180. {
  15181. City = item.City,
  15182. HotelName = item.HotelName,
  15183. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15184. // SingleRoomCount = item.SingleRoomCount,
  15185. SingleRoomPrice = singleRoomFeeStr,
  15186. // DoubleRoomCount = item.DoubleRoomCount,
  15187. DoubleRoomPrice = doubleRoomFeeStr,
  15188. //SuiteRoomCount = item.SuiteRoomCount,
  15189. SuiteRoomPrice = suiteRoomFeeStr,
  15190. OtherRoomPrice = otherRoomFeeStr,
  15191. //OtherRoomCount = item.OtherRoomCount,
  15192. BreakfastPrice = breakfastPriceStr,
  15193. GovernmentRent = governmentRentStr,
  15194. CityTax = cityTaxStr,
  15195. RoomExplanation = item.RoomExplanation,
  15196. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15197. PayTime = roomInfo?.ConsumptionDate,
  15198. BankNo = roomInfo?.BankNo,
  15199. PayMoney = payMoneyStr,
  15200. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15201. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15202. CardPrice = cardPriceStr,
  15203. Remark = ccpInfo.Remark
  15204. });
  15205. }
  15206. #endregion
  15207. //载入模板
  15208. WorkbookDesigner designer = new WorkbookDesigner();
  15209. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15210. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15211. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15212. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15213. var rateDatas1 = rateDatas.Distinct();
  15214. var rateStr = string.Empty;
  15215. foreach (var item in rateDatas1)
  15216. {
  15217. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15218. }
  15219. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15220. designer.SetDataSource("Opertor", userInfo.CnName);
  15221. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15222. dt.TableName = "ViewMyHotelReservations";
  15223. designer.SetDataSource(dt);
  15224. designer.Process();
  15225. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15226. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15227. designer.Workbook.Save(serverPath);
  15228. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15229. #region 删除指定行
  15230. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15231. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15232. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15233. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15234. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15235. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15236. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15237. cssIndex = dt.Columns["CityTax"].Ordinal,
  15238. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15239. remarkIndex = dt.Columns["Remark"].Ordinal;
  15240. //删除指定列
  15241. foreach (DataRow item in dt.Rows)
  15242. {
  15243. string singleStr = item["SingleRoomPrice"].ToString();
  15244. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15245. if (containsDigitButNotZero1) singleDel = false;
  15246. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15247. string doubleStr = item["DoubleRoomPrice"].ToString();
  15248. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15249. if (containsDigitButNotZero2) doubleDel = false;
  15250. string suiteStr = item["SuiteRoomPrice"].ToString();
  15251. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15252. if (containsDigitButNotZero3) suiteDel = false;
  15253. string otherStr = item["OtherRoomPrice"].ToString();
  15254. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15255. if (containsDigitButNotZero4) otherDel = false;
  15256. string zcStr = item["BreakfastPrice"].ToString();
  15257. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15258. if (containsDigitButNotZero5) zcDel = false;
  15259. string dsStr = item["GovernmentRent"].ToString();
  15260. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15261. if (containsDigitButNotZero6) dsDel = false;
  15262. string cssStr = item["CityTax"].ToString();
  15263. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15264. if (containsDigitButNotZero7) cssDel = false;
  15265. string cpStr = item["ConsumptionPatterns"].ToString();
  15266. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15267. string remarkStr = item["Remark"].ToString();
  15268. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15269. }
  15270. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15271. DeleteColumn(serverPath, cpIndex, cpDel);
  15272. DeleteColumn(serverPath, dsIndex, dsDel);
  15273. DeleteColumn(serverPath, cssIndex, cssDel);
  15274. DeleteColumn(serverPath, zcIndex, zcDel);
  15275. DeleteColumn(serverPath, otherIndex, otherDel);
  15276. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15277. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15278. DeleteColumn(serverPath, singleIndex, singleDel);
  15279. #endregion
  15280. //只保留第一个表格
  15281. DeleteSheet(serverPath);
  15282. return Ok(JsonView(true, "操作成功", url = rst));
  15283. }
  15284. else
  15285. {
  15286. _currency = _GroupCostParameter.Currency;
  15287. bool isIntType = int.TryParse(_currency, out int currId);
  15288. if (isIntType)
  15289. {
  15290. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15291. }
  15292. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15293. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15294. if (currInfo == null)
  15295. {
  15296. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15297. }
  15298. if (!_currency.ToUpper().Equals("CNY"))
  15299. {
  15300. _rate = _GroupCostParameter.Rate;
  15301. }
  15302. _rate = currInfo.Rate;
  15303. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15304. //string strFileName = "HotelStatement/";
  15305. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15306. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15307. #region 数据处理
  15308. foreach (var item in hrDtas)
  15309. {
  15310. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15311. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15312. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15313. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15314. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15315. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15316. string singleRoomFeeStr = string.Empty,
  15317. doubleRoomFeeStr = string.Empty,
  15318. suiteRoomFeeStr = string.Empty,
  15319. otherRoomFeeStr = string.Empty,
  15320. payMoneyStr = string.Empty,
  15321. cardPriceStr = string.Empty;
  15322. if (roomCurr.Equals(_currency))
  15323. {
  15324. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15325. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15326. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15327. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15328. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15329. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15330. }
  15331. else
  15332. {
  15333. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15334. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15335. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15336. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15337. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15338. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15339. }
  15340. string breakfastPriceStr = string.Empty,
  15341. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15342. governmentRentStr = string.Empty,
  15343. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15344. cityTaxStrStr = string.Empty,
  15345. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15346. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15347. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15348. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15349. int payDId = roomInfo?.PayDId ?? 0;
  15350. pcfds.Add(new HotelReservations_PCFD_View()
  15351. {
  15352. City = item.City,
  15353. HotelName = item.HotelName,
  15354. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15355. // SingleRoomCount = item.SingleRoomCount,
  15356. SingleRoomPrice = singleRoomFeeStr,
  15357. // DoubleRoomCount = item.DoubleRoomCount,
  15358. DoubleRoomPrice = doubleRoomFeeStr,
  15359. //SuiteRoomCount = item.SuiteRoomCount,
  15360. SuiteRoomPrice = suiteRoomFeeStr,
  15361. OtherRoomPrice = otherRoomFeeStr,
  15362. //OtherRoomCount = item.OtherRoomCount,
  15363. BreakfastPrice = breakfastPriceStr,
  15364. GovernmentRent = governmentRentStr,
  15365. CityTax = cityTaxStrStr,
  15366. RoomExplanation = item.RoomExplanation,
  15367. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15368. PayTime = roomInfo?.ConsumptionDate,
  15369. BankNo = roomInfo?.BankNo,
  15370. PayMoney = payMoneyStr,
  15371. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15372. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15373. CardPrice = cardPriceStr,
  15374. Remark = ccpInfo.Remark
  15375. });
  15376. }
  15377. #endregion
  15378. //载入模板
  15379. WorkbookDesigner designer = new WorkbookDesigner();
  15380. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15381. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15382. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15383. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15384. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15385. designer.SetDataSource("Opertor", userInfo.CnName);
  15386. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15387. dt.TableName = "ViewMyHotelReservations";
  15388. designer.SetDataSource(dt);
  15389. designer.Process();
  15390. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15391. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15392. designer.Workbook.Save(serverPath);
  15393. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15394. #region 删除指定行
  15395. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15396. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15397. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15398. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15399. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15400. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15401. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15402. cssIndex = dt.Columns["CityTax"].Ordinal,
  15403. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15404. remarkIndex = dt.Columns["Remark"].Ordinal;
  15405. //删除指定列
  15406. foreach (DataRow item in dt.Rows)
  15407. {
  15408. string singleStr = item["SingleRoomPrice"].ToString();
  15409. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15410. if (containsDigitButNotZero1) singleDel = false;
  15411. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15412. string doubleStr = item["DoubleRoomPrice"].ToString();
  15413. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15414. if (containsDigitButNotZero2) doubleDel = false;
  15415. string suiteStr = item["SuiteRoomPrice"].ToString();
  15416. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15417. if (containsDigitButNotZero3) suiteDel = false;
  15418. string otherStr = item["OtherRoomPrice"].ToString();
  15419. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15420. if (containsDigitButNotZero4) otherDel = false;
  15421. string zcStr = item["BreakfastPrice"].ToString();
  15422. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15423. if (containsDigitButNotZero5) zcDel = false;
  15424. string dsStr = item["GovernmentRent"].ToString();
  15425. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15426. if (containsDigitButNotZero6) dsDel = false;
  15427. string cssStr = item["CityTax"].ToString();
  15428. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15429. if (containsDigitButNotZero7) cssDel = false;
  15430. string cpStr = item["ConsumptionPatterns"].ToString();
  15431. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15432. string remarkStr = item["Remark"].ToString();
  15433. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15434. }
  15435. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15436. DeleteColumn(serverPath, cpIndex, cpDel);
  15437. DeleteColumn(serverPath, dsIndex, dsDel);
  15438. DeleteColumn(serverPath, cssIndex, cssDel);
  15439. DeleteColumn(serverPath, zcIndex, zcDel);
  15440. DeleteColumn(serverPath, otherIndex, otherDel);
  15441. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15442. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15443. DeleteColumn(serverPath, singleIndex, singleDel);
  15444. #endregion
  15445. //只保留第一个表格
  15446. DeleteSheet(serverPath);
  15447. return Ok(JsonView(true, "操作成功", url = rst));
  15448. }
  15449. //return Ok(JsonView(false));
  15450. }
  15451. /// <summary>
  15452. /// 删除指定列
  15453. /// </summary>
  15454. /// <param name="file"></param>
  15455. /// <param name="columnIndex"></param>
  15456. /// <param name="isDel"></param>
  15457. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15458. {
  15459. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15460. //wb.Save(file);
  15461. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15462. if (sheet1 != null)
  15463. {
  15464. if (isDel)
  15465. {
  15466. Cells cells = sheet1.Cells;
  15467. cells.DeleteColumn(columnIndex);
  15468. }
  15469. }
  15470. wb.Save(file);
  15471. }
  15472. /// <summary>
  15473. /// 删除sheet
  15474. /// </summary>
  15475. /// <param name="file"></param>
  15476. /// <param name="sheetName"></param>
  15477. private void DeleteSheet(string file, string sheetName = "")
  15478. {
  15479. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15480. //wb.Save(file);
  15481. List<string> sheets = new List<string>();
  15482. foreach (var item in wb.Worksheets)
  15483. {
  15484. sheets.Add(item.Name);
  15485. }
  15486. if (sheets.Count > 0)
  15487. {
  15488. sheets.RemoveAt(0);//不删除第一个sheet
  15489. foreach (var item in sheets)
  15490. {
  15491. wb.Worksheets.RemoveAt(item);
  15492. }
  15493. }
  15494. wb.Save(file);
  15495. }
  15496. /// <summary>
  15497. /// 酒店预订
  15498. /// 确认单
  15499. /// </summary>
  15500. /// <param name="_dto"></param>
  15501. /// <returns></returns>
  15502. [HttpPost]
  15503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15504. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15505. {
  15506. try
  15507. {
  15508. #region 参数验证
  15509. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15510. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15511. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15512. #region 团组操作权限验证 76 酒店预定模块
  15513. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15514. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15515. #endregion
  15516. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15517. #region 页面操作权限验证
  15518. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15519. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15520. #endregion
  15521. #endregion
  15522. //团组信息
  15523. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15524. //酒店数据
  15525. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15526. if (listhoteldata.Count < 0)
  15527. {
  15528. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15529. }
  15530. //利datatable存储
  15531. DataTable dt = new DataTable();
  15532. dt.Columns.Add("CheckInDate", typeof(string));
  15533. dt.Columns.Add("City", typeof(string));
  15534. dt.Columns.Add("Hotel", typeof(string));
  15535. dt.Columns.Add("Room", typeof(string));
  15536. for (int i = 0; i < listhoteldata.Count; i++)
  15537. {
  15538. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15539. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15540. while (dayStart < dayEnd)
  15541. {
  15542. string temp = "";
  15543. DataRow row = dt.NewRow();
  15544. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15545. row["City"] = listhoteldata[i].City;
  15546. row["Hotel"] = listhoteldata[i].HotelName;
  15547. if (listhoteldata[i].SingleRoomCount > 0)
  15548. {
  15549. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15550. }
  15551. if (listhoteldata[i].DoubleRoomCount > 0)
  15552. {
  15553. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15554. }
  15555. if (listhoteldata[i].SuiteRoomCount > 0)
  15556. {
  15557. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15558. }
  15559. if (listhoteldata[i].OtherRoomCount > 0)
  15560. {
  15561. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15562. }
  15563. row["Room"] = temp;
  15564. dt.Rows.Add(row);
  15565. dayStart = dayStart.AddDays(1);
  15566. }
  15567. }
  15568. Dictionary<string, string> dic = new Dictionary<string, string>();
  15569. dic.Add("Dele", di.TeamName);
  15570. dic.Add("City", di.VisitCountry);
  15571. //模板路径
  15572. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15573. //载入模板
  15574. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15575. DocumentBuilder builder = new DocumentBuilder(doc);
  15576. foreach (var key in dic.Keys)
  15577. {
  15578. builder.MoveToBookmark(key);
  15579. builder.Write(dic[key]);
  15580. }
  15581. //获取word里所有表格
  15582. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15583. //获取所填表格的序数
  15584. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15585. var rowStart = tableOne.Rows[0]; //获取第1行
  15586. //循环赋值
  15587. for (int i = 0; i < dt.Rows.Count; i++)
  15588. {
  15589. builder.MoveToCell(0, i + 1, 0, 0);
  15590. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15591. builder.MoveToCell(0, i + 1, 1, 0);
  15592. builder.Write(dt.Rows[i]["City"].ToString());
  15593. builder.MoveToCell(0, i + 1, 2, 0);
  15594. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15595. builder.MoveToCell(0, i + 1, 3, 0);
  15596. builder.Write(dt.Rows[i]["Room"].ToString());
  15597. }
  15598. //删除多余行
  15599. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15600. {
  15601. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15602. }
  15603. string strFileName = di.TeamName + "酒店确认单.doc";
  15604. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15605. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15606. return Ok(JsonView(true, "成功", url));
  15607. }
  15608. catch (Exception ex)
  15609. {
  15610. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15611. }
  15612. }
  15613. #endregion
  15614. #region 团组状态
  15615. /// <summary>
  15616. /// 团组状态列表 Page
  15617. /// </summary>
  15618. /// <param name="dto">团组列表请求dto</param>
  15619. /// <returns></returns>
  15620. [HttpPost]
  15621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15622. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15623. {
  15624. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15625. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15626. {
  15627. string sqlWhere = string.Empty;
  15628. if (dto.IsSure == 0) //未完成
  15629. {
  15630. sqlWhere += string.Format(@" And IsSure = 0");
  15631. }
  15632. else if (dto.IsSure == 1) //已完成
  15633. {
  15634. sqlWhere += string.Format(@" And IsSure = 1");
  15635. }
  15636. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15637. {
  15638. string tj = dto.SearchCriteria;
  15639. 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}%')",
  15640. tj, tj, tj, tj, tj);
  15641. }
  15642. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15643. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15644. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15645. From (
  15646. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15647. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15648. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15649. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15650. From Grp_DelegationInfo gdi
  15651. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15652. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15653. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15654. Where gdi.IsDel = 0 {0}
  15655. ) temp ", sqlWhere);
  15656. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15657. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15658. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15659. }
  15660. else
  15661. {
  15662. return Ok(JsonView(false, "查询失败"));
  15663. }
  15664. }
  15665. /// <summary>
  15666. /// 团组状态
  15667. /// 设置操作完成
  15668. /// </summary>
  15669. /// <param name="dto">团组列表请求dto</param>
  15670. /// <returns></returns>
  15671. [HttpPost]
  15672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15673. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15674. {
  15675. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15676. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15677. {
  15678. Id = dto.Id,
  15679. IsSure = 1
  15680. };
  15681. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15682. .UpdateColumns(it => new { it.IsSure })
  15683. .WhereColumns(it => new { it.Id })
  15684. .ExecuteCommandAsync();
  15685. if (result > 0)
  15686. {
  15687. return Ok(JsonView(true, "操作完成!"));
  15688. }
  15689. return Ok(JsonView(false, "操作失败!"));
  15690. }
  15691. #endregion
  15692. #region 保险费用录入
  15693. /// <summary>
  15694. /// 根据团组Id查询保险费用列表
  15695. /// </summary>
  15696. /// <param name="dto"></param>
  15697. /// <returns></returns>
  15698. [HttpPost]
  15699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15700. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15701. {
  15702. Result groupData = await _customersRep.CustomersByDiId(dto);
  15703. if (groupData.Code != 0)
  15704. {
  15705. return Ok(JsonView(false, groupData.Msg));
  15706. }
  15707. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15708. }
  15709. /// <summary>
  15710. /// 根据保险费用Id查询保险费用详细
  15711. /// </summary>
  15712. /// <param name="dto"></param>
  15713. /// <returns></returns>
  15714. [HttpPost]
  15715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15716. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15717. {
  15718. try
  15719. {
  15720. Result groupData = await _customersRep.CustomersById(dto);
  15721. if (groupData.Code != 0)
  15722. {
  15723. return Ok(JsonView(false, groupData.Msg));
  15724. }
  15725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15726. }
  15727. catch (Exception ex)
  15728. {
  15729. return Ok(JsonView(false, ex.Message));
  15730. }
  15731. }
  15732. /// <summary>
  15733. /// 保险费用录入页面初始化绑定
  15734. /// </summary>
  15735. /// <param name="dto"></param>
  15736. /// <returns></returns>
  15737. [HttpPost]
  15738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15739. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15740. {
  15741. try
  15742. {
  15743. Result groupData = await _customersRep.CustomersInitialize(dto);
  15744. if (groupData.Code != 0)
  15745. {
  15746. return Ok(JsonView(false, groupData.Msg));
  15747. }
  15748. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15749. }
  15750. catch (Exception ex)
  15751. {
  15752. return Ok(JsonView(false, ex.Message));
  15753. }
  15754. }
  15755. /// <summary>
  15756. /// 保险费用操作(Status:1.新增,2.修改)
  15757. /// </summary>
  15758. /// <param name="dto"></param>
  15759. /// <returns></returns>
  15760. [HttpPost]
  15761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15762. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15763. {
  15764. Result groupData = await _customersRep.OpCustomers(dto);
  15765. if (groupData.Code != 0)
  15766. {
  15767. return Ok(JsonView(false, groupData.Msg));
  15768. }
  15769. #region 应用推送
  15770. try
  15771. {
  15772. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15773. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15774. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15775. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15776. //自动审核
  15777. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15778. //2024-10-21 新增LZ UID
  15779. var userIds = new List<int>() { 21 };
  15780. string title = $"系统通知";
  15781. var diId = dto.DiId;
  15782. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15783. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15784. string content = "";
  15785. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15786. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15787. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15788. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15789. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15790. }
  15791. catch (Exception ex)
  15792. {
  15793. }
  15794. #endregion
  15795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15796. }
  15797. /// <summary>
  15798. /// 保险文件上传
  15799. /// </summary>
  15800. /// <param name="file"></param>
  15801. /// <returns></returns>
  15802. [HttpPost]
  15803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15804. public async Task<IActionResult> UploadCus(IFormFile file)
  15805. {
  15806. try
  15807. {
  15808. if (file != null)
  15809. {
  15810. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15811. //文件名称
  15812. string projectFileName = file.FileName;
  15813. //上传的文件的路径
  15814. string filePath = "";
  15815. if (!Directory.Exists(fileDir))
  15816. {
  15817. Directory.CreateDirectory(fileDir);
  15818. }
  15819. //上传的文件的路径
  15820. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15821. using (FileStream fs = System.IO.File.Create(filePath))
  15822. {
  15823. file.CopyTo(fs);
  15824. fs.Flush();
  15825. }
  15826. return Ok(JsonView(true, "上传成功!", projectFileName));
  15827. }
  15828. else
  15829. {
  15830. return Ok(JsonView(false, "上传失败!"));
  15831. }
  15832. }
  15833. catch (Exception ex)
  15834. {
  15835. return Ok(JsonView(false, "程序错误!"));
  15836. throw;
  15837. }
  15838. }
  15839. /// <summary>
  15840. /// 保险删除指定文件
  15841. /// </summary>
  15842. /// <param name="dto"></param>
  15843. /// <returns></returns>
  15844. [HttpPost]
  15845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15846. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15847. {
  15848. try
  15849. {
  15850. string filePath = "";
  15851. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15852. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15853. //int id = 0;
  15854. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15855. // 删除该文件
  15856. try
  15857. {
  15858. System.IO.File.Delete(filePath);
  15859. 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()
  15860. {
  15861. Attachment = "",
  15862. }).ExecuteCommandAsync();
  15863. if (result != 0)
  15864. {
  15865. return Ok(JsonView(true, "成功!"));
  15866. }
  15867. else
  15868. {
  15869. return Ok(JsonView(false, "失败!"));
  15870. }
  15871. }
  15872. catch (Exception)
  15873. {
  15874. 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()
  15875. {
  15876. Attachment = "",
  15877. }).ExecuteCommandAsync();
  15878. if (result != 0)
  15879. {
  15880. return Ok(JsonView(true, "成功!"));
  15881. }
  15882. else
  15883. {
  15884. return Ok(JsonView(false, "失败!"));
  15885. }
  15886. }
  15887. }
  15888. catch (Exception ex)
  15889. {
  15890. return Ok(JsonView(false, "程序错误!"));
  15891. throw;
  15892. }
  15893. }
  15894. /// <summary>
  15895. /// 保险费用操作(删除)
  15896. /// </summary>
  15897. /// <param name="dto"></param>
  15898. /// <returns></returns>
  15899. [HttpPost]
  15900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15901. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15902. {
  15903. try
  15904. {
  15905. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15906. if (!res)
  15907. {
  15908. return Ok(JsonView(false, "删除失败"));
  15909. }
  15910. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15911. {
  15912. IsDel = 1,
  15913. DeleteUserId = dto.DeleteUserId,
  15914. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15915. }).ExecuteCommandAsync();
  15916. return Ok(JsonView(true, "删除成功!"));
  15917. }
  15918. catch (Exception ex)
  15919. {
  15920. return Ok(JsonView(false, "程序错误!"));
  15921. throw;
  15922. }
  15923. }
  15924. #endregion
  15925. #region 接团客户名单 PageId 104
  15926. /// <summary>
  15927. /// 接团客户名单
  15928. /// 迁移数据(慎用!)
  15929. /// </summary>
  15930. /// <returns></returns>
  15931. [HttpPost]
  15932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15933. public async Task<IActionResult> PostTourClientListChange()
  15934. {
  15935. try
  15936. {
  15937. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15938. //var groupClinetData1
  15939. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15940. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15941. int updateCount = 0;
  15942. if (oldOAClientList.Count > 0)
  15943. {
  15944. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15945. _sqlSugar.BeginTran();
  15946. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15947. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15948. foreach (var item in oldOAClientList)
  15949. {
  15950. int comId = 0;
  15951. string format = "yyyy-MM-dd HH:mm:ss";
  15952. string data11 = "1990-01-01 00:00";
  15953. var data1 = IsValidDate(item.OPdate, format);
  15954. if (data1) data11 = item.OPdate;
  15955. //客户公司验证
  15956. if (!string.IsNullOrEmpty(item.Company))
  15957. {
  15958. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15959. if (clientComInfo == null) // add
  15960. {
  15961. var addInfo = new Crm_CustomerCompany()
  15962. {
  15963. CompanyAbbreviation = "",
  15964. CompanyFullName = item.Company,
  15965. Address = "",
  15966. PostCodes = "",
  15967. LastedOpUserId = item.OPer,
  15968. LastedOpDt = Convert.ToDateTime(data11),
  15969. CreateUserId = item.OPer,
  15970. CreateTime = Convert.ToDateTime(data11),
  15971. IsDel = 0
  15972. };
  15973. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15974. if (comId1 > 0) comId = comId1;
  15975. }
  15976. else comId = clientComInfo.Id;
  15977. }
  15978. //客户人员验证
  15979. int clientId = 0;
  15980. string name = item.LastName + item.Name;
  15981. if (!string.IsNullOrEmpty(name))
  15982. {
  15983. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15984. if (clientInfo == null)
  15985. {
  15986. DateTime? dateTime = null;
  15987. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  15988. if (isDt) dateTime = birthDayDt;
  15989. var addInfo1 = new Crm_DeleClient()
  15990. {
  15991. CrmCompanyId = comId,
  15992. DiId = -1,
  15993. LastName = item.LastName,
  15994. FirstName = item.Name,
  15995. OldName = "",
  15996. Pinyin = item.Pinyin,
  15997. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  15998. Marriage = 0,
  15999. Phone = item.Phone,
  16000. Job = item.Job,
  16001. BirthDay = dateTime
  16002. };
  16003. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16004. if (clientId1 > 0) clientId = clientId1;
  16005. }
  16006. else clientId = clientInfo.Id;
  16007. }
  16008. if (clientId < 1)
  16009. {
  16010. continue;
  16011. }
  16012. int airType = 0;
  16013. if (item.AirType == "超经舱") airType = 459;
  16014. else if (item.AirType == "公务舱") airType = 458;
  16015. else if (item.AirType == "经济舱") airType = 460;
  16016. else if (item.AirType == "其他") airType = 565;
  16017. else if (item.AirType == "头等舱") airType = 457;
  16018. var _TourClientListEntity = new Grp_TourClientList()
  16019. {
  16020. DiId = item.Diid,
  16021. ClientId = clientId,
  16022. CreateUserId = item.OPer,
  16023. CreateTime = Convert.ToDateTime(data11),
  16024. Remark = item.Remark,
  16025. IsDel = item.Isdel,
  16026. ShippingSpaceTypeId = airType,
  16027. ShippingSpaceSpecialNeeds = item.AirRemark,
  16028. HotelSpecialNeeds = item.RoomType
  16029. };
  16030. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16031. if (_TourClientList > 0)
  16032. {
  16033. updateCount++;
  16034. }
  16035. }
  16036. _sqlSugar.CommitTran();
  16037. }
  16038. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16039. }
  16040. catch (Exception ex)
  16041. {
  16042. _sqlSugar.RollbackTran();
  16043. return Ok(JsonView(false, ex.Message));
  16044. }
  16045. //return Ok(JsonView(true));
  16046. }
  16047. private bool IsValidDate(string dateString, string format)
  16048. {
  16049. DateTime dateValue;
  16050. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16051. return valid;
  16052. }
  16053. /// <summary>
  16054. /// 接团客户名单
  16055. /// 根据团组Id查询List
  16056. /// </summary>
  16057. /// <param name="_dto"></param>
  16058. /// <returns></returns>
  16059. [HttpPost]
  16060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16061. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16062. {
  16063. #region 参数验证
  16064. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16065. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16066. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16067. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16068. #region 页面操作权限验证
  16069. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16070. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16071. #endregion
  16072. #endregion
  16073. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16074. if (viewData.Code != 0)
  16075. {
  16076. return Ok(JsonView(false, viewData.Msg));
  16077. }
  16078. return Ok(JsonView(viewData.Data));
  16079. }
  16080. /// <summary>
  16081. /// 接团客户名单
  16082. /// 基础数据 Init
  16083. /// </summary>
  16084. /// <param name="_dto"></param>
  16085. /// <returns></returns>
  16086. [HttpPost]
  16087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16088. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16089. {
  16090. #region 参数验证
  16091. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16092. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16093. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16094. #region 页面操作权限验证
  16095. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16096. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16097. #endregion
  16098. #endregion
  16099. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16100. }
  16101. /// <summary>
  16102. /// 接团客户名单
  16103. /// 根据 Id查询 Details
  16104. /// </summary>
  16105. /// <param name="_dto"></param>
  16106. /// <returns></returns>
  16107. [HttpPost]
  16108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16109. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16110. {
  16111. #region 参数验证
  16112. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16113. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16114. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16115. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16116. #region 页面操作权限验证
  16117. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16118. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16119. #endregion
  16120. #endregion
  16121. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16122. if (viewData.Code != 0)
  16123. {
  16124. return Ok(JsonView(false, viewData.Msg));
  16125. }
  16126. return Ok(JsonView(viewData.Data));
  16127. }
  16128. /// <summary>
  16129. /// 接团客户名单
  16130. /// Add Or Edit
  16131. /// </summary>
  16132. /// <param name="_dto"></param>
  16133. /// <returns></returns>
  16134. [HttpPost]
  16135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16136. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16137. {
  16138. #region 参数验证
  16139. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16140. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16141. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16142. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16143. #region 页面操作权限验证
  16144. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16145. if (_dto.Id == 0) //添加
  16146. {
  16147. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16148. }
  16149. else if (_dto.Id >= 0) //修改
  16150. {
  16151. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16152. }
  16153. #endregion
  16154. #endregion
  16155. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16156. if (viewData.Code != 0)
  16157. {
  16158. return Ok(JsonView(false, viewData.Msg));
  16159. }
  16160. return Ok(JsonView(true));
  16161. }
  16162. /// <summary>
  16163. /// 接团客户名单
  16164. /// json字符串 AddMultiple(添加多个)
  16165. /// </summary>
  16166. /// <param name="_dto"></param>
  16167. /// <returns></returns>
  16168. [HttpPost]
  16169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16170. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16171. {
  16172. #region 参数验证
  16173. string jsonLabel = _dto.JsonLabel;
  16174. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16175. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16176. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16177. #region 页面操作权限验证
  16178. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16179. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16180. #endregion
  16181. #endregion
  16182. var request = new TourClientListAddMultipleDto();
  16183. request.DiId = _dto.DiId;
  16184. request.UserId = _dto.UserId;
  16185. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16186. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16187. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16188. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16189. var infos = new List<TourClientListInfo>();
  16190. foreach (var data in datas)
  16191. {
  16192. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16193. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16194. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16195. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16196. {
  16197. continue;
  16198. }
  16199. infos.Add(new TourClientListInfo()
  16200. {
  16201. IsAccompany = 1,
  16202. LastName = lastName,
  16203. FirstName = firstName,
  16204. Pinyin = lastNameEn + @"/" + firstNameEn,
  16205. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16206. CompanyFullName = data.CompanyFullName,
  16207. Job = data.Job
  16208. });
  16209. }
  16210. if (infos.Any())
  16211. {
  16212. var viewData = await _tourClientListRep._AddMultiple(request);
  16213. if (viewData.Code != 0)
  16214. {
  16215. return Ok(JsonView(false, viewData.Msg));
  16216. }
  16217. return Ok(JsonView(true));
  16218. }
  16219. return Ok(JsonView(false));
  16220. }
  16221. /// <summary>
  16222. /// 接团客户名单
  16223. /// AddMultiple(添加多个)
  16224. /// </summary>
  16225. /// <param name="_dto"></param>
  16226. /// <returns></returns>
  16227. [HttpPost]
  16228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16229. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16230. {
  16231. #region 参数验证
  16232. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16233. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16234. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16235. #region 页面操作权限验证
  16236. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16237. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16238. #endregion
  16239. #endregion
  16240. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16241. if (viewData.Code != 0)
  16242. {
  16243. return Ok(JsonView(false, viewData.Msg));
  16244. }
  16245. return Ok(JsonView(true));
  16246. }
  16247. /// <summary>
  16248. /// 接团客户名单
  16249. /// Del
  16250. /// </summary>
  16251. /// <param name="_dto"></param>
  16252. /// <returns></returns>
  16253. [HttpPost]
  16254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16255. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16256. {
  16257. #region 参数验证
  16258. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16259. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16260. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16261. #region 页面操作权限验证
  16262. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16263. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16264. #endregion
  16265. #endregion
  16266. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16267. if (viewData.Code != 0)
  16268. {
  16269. return Ok(JsonView(false, viewData.Msg));
  16270. }
  16271. return Ok(JsonView(true));
  16272. }
  16273. /// <summary>
  16274. /// 接团客户名单
  16275. /// 文件下载 客户名单
  16276. /// </summary>
  16277. /// <param name="_dto"></param>
  16278. /// <returns></returns>
  16279. [HttpPost]
  16280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16281. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16282. {
  16283. #region 参数验证
  16284. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16285. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16286. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16287. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16288. #region 页面操作权限验证
  16289. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16290. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16291. #endregion
  16292. #endregion
  16293. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16294. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16295. From Grp_TourClientList tcl
  16296. Left Join
  16297. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16298. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16299. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16300. From Crm_DeleClient dc
  16301. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16302. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16303. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16304. Where dc.IsDel = 0) temp
  16305. On temp.DcId =tcl.ClientId
  16306. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16307. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16308. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16309. //载入模板
  16310. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16311. if (_dto.Language == 1)
  16312. {
  16313. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16314. }
  16315. //载入模板
  16316. var doc = new Document(tempPath);
  16317. DocumentBuilder builder = new DocumentBuilder(doc);
  16318. //获取word里所有表格
  16319. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16320. //获取所填表格的序数
  16321. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16322. var rowStart = tableOne.Rows[0]; //获取第1行
  16323. if (_dto.Language == 0)
  16324. {
  16325. //循环赋值
  16326. for (int i = 0; i < DcList.Count; i++)
  16327. {
  16328. EncryptionProcessor.DecryptProperties(DcList[i]);
  16329. builder.MoveToCell(0, i + 1, 0, 0);
  16330. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16331. builder.MoveToCell(0, i + 1, 1, 0);
  16332. int sex = DcList[i].Sex;
  16333. string sexStr = string.Empty;
  16334. if (sex == 0) sexStr = "男";
  16335. else if (sex == 1) sexStr = "女";
  16336. else sexStr = "未设置";
  16337. builder.Write(sexStr);
  16338. builder.MoveToCell(0, i + 1, 2, 0);
  16339. string birthDay = DcList[i].BirthDay;
  16340. string birthDayStr = string.Empty;
  16341. if (!string.IsNullOrEmpty(birthDay))
  16342. {
  16343. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16344. }
  16345. builder.Write(birthDayStr);
  16346. builder.MoveToCell(0, i + 1, 3, 0);
  16347. string company = "";
  16348. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16349. {
  16350. company = DcList[i].CompanyFullName.ToString();
  16351. }
  16352. builder.Write(company);
  16353. builder.MoveToCell(0, i + 1, 4, 0);
  16354. builder.Write(DcList[i].Job);
  16355. }
  16356. }
  16357. else if (_dto.Language == 1)
  16358. {
  16359. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16360. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16361. List<string> transArrayStr = new List<string>();
  16362. string transStrRes1 = "";
  16363. for (int i = 0; i < DcList.Count; i++)
  16364. {
  16365. var dc = DcList[i];
  16366. EncryptionProcessor.DecryptProperties(dc);
  16367. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16368. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16369. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16370. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16371. else transStrRes1 += $"{str1}|";
  16372. }
  16373. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  16374. string transStrRes = "";
  16375. if (transStrRes1.Length > 0)
  16376. {
  16377. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16378. }
  16379. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  16380. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16381. //List<string> transArray = new List<string> { };
  16382. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16383. if (transStrRes.Contains("|"))
  16384. {
  16385. string[] transArray1 = transStrRes.Split('|');
  16386. if (transArray1.Length > 0)
  16387. {
  16388. foreach (var item in transArray1)
  16389. {
  16390. if (item.Contains("&"))
  16391. {
  16392. string[] transArray2 = item.Split('&');
  16393. int index = 0;
  16394. string companyName = "", job = "";
  16395. if (transArray2.Length > 0)
  16396. {
  16397. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16398. if (1 < transArray2.Length) companyName = transArray2[1];
  16399. if (2 < transArray2.Length) job = transArray2[2];
  16400. }
  16401. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16402. }
  16403. }
  16404. }
  16405. }
  16406. //循环赋值
  16407. for (int i = 0; i < DcList.Count; i++)
  16408. {
  16409. string PYName = "";
  16410. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16411. {
  16412. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16413. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16414. PYName = PY_First + " " + PY_Last;
  16415. }
  16416. else
  16417. {
  16418. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16419. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16420. PYName = PY_First + " " + PY_Last;
  16421. }
  16422. builder.MoveToCell(0, i + 1, 0, 0);
  16423. builder.Write(PYName);
  16424. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16425. builder.MoveToCell(0, i + 1, 1, 0);
  16426. builder.Write(sex);
  16427. DateTime birthDt;
  16428. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16429. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16430. builder.MoveToCell(0, i + 1, 2, 0);
  16431. builder.Write(birthday);
  16432. string company = string.Empty, job = string.Empty;
  16433. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16434. if (dcTransInfo != null)
  16435. {
  16436. company = dcTransInfo.CompanyName;
  16437. job = dcTransInfo.Job;
  16438. }
  16439. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16440. {
  16441. //查询对照表
  16442. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16443. if (tempCec != null)
  16444. {
  16445. company = tempCec.enName;
  16446. }
  16447. //翻译
  16448. else
  16449. {
  16450. }
  16451. }
  16452. builder.MoveToCell(0, i + 1, 3, 0);
  16453. builder.Write(company);
  16454. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16455. {
  16456. //查询对照表
  16457. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16458. if (tempPec != null)
  16459. {
  16460. job = tempPec.enName;
  16461. }
  16462. //翻译
  16463. else
  16464. {
  16465. }
  16466. }
  16467. builder.MoveToCell(0, i + 1, 4, 0);
  16468. builder.Write(job);
  16469. }
  16470. }
  16471. //删除多余行
  16472. while (tableOne.Rows.Count > DcList.Count + 1)
  16473. {
  16474. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16475. }
  16476. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16477. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16478. doc.Save(fileDir);
  16479. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16480. return Ok(JsonView(true, "操作成功!", Url));
  16481. }
  16482. private class TranslateInfo
  16483. {
  16484. public int Index { get; set; }
  16485. public string CompanyName { get; set; }
  16486. public string Job { get; set; }
  16487. }
  16488. #endregion
  16489. #region 团组倒推表
  16490. /// <summary>
  16491. /// 倒推表基础数据
  16492. /// Init
  16493. /// </summary>
  16494. /// <returns></returns>
  16495. [HttpPost]
  16496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16497. public async Task<IActionResult> PostInvertedListInit()
  16498. {
  16499. var viewData = await _invertedListRep._Init();
  16500. if (viewData.Code != 0)
  16501. {
  16502. return Ok(JsonView(false, viewData.Msg));
  16503. }
  16504. return Ok(JsonView(viewData.Data));
  16505. }
  16506. /// <summary>
  16507. /// 倒推表
  16508. /// Info
  16509. /// </summary>
  16510. /// <param name="dto"></param>
  16511. /// <returns></returns>
  16512. [HttpPost]
  16513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16514. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16515. {
  16516. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16517. if (viewData.Code != 0)
  16518. {
  16519. return Ok(JsonView(false, viewData.Msg));
  16520. }
  16521. return Ok(JsonView(viewData.Data));
  16522. }
  16523. /// <summary>
  16524. /// 倒推表
  16525. /// Create
  16526. /// </summary>
  16527. /// <param name="dto"></param>
  16528. /// <returns></returns>
  16529. [HttpPost]
  16530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16531. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16532. {
  16533. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16534. if (viewData.Code != 0)
  16535. {
  16536. return Ok(JsonView(false, viewData.Msg));
  16537. }
  16538. return Ok(JsonView(viewData.Data));
  16539. }
  16540. /// <summary>
  16541. /// 倒推表
  16542. /// Update
  16543. /// </summary>
  16544. /// <param name="dto"></param>
  16545. /// <returns></returns>
  16546. [HttpPost]
  16547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16548. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16549. {
  16550. var viewData = await _invertedListRep._Update(dto);
  16551. if (viewData.Code != 0)
  16552. {
  16553. return Ok(JsonView(false, viewData.Msg));
  16554. }
  16555. return Ok(JsonView(viewData.Data));
  16556. }
  16557. /// <summary>
  16558. /// 倒推表
  16559. /// File Download
  16560. /// </summary>
  16561. /// <param name="dto"></param>
  16562. /// <returns></returns>
  16563. [HttpPost]
  16564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16565. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16566. {
  16567. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16568. if (info2.Code != 0)
  16569. {
  16570. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16571. }
  16572. var info1 = info2.Data as InvertedListInfoView;
  16573. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16574. string teamName = "";
  16575. if (info != null) teamName = info.TeamName;
  16576. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  16577. var doc = new Document();
  16578. var builder = new DocumentBuilder(doc);
  16579. #region old insert
  16580. ////载入模板
  16581. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  16582. //Document doc = new Document(tempPath);
  16583. //DocumentBuilder builder = new DocumentBuilder(doc);
  16584. //利用键值对存放数据
  16585. //Dictionary<string, string> dic = new Dictionary<string, string>();
  16586. //dic.Add("TeamName", teamName);
  16587. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16588. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16589. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  16590. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16591. //dic.Add("SQRemark", info1.ApprovalRemark);
  16592. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16593. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16594. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16595. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  16596. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16597. //dic.Add("QZRemark", info1.VisaInformationRemark);
  16598. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16599. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  16600. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16601. //dic.Add("CQRemark", info1.IssueVisaRemark);
  16602. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16603. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16604. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16605. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16606. //#region 填充word模板书签内容
  16607. //foreach (var key in dic.Keys)
  16608. //{
  16609. // builder.MoveToBookmark(key);
  16610. // builder.Write(dic[key]);
  16611. //}
  16612. //#endregion
  16613. #endregion
  16614. #region New Insert
  16615. string titleFont = $"仿宋",
  16616. contentFont = $"仿宋";
  16617. var fontColor = Color.FromArgb(64, 64, 64);
  16618. //设置标题 团组名称
  16619. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16620. builder.Font.Name = titleFont;
  16621. builder.Font.Color = fontColor;
  16622. builder.Font.Size = 12;
  16623. builder.Font.Bold = true;
  16624. builder.Writeln(teamName);
  16625. //设置副标题 团组出访时间
  16626. builder.Font.Size = 12;
  16627. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  16628. builder.Writeln();
  16629. var backgroundColor = Color.FromArgb(199, 199, 199);
  16630. var table = builder.StartTable();
  16631. builder.InsertCell();
  16632. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  16633. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  16634. builder.CellFormat.Borders.LineWidth = 1;
  16635. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  16636. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  16637. builder.RowFormat.Height = 40;
  16638. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16639. builder.Font.Name = contentFont;
  16640. builder.Font.Size = 12;
  16641. builder.Font.Bold = true;
  16642. builder.Font.Color = fontColor;
  16643. builder.Write("时间");
  16644. builder.InsertCell();
  16645. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  16646. builder.Write("流程");
  16647. builder.InsertCell();
  16648. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  16649. builder.Write("说明");
  16650. builder.EndRow();
  16651. //报批资料准备
  16652. if (info1.IsSelectedAirportd)
  16653. {
  16654. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  16655. }
  16656. //报批/提供送签资料
  16657. if (info1.IsSelectedApprovalData)
  16658. {
  16659. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  16660. }
  16661. //出批件护照办理
  16662. if (info1.IsSelectedIssueApproval)
  16663. {
  16664. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  16665. }
  16666. //签证资料准备
  16667. if (info1.IsSelectedVisaInfo)
  16668. {
  16669. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  16670. }
  16671. //送签
  16672. if (info1.IsSelectedSendVisa)
  16673. {
  16674. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  16675. }
  16676. //出签
  16677. if (info1.IsSelectedIssueVisa)
  16678. {
  16679. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  16680. }
  16681. //机票
  16682. if (info1.IsSelectedAirTicket)
  16683. {
  16684. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  16685. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  16686. }
  16687. //酒店
  16688. if (info1.IsSelectedHotel)
  16689. {
  16690. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  16691. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  16692. }
  16693. //开行前会
  16694. if (info1.IsSelectedPreTripMeeting)
  16695. {
  16696. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  16697. }
  16698. //送机
  16699. if (info1.IsSelectedAirportdDropOff)
  16700. {
  16701. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  16702. }
  16703. builder.EndTable();
  16704. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  16705. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  16706. for (int i = 0; i < table.Rows.Count; i++)
  16707. {
  16708. var row = table.Rows[i];
  16709. //设置宽度
  16710. row.Cells[0].CellFormat.Width = 20.00;
  16711. row.Cells[1].CellFormat.Width = 30.00;
  16712. row.Cells[2].CellFormat.Width = 50.00;
  16713. if (i != 0)
  16714. {
  16715. //边框设置
  16716. InvertedListFileDownloadSetBorders(row.Cells, 0);
  16717. InvertedListFileDownloadSetBorders(row.Cells, 1);
  16718. InvertedListFileDownloadSetBorders(row.Cells, 2);
  16719. }
  16720. }
  16721. #region 页脚插入图片
  16722. // 创建页脚
  16723. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  16724. doc.FirstSection.HeadersFooters.Add(footer);
  16725. Paragraph para = new Paragraph(doc);
  16726. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  16727. footer.AppendChild(para);
  16728. builder.MoveTo(para);
  16729. string imagePath = "./Images/FMGJ_Log.png";
  16730. builder.InsertImage(imagePath);
  16731. #endregion
  16732. #endregion
  16733. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16734. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  16735. string filePath = fileDir + $@"InvertedList/{fileName}";
  16736. doc.Save(filePath);
  16737. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16738. return Ok(JsonView(true, "操作成功!", Url));
  16739. }
  16740. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  16741. {
  16742. var fontColor = Color.FromArgb(64, 64, 64);
  16743. builder.InsertCell();
  16744. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  16745. builder.RowFormat.Height = 40;
  16746. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16747. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16748. builder.Font.Name = fontName;
  16749. builder.Font.Size = 8;
  16750. builder.Font.Bold = true;
  16751. builder.Font.Color = fontColor;
  16752. builder.Write(dateTime);
  16753. builder.InsertCell();
  16754. builder.Font.Size = 9;
  16755. builder.Font.Bold = true;
  16756. builder.Font.Color = fontColor;
  16757. builder.Write(content);
  16758. builder.InsertCell();
  16759. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16760. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16761. builder.Font.Size = 9;
  16762. builder.Font.Bold = false;
  16763. builder.Font.Color = fontColor;
  16764. builder.Write(reamrk);
  16765. builder.EndRow();
  16766. }
  16767. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  16768. {
  16769. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  16770. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  16771. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  16772. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  16773. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  16774. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  16775. }
  16776. #endregion
  16777. #region 会务倒推表
  16778. /// <summary>
  16779. /// 会务倒推表
  16780. /// Init
  16781. /// </summary>
  16782. /// <returns></returns>
  16783. [HttpPost]
  16784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16785. public async Task<IActionResult> InforRetrogressTableInit()
  16786. {
  16787. var groupData = await _groupRepository.PostShareGroupInfos(1);
  16788. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  16789. return Ok(JsonView(false, groupData.Msg));
  16790. }
  16791. /// <summary>
  16792. /// 会务倒推表
  16793. /// ExcelDownload
  16794. /// </summary>
  16795. /// <param name="dto"></param>
  16796. /// <returns></returns>
  16797. [HttpPost]
  16798. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  16799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16800. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  16801. {
  16802. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  16803. var validatorRes = await validator.ValidateAsync(dto);
  16804. if (!validatorRes.IsValid)
  16805. {
  16806. StringBuilder sb = new StringBuilder();
  16807. foreach (var item in validatorRes.Errors)
  16808. {
  16809. sb.AppendLine(item.ErrorMessage);
  16810. }
  16811. return Ok(JsonView(false, sb.ToString()));
  16812. }
  16813. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  16814. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  16815. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  16816. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  16817. #region Excel
  16818. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  16819. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  16820. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  16821. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  16822. var fileNamePrefix = string.Empty;
  16823. if (days >= 30)
  16824. {
  16825. tempPath += $"会务工作倒推进度表(30天).xlsx";
  16826. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  16827. }
  16828. else if (days < 30 && days > 7)
  16829. {
  16830. tempPath += $"会务工作倒推进度表(15天).xlsx";
  16831. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  16832. }
  16833. else if (days <= 7)
  16834. {
  16835. tempPath += $"会务工作倒推进度表(7天).xlsx";
  16836. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  16837. }
  16838. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  16839. fileName = CommonFun.ValidFileName(fileName);
  16840. //载入模板
  16841. WorkbookDesigner designer = new WorkbookDesigner();
  16842. designer.Workbook = new Workbook(tempPath);
  16843. designer.Process();
  16844. if (!Directory.Exists(savePath))
  16845. {
  16846. Directory.CreateDirectory(savePath);
  16847. }
  16848. string serverPath = $"{savePath}{fileName}";
  16849. designer.Workbook.Save(serverPath);
  16850. string rst = $"{servicePath}{ftpPath}{fileName}";
  16851. #endregion
  16852. return Ok(JsonView(new { url = rst }));
  16853. }
  16854. #endregion
  16855. #region 三公签证费用(签证费、代办费)
  16856. /// <summary>
  16857. /// 三公签证费用(签证费、代办费)
  16858. /// List
  16859. /// </summary>
  16860. /// <returns></returns>
  16861. [HttpPost]
  16862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16863. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16864. {
  16865. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16866. if (_view.Code != 0)
  16867. {
  16868. return Ok(JsonView(false, _view.Msg));
  16869. }
  16870. return Ok(JsonView(true, "操作成功!", _view.Data));
  16871. }
  16872. /// <summary>
  16873. /// 三公签证费用(签证费、代办费)
  16874. /// Add Or Update
  16875. /// </summary>
  16876. /// <returns></returns>
  16877. [HttpPost]
  16878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16879. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16880. {
  16881. var _view = await _visaFeeInfoRep._Update(_dto);
  16882. if (_view.Code != 0)
  16883. {
  16884. return Ok(JsonView(false, _view.Msg));
  16885. }
  16886. return Ok(JsonView(true, _view.Msg));
  16887. }
  16888. #endregion
  16889. #region 酒店询价
  16890. /// <summary>
  16891. /// 酒店询价
  16892. /// Init
  16893. /// </summary>
  16894. /// <returns></returns>
  16895. [HttpPost]
  16896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16897. public async Task<IActionResult> PostHotelInquiryInit()
  16898. {
  16899. var res = await _hotelInquiryRep._Init();
  16900. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16901. return Ok(JsonView(true, res.Msg, res.Data));
  16902. }
  16903. /// <summary>
  16904. /// 酒店询价
  16905. /// page Item
  16906. /// </summary>
  16907. /// <param name="_dto"></param>
  16908. /// <returns></returns>
  16909. [HttpPost]
  16910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16911. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16912. {
  16913. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16914. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16915. var view = res.Data as PageDataViewBase;
  16916. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16917. }
  16918. /// <summary>
  16919. /// 酒店询价
  16920. /// info
  16921. /// </summary>
  16922. /// <param name="_dto"></param>
  16923. /// <returns></returns>
  16924. [HttpPost]
  16925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16926. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16927. {
  16928. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16929. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16930. return Ok(JsonView(true, res.Msg, res.Data));
  16931. }
  16932. /// <summary>
  16933. /// 酒店询价
  16934. /// Add Or Edit
  16935. /// </summary>
  16936. /// <param name="_dto"></param>
  16937. /// <returns></returns>
  16938. [HttpPost]
  16939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16940. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16941. {
  16942. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16943. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16944. return Ok(JsonView(true, res.Msg, res.Data));
  16945. }
  16946. /// <summary>
  16947. /// 酒店询价
  16948. /// Del
  16949. /// </summary>
  16950. /// <param name="_dto"></param>
  16951. /// <returns></returns>
  16952. [HttpPost]
  16953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16954. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16955. {
  16956. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16957. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16958. return Ok(JsonView(true, res.Msg, res.Data));
  16959. }
  16960. #endregion
  16961. #region 下载匹配op行程单
  16962. /// <summary>
  16963. /// 匹配op行程单
  16964. /// Init
  16965. /// </summary>
  16966. /// <param name="dto">团组列表请求dto</param>
  16967. /// <returns></returns>
  16968. [HttpPost]
  16969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16970. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16971. {
  16972. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16973. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16974. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16975. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16976. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16977. .Where(it => it.IsDel == 0)
  16978. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16979. .OrderByDescending(it => it.CreateUserId)
  16980. .ToList();
  16981. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16982. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16983. var diids = groupInfos.Select(it => it.Id).ToList();
  16984. List<string> countrys = new List<string>();
  16985. foreach (var item in country)
  16986. {
  16987. var data = _groupRepository.FormartTeamName(item);
  16988. var dataArray = _groupRepository.GroupSplitCountry(data);
  16989. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  16990. }
  16991. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  16992. List<string> areaArray = new List<string>(); //GetGroupCityLine
  16993. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  16994. foreach (var item in areaItem)
  16995. {
  16996. string areaStr = item.Value;
  16997. if (!string.IsNullOrEmpty(areaStr))
  16998. {
  16999. string[] str1 = areaStr.Split("-");
  17000. if (str1.Length > 0)
  17001. {
  17002. areaArray.AddRange(str1);
  17003. }
  17004. }
  17005. }
  17006. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17007. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17008. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17009. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17010. .ToList();
  17011. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17012. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17013. .Where(it => countriesIds.Contains(it.Id))
  17014. .Select(it => new { it.Id, Name = it.Name_CN })
  17015. .ToList();
  17016. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17017. .Select(it => it.TeamName).ToList();
  17018. stopwatch.Stop();
  17019. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17020. }
  17021. ///// <summary>
  17022. ///// 匹配op行程单
  17023. ///// Init 查询区域数据
  17024. ///// </summary>
  17025. ///// <param name="dto">团组列表请求dto</param>
  17026. ///// <returns></returns>
  17027. //[HttpPost]
  17028. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17029. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17030. //{
  17031. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17032. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17033. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17034. // if (string.IsNullOrEmpty(countriesDataStr))
  17035. // {
  17036. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17037. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17038. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17039. // }
  17040. // else
  17041. // {
  17042. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17043. // }
  17044. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17045. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17046. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17047. // List<dynamic> childList = new List<dynamic>();
  17048. // int parentId = dto.CountriesId;
  17049. // if (provinceData.Count > 1)
  17050. // {
  17051. // foreach (var item1 in provinceData)
  17052. // {
  17053. // List<dynamic> childList1 = new List<dynamic>();
  17054. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17055. // foreach (var item2 in citiesData1)
  17056. // {
  17057. // List<dynamic> childList2 = new List<dynamic>();
  17058. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17059. // foreach (var item3 in countiesData1)
  17060. // {
  17061. // childList2.Add(new
  17062. // {
  17063. // id = item3.Id,
  17064. // parentId = item2.Id,
  17065. // level = "district",
  17066. // name = item3.Name_CN,
  17067. // });
  17068. // }
  17069. // childList1.Add(new
  17070. // {
  17071. // id = item2.Id,
  17072. // parentId = item1.Id,
  17073. // level = "city",
  17074. // name = item2.Name_CN,
  17075. // childList = childList2
  17076. // });
  17077. // }
  17078. // childList.Add(new
  17079. // {
  17080. // id = item1.Id,
  17081. // parentId = parentId,
  17082. // level = "province",
  17083. // name = item1.Name_CN,
  17084. // childList = childList1
  17085. // });
  17086. // }
  17087. // //城市
  17088. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17089. // foreach (var item2 in citiesData2)
  17090. // {
  17091. // List<dynamic> childList22 = new List<dynamic>();
  17092. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17093. // foreach (var item3 in countiesData1)
  17094. // {
  17095. // childList22.Add(new
  17096. // {
  17097. // id = item3.Id,
  17098. // parentId = item2.Id,
  17099. // level = "district",
  17100. // name = item3.Name_CN,
  17101. // });
  17102. // }
  17103. // childList.Add(new
  17104. // {
  17105. // id = item2.Id,
  17106. // parentId = parentId,
  17107. // level = "city",
  17108. // name = item2.Name_CN,
  17109. // childList = childList22
  17110. // });
  17111. // }
  17112. // }
  17113. // else
  17114. // {
  17115. // foreach (var item2 in citiesData)
  17116. // {
  17117. // string cname = item2.Name_CN;
  17118. // List<dynamic> childList1 = new List<dynamic>();
  17119. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17120. // foreach (var item3 in countiesData1)
  17121. // {
  17122. // childList1.Add(new
  17123. // {
  17124. // Id = item3.Id,
  17125. // parentId = item2.Id,
  17126. // level = "district",
  17127. // name = item3.Name_CN
  17128. // });
  17129. // }
  17130. // childList.Add(new
  17131. // {
  17132. // id = item2.Id,
  17133. // parentId = parentId,
  17134. // level = "city",
  17135. // name = item2.Name_CN,
  17136. // childList = childList1
  17137. // });
  17138. // }
  17139. // }
  17140. // stopwatch.Stop();
  17141. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17142. //}
  17143. /// <summary>
  17144. /// 匹配op行程单
  17145. /// 接团信息列表 Page
  17146. /// </summary>
  17147. /// <param name="dto">团组列表请求dto</param>
  17148. /// <returns></returns>
  17149. [HttpPost]
  17150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17151. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17152. {
  17153. var swatch = new Stopwatch();
  17154. swatch.Start();
  17155. #region 参数验证
  17156. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17157. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17158. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17159. #region 页面操作权限验证
  17160. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17161. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17162. #endregion
  17163. #endregion
  17164. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17165. {
  17166. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17167. //string sqlWhere = "";
  17168. if (!string.IsNullOrEmpty(dto.Country))
  17169. {
  17170. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17171. }
  17172. if (!string.IsNullOrEmpty(dto.Area))
  17173. {
  17174. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17175. }
  17176. if (!string.IsNullOrEmpty(dto.TeamName))
  17177. {
  17178. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17179. }
  17180. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17181. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17182. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17183. swatch.Stop();
  17184. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17185. }
  17186. else
  17187. {
  17188. return Ok(JsonView(false, "查询失败"));
  17189. }
  17190. }
  17191. /// <summary>
  17192. /// 匹配op行程单
  17193. /// 行程单下载
  17194. /// </summary>
  17195. /// <param name="dto">团组列表请求dto</param>
  17196. /// <returns></returns>
  17197. [HttpPost]
  17198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17199. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17200. {
  17201. #region 参数验证
  17202. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17203. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17204. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17205. #region 页面操作权限验证
  17206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17207. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17208. #endregion
  17209. #endregion
  17210. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17211. {
  17212. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17213. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17214. }
  17215. else
  17216. {
  17217. return Ok(JsonView(false, "下载失败!"));
  17218. }
  17219. }
  17220. #endregion
  17221. #region 国家信息 数据 注释
  17222. //[HttpPost]
  17223. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17224. //{
  17225. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17226. // foreach (var item in dto)
  17227. // {
  17228. // infos.Add(new Grp_GroupsTaskAssignment()
  17229. // {
  17230. // DIId = item,
  17231. // CTId = 82,
  17232. // UId = 248,
  17233. // IsEnable = 1,
  17234. // CreateUserId = 233,
  17235. // CreateTime = DateTime.Now,
  17236. // IsDel = 0
  17237. // });
  17238. // infos.Add(new Grp_GroupsTaskAssignment()
  17239. // {
  17240. // DIId = item,
  17241. // CTId = 82,
  17242. // UId = 286,
  17243. // IsEnable = 1,
  17244. // CreateUserId = 233,
  17245. // CreateTime = DateTime.Now,
  17246. // IsDel = 0
  17247. // });
  17248. // }
  17249. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17250. // return Ok("操作成功");
  17251. //}
  17252. //public class paramJsonDto
  17253. //{
  17254. // public List<CountriesInfo> str { get; set; }
  17255. //}
  17256. //[HttpPost]
  17257. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17258. //{
  17259. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17260. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17261. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17262. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17263. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17264. // _sqlSugar.BeginTran();
  17265. // int countitiesIndex = 0;
  17266. // foreach (var item in dto.str)
  17267. // {
  17268. // dynamic data = item.c;
  17269. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17270. // if (data != null)
  17271. // {
  17272. // countitiesIndex++;
  17273. // foreach (var item1 in data)
  17274. // {
  17275. // string cnname = item1.cn;
  17276. // string enname = item1.en;
  17277. // Sys_Cities provinceInfo = new Sys_Cities()
  17278. // {
  17279. // CountriesId = countriesId,
  17280. // Name_CN = cnname,
  17281. // Name_EN = enname,
  17282. // ParentId = 0,
  17283. // IsCapital = 1,
  17284. // CreateUserId = 208,
  17285. // CreateTime = DateTime.Now,
  17286. // IsDel = 0
  17287. // };
  17288. // if (item1.lv == "province") //省份
  17289. // {
  17290. // provinceInfo.Level = 1;
  17291. // int provinceId = 0;
  17292. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17293. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17294. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17295. // var data1 = item1.c;
  17296. // foreach (var item2 in data1)
  17297. // {
  17298. // if (item2.lv == "city")
  17299. // {
  17300. // string citycnname = item2.cn;
  17301. // string cityenname = item2.en;
  17302. // Sys_Cities cityInfo = new Sys_Cities()
  17303. // {
  17304. // CountriesId = countriesId,
  17305. // ParentId = provinceId,
  17306. // Level = 2,
  17307. // Name_CN = citycnname,
  17308. // Name_EN = cityenname,
  17309. // IsCapital = 1,
  17310. // CreateUserId = 208,
  17311. // CreateTime = DateTime.Now,
  17312. // IsDel = 0
  17313. // };
  17314. // if (item2.c != null)
  17315. // {
  17316. // int cityId = 0;
  17317. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17318. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17319. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17320. // foreach (var item3 in item2.c)
  17321. // {
  17322. // if (item3.lv == "district")
  17323. // {
  17324. // var districtInfo = new Sys_Cities()
  17325. // {
  17326. // CountriesId = countriesId,
  17327. // Name_CN = item3.cn,
  17328. // Name_EN = item3.en,
  17329. // Level = 3,
  17330. // ParentId = cityId,
  17331. // IsCapital = 1,
  17332. // CreateUserId = 208,
  17333. // CreateTime = DateTime.Now,
  17334. // IsDel = 0
  17335. // };
  17336. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17337. // //{
  17338. // districts.Add(districtInfo);
  17339. // //}
  17340. // }
  17341. // }
  17342. // }
  17343. // else
  17344. // {
  17345. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17346. // //{
  17347. // cities.Add(cityInfo);
  17348. // //}
  17349. // }
  17350. // }
  17351. // }
  17352. // }
  17353. // else if (item1.lv == "city")//城市
  17354. // {
  17355. // provinceInfo.Level = 2;
  17356. // if (item1.c != null)
  17357. // {
  17358. // int cityId = 0;
  17359. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17360. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17361. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17362. // foreach (var item3 in item1.c)
  17363. // {
  17364. // if (item3.lv == "district")
  17365. // {
  17366. // var districtInfo = new Sys_Cities()
  17367. // {
  17368. // CountriesId = countriesId,
  17369. // Name_CN = item3.cn,
  17370. // Name_EN = item3.en,
  17371. // Level = 3,
  17372. // ParentId = cityId,
  17373. // IsCapital = 1,
  17374. // CreateUserId = 208,
  17375. // CreateTime = DateTime.Now,
  17376. // IsDel = 0
  17377. // };
  17378. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17379. // //{
  17380. // districts.Add(districtInfo);
  17381. // //}
  17382. // }
  17383. // }
  17384. // }
  17385. // else
  17386. // {
  17387. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17388. // //{
  17389. // cities.Add(provinceInfo);
  17390. // //}
  17391. // }
  17392. // }
  17393. // }
  17394. // }
  17395. // }
  17396. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17397. // cities = cities.Distinct().ToList();
  17398. // districts = districts.Distinct().ToList();
  17399. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17400. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17401. // cities.AddRange(districts);
  17402. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17403. // //_sqlSugar.RollbackTran();
  17404. // _sqlSugar.CommitTran();
  17405. // return Ok(JsonView(false, "操作成功!"));
  17406. //}
  17407. //[HttpPost]
  17408. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17409. //{
  17410. // List<CountitiesInfo> infos = dto.MyProperty;
  17411. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17412. // _sqlSugar.BeginTran();
  17413. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17414. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17415. // foreach (var item in infos)
  17416. // {
  17417. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17418. // if (countryInfo != null)
  17419. // {
  17420. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17421. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17422. // if (cityInfo1 != null)
  17423. // {
  17424. // cityInfo1.IsCapital = 0;
  17425. // cityInfos.Add(cityInfo1);
  17426. // }
  17427. // }
  17428. // }
  17429. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17430. // .UpdateColumns(it => it.IsCapital)
  17431. // .WhereColumns(it => it.Id)
  17432. // .ExecuteCommand();
  17433. // //_sqlSugar.RollbackTran();
  17434. // _sqlSugar.CommitTran();
  17435. // return Ok(JsonView(false, "操作成功!"));
  17436. //}
  17437. //public class CounrtiesDto
  17438. //{
  17439. // public List<CountitiesInfo> MyProperty { get; set; }
  17440. //}
  17441. //public class CountitiesInfo
  17442. //{
  17443. // /// <summary>
  17444. // /// 圣约翰
  17445. // /// </summary>
  17446. // public string capital_name_chinese { get; set; }
  17447. // /// <summary>
  17448. // ///
  17449. // /// </summary>
  17450. // public string capital_name { get; set; }
  17451. // /// <summary>
  17452. // ///
  17453. // /// </summary>
  17454. // public string country_type { get; set; }
  17455. // /// <summary>
  17456. // /// 安提瓜和巴布达
  17457. // /// </summary>
  17458. // public string country_name_chinese { get; set; }
  17459. // /// <summary>
  17460. // /// 安提瓜和巴布达
  17461. // /// </summary>
  17462. // public string country_name_chinese_short { get; set; }
  17463. // /// <summary>
  17464. // /// 安提瓜和巴布达
  17465. // /// </summary>
  17466. // public string country_name_chinese_UN { get; set; }
  17467. // /// <summary>
  17468. // ///
  17469. // /// </summary>
  17470. // public string country_name_english_abbreviation { get; set; }
  17471. // /// <summary>
  17472. // ///
  17473. // /// </summary>
  17474. // public string country_name_english_formal { get; set; }
  17475. // /// <summary>
  17476. // ///
  17477. // /// </summary>
  17478. // public string country_name_english_UN { get; set; }
  17479. // /// <summary>
  17480. // ///
  17481. // /// </summary>
  17482. // public string continent_name { get; set; }
  17483. // /// <summary>
  17484. // ///
  17485. // /// </summary>
  17486. // public string subregion_name { get; set; }
  17487. // /// <summary>
  17488. // ///
  17489. // /// </summary>
  17490. // public string country_code2 { get; set; }
  17491. // /// <summary>
  17492. // ///
  17493. // /// </summary>
  17494. // public string country_code3 { get; set; }
  17495. // /// <summary>
  17496. // ///
  17497. // /// </summary>
  17498. // public string phone_code { get; set; }
  17499. //}
  17500. //public class CountriesInfo : BasicInfo
  17501. //{
  17502. // public List<CitiesInfo> c { get; set; }
  17503. //}
  17504. //public class CitiesInfo : BasicInfo
  17505. //{
  17506. // public List<AreaInfo> c { get; set; }
  17507. //}
  17508. //public class AreaInfo : BasicInfo
  17509. //{
  17510. // public List<AreaInfo> c { get; set; }
  17511. //}
  17512. //public class BasicInfo
  17513. //{
  17514. // public string code { get; set; }
  17515. // public string cn { get; set; }
  17516. // public string lv { get; set; }
  17517. // public string en { get; set; }
  17518. //}
  17519. #endregion
  17520. #region 查看邀请方
  17521. /// <summary>
  17522. /// 查看邀请方
  17523. /// 邀请方信息 Init
  17524. /// </summary>
  17525. /// <param name="dto"></param>
  17526. /// <returns></returns>
  17527. [HttpPost]
  17528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17529. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17530. {
  17531. string sqlWhere = string.Empty;
  17532. if (!string.IsNullOrEmpty(dto.Search))
  17533. {
  17534. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17535. }
  17536. string sql = string.Format($@"Select
  17537. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17538. Id,
  17539. UnitName
  17540. From Res_InvitationOfficialActivityData
  17541. Where IsDel = 0
  17542. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17543. RefAsync<int> total = 0;
  17544. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17545. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17546. }
  17547. /// <summary>
  17548. /// 查看邀请方
  17549. /// 国家信息 Init
  17550. /// </summary>
  17551. /// <param name="dto"></param>
  17552. /// <returns></returns>
  17553. [HttpPost]
  17554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17555. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17556. {
  17557. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17558. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17559. var diids = groupInfos.Select(it => it.Id).ToList();
  17560. List<string> countrys = new List<string>();
  17561. foreach (var item in country)
  17562. {
  17563. var data = _groupRepository.FormartTeamName(item);
  17564. var dataArray = _groupRepository.GroupSplitCountry(data);
  17565. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17566. }
  17567. countrys = countrys.Distinct().ToList();
  17568. for (int i = 0; i < countrys.Count; i++)
  17569. {
  17570. string item = countrys[i];
  17571. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17572. {
  17573. countrys.Remove(item);
  17574. i--;
  17575. }
  17576. }
  17577. RefAsync<int> total = 0;
  17578. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17579. .Where(it => countrys.Contains(it.Name_CN))
  17580. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17581. .Select(it => new { id = it.Id, name = it.Name_CN })
  17582. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17583. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17584. }
  17585. /// <summary>
  17586. /// 查看邀请方
  17587. /// 城市信息 Init
  17588. /// </summary>
  17589. /// <param name="dto"></param>
  17590. /// <returns></returns>
  17591. [HttpPost]
  17592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17593. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17594. {
  17595. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17596. RefAsync<int> total = 0;
  17597. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17598. .Where(it => it.CountriesId == dto.CountiesId)
  17599. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17600. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17601. .Select(it => new { id = it.Id, name = it.Name_CN })
  17602. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17603. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17604. }
  17605. /// <summary>
  17606. /// 查看邀请方
  17607. /// 团组名称 Init
  17608. /// </summary>
  17609. /// <param name="dto"></param>
  17610. /// <returns></returns>
  17611. [HttpPost]
  17612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17613. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17614. {
  17615. var watch = new Stopwatch();
  17616. watch.Start();
  17617. RefAsync<int> total = 0;
  17618. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17619. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17620. .Where((oa, di) => oa.IsDel == 0)
  17621. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17622. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17623. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17624. .Distinct()
  17625. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17626. watch.Stop();
  17627. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17628. }
  17629. /// <summary>
  17630. /// 查看邀请方
  17631. /// 团组 & 邀请方信息
  17632. /// </summary>
  17633. /// <param name="dto"></param>
  17634. /// <returns></returns>
  17635. [HttpPost]
  17636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17637. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17638. {
  17639. var watch = new Stopwatch();
  17640. watch.Start();
  17641. RefAsync<int> total = 0;
  17642. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17643. .AS("Grp_DelegationInfo")
  17644. .Includes(x => x.InvitingInfos)
  17645. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17646. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17647. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17648. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17649. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17650. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17651. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17652. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17653. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17654. infos.ForEach(x =>
  17655. {
  17656. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17657. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17658. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17659. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17660. });
  17661. watch.Stop();
  17662. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17663. }
  17664. #endregion
  17665. #region 报批行程
  17666. /// <summary>
  17667. /// 报批行程初始化
  17668. /// </summary>
  17669. /// <param name="dto"></param>
  17670. /// <returns></returns>
  17671. [HttpPost]
  17672. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17673. {
  17674. const int chiNumber = 5;
  17675. var jw = JsonView(false);
  17676. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17677. var group = groupList.First();
  17678. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17679. group = groupList.First(x => x.Id == diid);
  17680. if (group == null)
  17681. {
  17682. jw.Msg = "暂无团组!";
  17683. return Ok(jw);
  17684. }
  17685. var data = new
  17686. {
  17687. groupList = groupList.Select(x => new
  17688. {
  17689. x.TeamName,
  17690. x.Id
  17691. }),
  17692. content = new ArrayList(),
  17693. groupInfo = new
  17694. {
  17695. group.VisitDays,
  17696. group.TourCode,
  17697. group.VisitPNumber,
  17698. group.TeamName,
  17699. group.Id,
  17700. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17701. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17702. },
  17703. };
  17704. var resultArr = new ArrayList();
  17705. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17706. if (content.Count == 0)
  17707. {
  17708. var stay = "-";
  17709. var cityPath = "-";
  17710. //添加城市路径以及住宿地
  17711. //黑屏代码数据
  17712. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17713. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17714. {
  17715. jw = JsonView(true, "黑屏代码有误!", data);
  17716. return Ok(jw);
  17717. }
  17718. foreach (DataRow row in dtBlack.Rows)
  17719. {
  17720. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17721. {
  17722. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17723. return Ok(jw);
  17724. }
  17725. }
  17726. //黑屏代码获取时间区间
  17727. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17728. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17729. _sqlSugar.BeginTran();
  17730. for (int i = 0; i < timeArr.Count; i++)
  17731. {
  17732. stay = "-";
  17733. cityPath = "-";
  17734. DateTime NewData = DateTime.Parse(timeArr[i]);
  17735. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17736. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17737. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17738. if (tbSelect.Length > 0)
  17739. {
  17740. List<string> threeCodeStr = new List<string>();
  17741. foreach (var item in tbSelect)
  17742. {
  17743. var threeCode = item["Three"].ToString() ?? "";
  17744. if (threeCode.Length == 6)
  17745. {
  17746. var start = threeCode.Substring(0, 3);
  17747. var end = threeCode.Substring(3, 3);
  17748. if (threeCodeStr.Count == 0)
  17749. {
  17750. threeCodeStr.Add(start);
  17751. threeCodeStr.Add(end);
  17752. }
  17753. else
  17754. {
  17755. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17756. {
  17757. threeCodeStr.Add(end);
  17758. }
  17759. else
  17760. {
  17761. threeCodeStr.Add(start);
  17762. threeCodeStr.Add(end);
  17763. }
  17764. }
  17765. }
  17766. }
  17767. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17768. var last = threeCodeStr.Last();
  17769. foreach (var item in threeCodeStr)
  17770. {
  17771. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17772. if (item.Equals(last))
  17773. {
  17774. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17775. }
  17776. }
  17777. cityPath = cityPath.Trim('-');
  17778. }
  17779. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17780. appro.Diid = diid ?? -1;
  17781. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17782. appro.Id = thisId;
  17783. appro.CreateUserId = dto.UserId;
  17784. appro.CreateTime = DateTime.Now;
  17785. content.Add(appro);
  17786. }
  17787. _sqlSugar.CommitTran();
  17788. }
  17789. foreach (var x in content)
  17790. {
  17791. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17792. if (chiList.Count < chiNumber)
  17793. {
  17794. for (int i = chiList.Count; i < chiNumber; i++)
  17795. {
  17796. chiList.Add(new Grp_ApprovalTravelDetails());
  17797. }
  17798. }
  17799. resultArr.Add(new
  17800. {
  17801. x.Id,
  17802. x.Date,
  17803. x.Diid,
  17804. chiList = chiList.Select(x1 => new
  17805. {
  17806. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17807. x1.Details,
  17808. x1.ParentId,
  17809. x1.Id
  17810. })
  17811. });
  17812. }
  17813. data = data with
  17814. {
  17815. content = resultArr,
  17816. };
  17817. jw = JsonView(true, "获取成功!", data);
  17818. return Ok(jw);
  17819. }
  17820. /// <summary>
  17821. /// 报批行程删除
  17822. /// </summary>
  17823. /// <param name="dto"></param>
  17824. /// <returns></returns>
  17825. [HttpPost]
  17826. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17827. {
  17828. var jw = JsonView(false);
  17829. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17830. if (group == null)
  17831. {
  17832. jw.Msg = "团组参数有误!";
  17833. return Ok(jw);
  17834. }
  17835. try
  17836. {
  17837. _sqlSugar.BeginTran();
  17838. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17839. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17840. {
  17841. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17842. DeleteUserId = dto.uesrId,
  17843. IsDel = 1
  17844. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17845. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17846. {
  17847. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17848. DeleteUserId = dto.uesrId,
  17849. IsDel = 1
  17850. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17851. _sqlSugar.CommitTran();
  17852. jw = JsonView(true, "删除成功");
  17853. }
  17854. catch (Exception ex)
  17855. {
  17856. jw = JsonView(false, ex.Message);
  17857. }
  17858. return Ok(jw);
  17859. }
  17860. /// <summary>
  17861. /// 报批行程保存
  17862. /// </summary>
  17863. /// <param name="dto"></param>
  17864. /// <returns></returns>
  17865. [HttpPost]
  17866. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17867. {
  17868. var jw = JsonView(false);
  17869. var Find = dto.Arr.Find(x => x.id == 0);
  17870. if (Find != null)
  17871. {
  17872. jw.Msg = "生成的ID为0!";
  17873. return Ok(jw);
  17874. }
  17875. foreach (var item in dto.Arr)
  17876. {
  17877. foreach (var chi in item.chiList)
  17878. {
  17879. if (chi.parentId == 0)
  17880. {
  17881. chi.parentId = item.id;
  17882. }
  17883. }
  17884. }
  17885. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17886. _sqlSugar.BeginTran();
  17887. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17888. {
  17889. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17890. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17891. {
  17892. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17893. DeleteUserId = dto.UserId,
  17894. IsDel = 1
  17895. }).ExecuteCommand();
  17896. }
  17897. try
  17898. {
  17899. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17900. {
  17901. CreateTime = DateTime.Now,
  17902. CreateUserId = dto.UserId,
  17903. Details = x.details,
  17904. ParentId = x.parentId,
  17905. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17906. Remark = "",
  17907. IsDel = 0
  17908. }).ToList()).ExecuteCommand();
  17909. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17910. {
  17911. Id = x.id,
  17912. Details = x.details,
  17913. ParentId = x.parentId,
  17914. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17915. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17916. {
  17917. Details = x.Details,
  17918. ParentId = x.ParentId,
  17919. Time = x.Time
  17920. }).ExecuteCommand();
  17921. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17922. {
  17923. Id = x.id,
  17924. Date = x.date,
  17925. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17926. {
  17927. Date = x.Date
  17928. }).ExecuteCommand();
  17929. _sqlSugar.CommitTran();
  17930. jw = JsonView(true, "保存成功!");
  17931. }
  17932. catch (Exception ex)
  17933. {
  17934. _sqlSugar.RollbackTran();
  17935. jw = JsonView(false, "保存失败!" + ex.Message);
  17936. }
  17937. return Ok(jw);
  17938. }
  17939. /// <summary>
  17940. /// 报批行程生成
  17941. /// </summary>
  17942. /// <param name="dto"></param>
  17943. /// <returns></returns>
  17944. [HttpPost]
  17945. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17946. {
  17947. var jw = JsonView(false);
  17948. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17949. if (group == null)
  17950. {
  17951. jw.Msg = "暂无该团组!";
  17952. return Ok(jw);
  17953. }
  17954. //黑屏代码数据
  17955. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17956. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17957. {
  17958. jw.Msg = "黑屏代码有误!";
  17959. return Ok(jw);
  17960. }
  17961. foreach (DataRow row in dtBlack.Rows)
  17962. {
  17963. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17964. {
  17965. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17966. return Ok(jw);
  17967. }
  17968. }
  17969. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17970. var resultArr = new ArrayList();
  17971. if (officialActivitiesArr.Count == 0)
  17972. {
  17973. jw.Msg = "暂无公务出访信息!";
  17974. return Ok(jw);
  17975. }
  17976. try
  17977. {
  17978. _sqlSugar.BeginTran();
  17979. DeleteApprovalJourney(new
  17980. Domain.Dtos.Groups.DeleteApprovalJourney
  17981. {
  17982. Diid = dto.Diid,
  17983. uesrId = dto.Userid
  17984. });
  17985. var stay = "-";
  17986. var cityPath = "-";
  17987. //添加城市路径以及住宿地
  17988. //黑屏代码获取时间区间
  17989. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17990. var empty = "【未收入该三字码!请机票同事录入】";
  17991. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17992. for (int i = 0; i < timeArr.Count; i++)
  17993. {
  17994. stay = "-";
  17995. cityPath = "-";
  17996. var chiarr = new List<Grp_ApprovalTravelDetails>();
  17997. DateTime NewData = DateTime.Parse(timeArr[i]);
  17998. var gwinfo = officialActivitiesArr.Where(x => DateTime.TryParse(x.Date, out DateTime gwData) && gwData.ToString("yyyy-MM-dd") == NewData.ToString("yyyy-MM-dd")).OrderBy(x => x.Time).ToList();
  17999. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18000. if (tbSelect.Length > 0)
  18001. {
  18002. List<string> threeCodeStr = new List<string>();
  18003. bool isTrade = false;
  18004. string trip = string.Empty;
  18005. var rowLast = tbSelect.Last();
  18006. var rowFirst = tbSelect.First();
  18007. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18008. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18009. var takeOffTime = DateTime.Parse(timeArr[i]);
  18010. var fallToTime = DateTime.Parse(timeArr[i]);
  18011. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18012. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18013. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18014. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18015. foreach (var item in tbSelect)
  18016. {
  18017. var start = string.Empty;
  18018. var end = string.Empty;
  18019. var threeCode = item["Three"].ToString() ?? "";
  18020. if (threeCode.Length == 6)
  18021. {
  18022. start = threeCode.Substring(0, 3);
  18023. end = threeCode.Substring(3, 3);
  18024. if (threeCodeStr.Count == 0)
  18025. {
  18026. threeCodeStr.Add(start);
  18027. threeCodeStr.Add(end);
  18028. }
  18029. else
  18030. {
  18031. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18032. {
  18033. threeCodeStr.Add(end);
  18034. }
  18035. else
  18036. {
  18037. threeCodeStr.Add(start);
  18038. threeCodeStr.Add(end);
  18039. }
  18040. }
  18041. }
  18042. //处理机票信息
  18043. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18044. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18045. if (start_Object == null)
  18046. {
  18047. start_Object = new Res_ThreeCode()
  18048. {
  18049. AirPort = empty,
  18050. AirPort_En = empty,
  18051. City = empty,
  18052. Country = empty,
  18053. Four = empty,
  18054. Three = empty,
  18055. };
  18056. }
  18057. if (end_Object == null)
  18058. {
  18059. end_Object = new Res_ThreeCode()
  18060. {
  18061. AirPort = empty,
  18062. AirPort_En = empty,
  18063. City = empty,
  18064. Country = empty,
  18065. Four = empty,
  18066. Three = empty,
  18067. };
  18068. }
  18069. //机型判断
  18070. string airModel = item["AirModel"].ToString();
  18071. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18072. string flightTime = item["FlightTime"].ToString();
  18073. if (flightTime!.Contains(":"))
  18074. {
  18075. flightTime = flightTime.Replace(":", "小时");
  18076. flightTime += "分钟";
  18077. }
  18078. if (flightTime.Contains("H"))
  18079. {
  18080. flightTime = flightTime.Replace("H", "小时");
  18081. }
  18082. if (flightTime.Contains("M"))
  18083. {
  18084. flightTime = flightTime.Replace("M", "分钟");
  18085. }
  18086. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18087. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18088. {
  18089. flightTime = flightDataTime.Hour > 0
  18090. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18091. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18092. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18093. }
  18094. //航班号
  18095. string flightcode = item["Fliagtcode"].ToString();
  18096. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18097. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18098. if (aircompany == null)
  18099. {
  18100. aircompany = new Res_AirCompany
  18101. {
  18102. CnName = hsEmpty,
  18103. EnName = hsEmpty,
  18104. ShortCode = hsEmpty,
  18105. };
  18106. }
  18107. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18108. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18109. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18110. if (isTrade)
  18111. {
  18112. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18113. }
  18114. else
  18115. {
  18116. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18117. }
  18118. }
  18119. chiarr.Add(new Grp_ApprovalTravelDetails
  18120. {
  18121. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18122. CreateTime = DateTime.Now,
  18123. CreateUserId = dto.Userid,
  18124. ParentId = 0,
  18125. Details = trip
  18126. });
  18127. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18128. var last = threeCodeStr.Last();
  18129. foreach (var item in threeCodeStr)
  18130. {
  18131. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18132. if (item.Equals(last))
  18133. {
  18134. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18135. }
  18136. }
  18137. cityPath = cityPath.Trim('-');
  18138. }
  18139. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18140. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18141. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18142. appro.Diid = dto.Diid;
  18143. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18144. appro.Id = thisId;
  18145. appro.CreateUserId = dto.Userid;
  18146. appro.CreateTime = DateTime.Now;
  18147. foreach (var item in gwinfo)
  18148. {
  18149. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18150. chi.Details = "拜访" + item.Client;
  18151. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18152. {
  18153. chi.Details += "," + item.ReqSample;
  18154. }
  18155. chi.ParentId = thisId;
  18156. chi.Time = item.Time;
  18157. chiarr.Add(chi);
  18158. }
  18159. if (chiarr.Count < 5)
  18160. {
  18161. for (int j = chiarr.Count; j < 5; j++)
  18162. {
  18163. chiarr.Add(new
  18164. Grp_ApprovalTravelDetails());
  18165. }
  18166. }
  18167. resultArr.Add(new
  18168. {
  18169. appro.Id,
  18170. appro.Date,
  18171. appro.Diid,
  18172. chiList = chiarr.Select(x1 => new
  18173. {
  18174. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  18175. x1.Details,
  18176. x1.ParentId,
  18177. x1.Id
  18178. })
  18179. });
  18180. }
  18181. _sqlSugar.CommitTran();
  18182. jw = JsonView(true, "生成成功!", resultArr);
  18183. }
  18184. catch (Exception ex)
  18185. {
  18186. jw.Code = 400;
  18187. jw.Msg = "生成失败!" + ex.Message;
  18188. }
  18189. return Ok(jw);
  18190. }
  18191. /// <summary>
  18192. /// 报批行程word导出
  18193. /// </summary>
  18194. /// <param name="dto"></param>
  18195. /// <returns></returns>
  18196. [HttpPost]
  18197. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18198. {
  18199. var jw = JsonView(false);
  18200. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18201. if (group == null)
  18202. {
  18203. jw.Msg = "暂无该团组!";
  18204. return Ok(jw);
  18205. }
  18206. //模板路径
  18207. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18208. //载入模板
  18209. Document doc = new Document(tempPath);
  18210. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18211. //获取所填表格的序数
  18212. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18213. Aspose.Words.Tables.Row titleRowClone = null;
  18214. Aspose.Words.Tables.Row CenterRowClone = null;
  18215. int index = 0;
  18216. int indexChi = 0;
  18217. int SetIndex = 0;
  18218. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18219. //获取数据,放到datatable
  18220. foreach (var item in ApprovalTravelArr)
  18221. {
  18222. if (index > 0)
  18223. {
  18224. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18225. tableOne.AppendChild(titleRowClone);
  18226. }
  18227. var textTime = item.Date;
  18228. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18229. SetCells(tableOne, doc, SetIndex, 0, textTime);
  18230. SetIndex++;
  18231. if (ChiRep.Count > 0)
  18232. {
  18233. foreach (var itemChi in ChiRep)
  18234. {
  18235. var txtTime = itemChi.Time;
  18236. var txtDetail = itemChi.Details;
  18237. if (indexChi > 0)
  18238. {
  18239. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18240. tableOne.AppendChild(CenterRowClone);
  18241. }
  18242. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18243. {
  18244. SetCells(tableOne, doc, SetIndex, 0, "");
  18245. SetCells(tableOne, doc, SetIndex, 1, "");
  18246. indexChi++;
  18247. SetIndex++;
  18248. break;
  18249. }
  18250. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  18251. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  18252. indexChi++;
  18253. SetIndex++;
  18254. }
  18255. }
  18256. else
  18257. {
  18258. if (indexChi > 0)
  18259. {
  18260. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18261. tableOne.AppendChild(CenterRowClone);
  18262. }
  18263. SetCells(tableOne, doc, SetIndex, 0, "");
  18264. SetCells(tableOne, doc, SetIndex, 1, "");
  18265. indexChi++;
  18266. SetIndex++;
  18267. }
  18268. index++;
  18269. }
  18270. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  18271. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18272. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18273. jw.Code = 200;
  18274. jw.Msg = "";
  18275. return Ok(jw);
  18276. }
  18277. private string intToString(int numberVal)
  18278. {
  18279. string numberval = numberVal.ToString();
  18280. Dictionary<char, string> Number = new Dictionary<char, string>();
  18281. Number.Add('1', "一");
  18282. Number.Add('2', "二");
  18283. Number.Add('3', "三");
  18284. Number.Add('4', "四");
  18285. Number.Add('5', "五");
  18286. Number.Add('6', "六");
  18287. Number.Add('7', "七");
  18288. Number.Add('8', "八");
  18289. Number.Add('9', "九");
  18290. string stringNumberVal = string.Empty;
  18291. for (int i = 0; i < numberval.Length; i++)
  18292. {
  18293. if (i == 0)
  18294. {
  18295. stringNumberVal += Number[numberval[i]];
  18296. }
  18297. else if (i >= 1)
  18298. {
  18299. if (numberval[i] == '0')
  18300. {
  18301. stringNumberVal = "十";
  18302. }
  18303. else
  18304. {
  18305. stringNumberVal += "十" + Number[numberval[i]];
  18306. }
  18307. }
  18308. }
  18309. return stringNumberVal;
  18310. }
  18311. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  18312. {
  18313. //获取table中的某个单元格,从0开始
  18314. Cell lshCell = table.Rows[rows].Cells[cells];
  18315. //将单元格中段落移除
  18316. foreach (Node item in lshCell.Paragraphs)
  18317. {
  18318. lshCell.Paragraphs.Remove(item);
  18319. }
  18320. if (val.Contains("\r\n"))
  18321. {
  18322. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18323. foreach (var item in spArr)
  18324. {
  18325. //新建一个段落
  18326. Paragraph p = new Paragraph(doc);
  18327. var r = new Run(doc, item);
  18328. //把设置的值赋给之前新建的段落
  18329. p.AppendChild(r);
  18330. //将此段落加到单元格内
  18331. lshCell.AppendChild(p);
  18332. }
  18333. }
  18334. else
  18335. {
  18336. //新建一个段落
  18337. Paragraph p = new Paragraph(doc);
  18338. var r = new Run(doc, val);
  18339. //把设置的值赋给之前新建的段落
  18340. p.AppendChild(r);
  18341. //将此段落加到单元格内
  18342. lshCell.AppendChild(p);
  18343. }
  18344. }
  18345. [HttpPost]
  18346. public async Task<IActionResult> ServerHttp(string paramStr)
  18347. {
  18348. paramStr = paramStr.TrimEnd('\'');
  18349. paramStr = paramStr.TrimStart('\'');
  18350. JsonView jw = JsonView(false);
  18351. JObject param = JObject.Parse(paramStr);
  18352. if (!param.ContainsKey("url"))
  18353. {
  18354. jw.Msg = "url null";
  18355. return Ok(jw);
  18356. }
  18357. string url = param["url"]!.ToString();
  18358. var methon = "get";
  18359. Dictionary<string, string> headValues = null;
  18360. string bodyStr = string.Empty;
  18361. if (param.ContainsKey("methon"))
  18362. {
  18363. methon = param["methon"]!.ToString().ToLower();
  18364. }
  18365. if (param.ContainsKey("header"))
  18366. {
  18367. var header = param["header"]!.ToString();
  18368. JObject headerJobject = JObject.Parse(header);
  18369. headValues = new Dictionary<string, string>();
  18370. foreach (JProperty item in headerJobject.Properties())
  18371. {
  18372. var value = item.Value.ToString();
  18373. var head = item.Path;
  18374. headValues.Add(head, value);
  18375. }
  18376. }
  18377. HttpClient client = new HttpClient();
  18378. string responseString = string.Empty;
  18379. StringContent content = null;
  18380. if (headValues != null)
  18381. {
  18382. foreach (var item in headValues.Keys)
  18383. {
  18384. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18385. {
  18386. if (param.ContainsKey("body"))
  18387. {
  18388. bodyStr = param["body"]!.ToString();
  18389. }
  18390. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18391. }
  18392. else
  18393. {
  18394. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18395. }
  18396. }
  18397. }
  18398. try
  18399. {
  18400. if (methon == "get")
  18401. {
  18402. responseString = await client.GetStringAsync(url);
  18403. }
  18404. else if (methon == "post")
  18405. {
  18406. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18407. {
  18408. Content = content
  18409. };
  18410. var response = await client.SendAsync(request);
  18411. try
  18412. {
  18413. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18414. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18415. {
  18416. using (StreamReader reader = new StreamReader(gzipStream))
  18417. {
  18418. responseString = await reader.ReadToEndAsync();
  18419. }
  18420. }
  18421. }
  18422. catch (Exception)
  18423. {
  18424. responseString = await response.Content.ReadAsStringAsync();
  18425. }
  18426. }
  18427. else
  18428. {
  18429. responseString = "methon error";
  18430. }
  18431. jw = JsonView(true, "success", responseString);
  18432. }
  18433. catch (Exception ex)
  18434. {
  18435. jw.Msg = "error " + ex.Message;
  18436. jw.Data = ex.StackTrace;
  18437. }
  18438. finally
  18439. {
  18440. client.Dispose();
  18441. }
  18442. return Ok(jw);
  18443. }
  18444. #endregion
  18445. #region 团组接待意见调查
  18446. /// <summary>
  18447. /// 团组接待意见调查 - 信息管理
  18448. /// 基础数据(团组)
  18449. /// </summary>
  18450. /// <returns></returns>
  18451. [HttpGet]
  18452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18453. public async Task<IActionResult> OpinionaireInit()
  18454. {
  18455. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18456. .Select(x => new
  18457. {
  18458. x.Id,
  18459. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18460. })
  18461. .OrderByDescending(x => x.Id)
  18462. .ToListAsync();
  18463. return Ok(JsonView(groupData, groupData.Count));
  18464. }
  18465. /// <summary>
  18466. /// 团组接待意见调查 - 信息管理
  18467. /// 列表
  18468. /// </summary>
  18469. /// <param name="groupId"></param>
  18470. /// <returns></returns>
  18471. [HttpGet("{groupId}")]
  18472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18473. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18474. {
  18475. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18476. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18477. .Select(x => new
  18478. {
  18479. x.Id,
  18480. x.TourGuideName,
  18481. x.CityName,
  18482. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18483. x.CreateTime
  18484. })
  18485. .OrderBy(x => x.Id)
  18486. .ToListAsync();
  18487. return Ok(JsonView(data));
  18488. }
  18489. /// <summary>
  18490. /// 团组接待意见调查 - 信息管理
  18491. /// 保存
  18492. /// </summary>
  18493. /// <param name="dto"></param>
  18494. /// <returns></returns>
  18495. [HttpPost]
  18496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18497. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18498. {
  18499. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18500. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18501. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18502. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18503. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18504. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18505. _opinionaireRep.BeginTran();
  18506. if (addData != null && addData.Count > 0)
  18507. {
  18508. foreach (var item in addData)
  18509. {
  18510. item.CreateUserId = currUserInfo.UserId;
  18511. item.DiId = dto.DiId;
  18512. }
  18513. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18514. }
  18515. if (updData != null && updData.Count > 0)
  18516. {
  18517. var upd = await _opinionaireRep._sqlSugar
  18518. .Updateable(updData)
  18519. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18520. .WhereColumns(x => new { x.Id })
  18521. .ExecuteCommandAsync();
  18522. }
  18523. _opinionaireRep.CommitTran();
  18524. return Ok(JsonView("操作成功!"));
  18525. }
  18526. /// <summary>
  18527. /// 团组接待意见调查 - 信息管理
  18528. /// 删除
  18529. /// </summary>
  18530. /// <param name="id"></param>
  18531. /// <returns></returns>
  18532. [HttpDelete("{id}")]
  18533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18534. public async Task<IActionResult> OpinionaireManageDel(int id)
  18535. {
  18536. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18537. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18538. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18539. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18540. if (!del) return Ok(JsonView("操作失败!"));
  18541. return Ok(JsonView("操作成功!"));
  18542. }
  18543. /// <summary>
  18544. /// 团组接待意见调查 - 用户
  18545. /// 列表
  18546. /// </summary>
  18547. /// <param name="diId"></param>
  18548. /// <returns></returns>
  18549. [HttpGet("{diId}")]
  18550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18551. public async Task<IActionResult> OpinionaireUserList(int diId)
  18552. {
  18553. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18554. var sql = string.Format(@"
  18555. SELECT
  18556. o.Id,
  18557. o.DiId,
  18558. di.TeamName AS 'GroupName',
  18559. di.VisitPNumber AS 'PeopleNumber',
  18560. di.ClientName AS 'LeadGroup',
  18561. di.VisitCountry AS 'Travel',
  18562. di.VisitDays AS 'Days',
  18563. o.CityName,
  18564. o.TourGuideName,
  18565. o.Catering,
  18566. o.CateringReason,
  18567. o.Stay,
  18568. o.StayReason,
  18569. o.[Route],
  18570. o.RouteReason,
  18571. o.OfficialActivity,
  18572. o.OfficialActivityReason,
  18573. o.TourGuide,
  18574. o.TourGuideReason,
  18575. o.[Translate],
  18576. o.TranslateReason,
  18577. o.Trip,
  18578. o.TripReason,
  18579. o.ESFileName,
  18580. o.SignatureDate,
  18581. o.Remark
  18582. FROM
  18583. Grp_Opinionaire o
  18584. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18585. WHERE
  18586. o.IsDel = 0
  18587. AND o.DiId = {0}
  18588. ORDER BY
  18589. o.Id ASC", diId);
  18590. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18591. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18592. return Ok(JsonView(data));
  18593. }
  18594. /// <summary>
  18595. /// 团组接待意见调查 - 用户
  18596. /// 保存
  18597. /// </summary>
  18598. /// <param name="dto"></param>
  18599. /// <returns></returns>
  18600. [HttpPost]
  18601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18602. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18603. {
  18604. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18605. foreach (var item in dto)
  18606. {
  18607. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18608. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18609. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18610. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18611. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18612. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18613. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18614. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18615. }
  18616. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18617. if (!Directory.Exists(filePathBase))
  18618. {
  18619. Directory.CreateDirectory(filePathBase);
  18620. }
  18621. #region 上传文件
  18622. var filePaths = new List<string>();
  18623. foreach (var item in dto)
  18624. {
  18625. var file = item.File;
  18626. // 将文件保存到指定位置
  18627. var filePath = Path.Combine(filePathBase, file.FileName);
  18628. using (var stream = new FileStream(filePath, FileMode.Create))
  18629. {
  18630. await file.CopyToAsync(stream);
  18631. }
  18632. //验证文件是否上传成功
  18633. if (!System.IO.File.Exists(filePath))
  18634. {
  18635. foreach (var filePathStr in filePaths)
  18636. {
  18637. System.IO.File.Delete(filePathStr);
  18638. }
  18639. return Ok(JsonView(false, "文件上传失败!"));
  18640. }
  18641. item.ESFileName = file.FileName;
  18642. }
  18643. #endregion
  18644. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18645. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18646. .UpdateColumns(x => new
  18647. {
  18648. x.Catering,
  18649. x.CateringReason,
  18650. x.Stay,
  18651. x.StayReason,
  18652. x.Route,
  18653. x.RouteReason,
  18654. x.OfficialActivity,
  18655. x.OfficialActivityReason,
  18656. x.TourGuide,
  18657. x.TourGuideReason,
  18658. x.Translate,
  18659. x.TranslateReason,
  18660. x.Trip,
  18661. x.TripReason,
  18662. x.ESFileName,
  18663. x.SignatureDate,
  18664. x.Remark
  18665. })
  18666. .WhereColumns(x => new { x.Id })
  18667. .ExecuteCommandAsync();
  18668. if (upd < 1)
  18669. {
  18670. foreach (var filePathStr in filePaths)
  18671. {
  18672. System.IO.File.Delete(filePathStr);
  18673. }
  18674. return Ok(JsonView(false));
  18675. }
  18676. return Ok(JsonView(true));
  18677. }
  18678. #endregion
  18679. #region 团组餐厅相关信息
  18680. /// <summary>
  18681. /// 团组相关餐厅信息
  18682. /// 基础数据(团组)
  18683. /// </summary>
  18684. /// <returns></returns>
  18685. [HttpGet]
  18686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18687. public async Task<IActionResult> RestaurantInit()
  18688. {
  18689. return Ok(await _restaurantRep.InitAsync());
  18690. }
  18691. /// <summary>
  18692. /// 团组相关餐厅信息
  18693. /// Item
  18694. /// </summary>
  18695. /// <param name="dto"></param>
  18696. /// <returns></returns>
  18697. [HttpPost]
  18698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18699. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18700. {
  18701. int portType = dto.PortType,
  18702. groupId = dto.GroupId;
  18703. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18704. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18705. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  18706. }
  18707. /// <summary>
  18708. /// 团组相关餐厅信息
  18709. /// List
  18710. /// </summary>
  18711. /// <param name="dto"></param>
  18712. /// <returns></returns>
  18713. [HttpPost]
  18714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18715. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18716. {
  18717. int portType = dto.PortType,
  18718. groupId = dto.GroupId;
  18719. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18720. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18721. var sql = string.Format(@" SELECT
  18722. ri.Id,
  18723. ri.GroupId,
  18724. ri.Date,
  18725. ri.StartTime,
  18726. ri.EndTime,
  18727. CASE WHEN ri.Type = 1 THEN '早餐'
  18728. WHEN ri.Type = 2 THEN '午餐'
  18729. WHEN ri.Type = 3 THEN '晚餐'
  18730. ELSE '其他'
  18731. END AS 'Type',
  18732. ri.Name,
  18733. ri.Address,
  18734. ri.Tel,
  18735. ri.Remark,
  18736. ri.CreateTime,
  18737. u.CnName AS CreateUserName
  18738. FROM
  18739. Grp_RestaurantInfo ri
  18740. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18741. WHERE
  18742. ri.IsDel = 0
  18743. AND ri.GroupId = {0}
  18744. ORDER BY
  18745. ri.Date ASC
  18746. ", groupId);
  18747. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18748. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18749. return Ok(JsonView(infos));
  18750. }
  18751. /// <summary>
  18752. /// 团组相关餐厅信息
  18753. /// Info
  18754. /// </summary>
  18755. /// <param name="dto"></param>
  18756. /// <returns></returns>
  18757. [HttpPost]
  18758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18759. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18760. {
  18761. int portType = dto.PortType,
  18762. id = dto.Id;
  18763. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18764. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18765. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18766. }
  18767. /// <summary>
  18768. /// 团组相关餐厅信息
  18769. /// Op
  18770. /// </summary>
  18771. /// <param name="dto"></param>
  18772. /// <returns></returns>
  18773. [HttpPost]
  18774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18775. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18776. {
  18777. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18778. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18779. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18780. return Ok(await _restaurantRep.OpAsync(dto));
  18781. }
  18782. /// <summary>
  18783. /// 团组相关餐厅信息
  18784. /// Del
  18785. /// </summary>
  18786. /// <param name="dto"></param>
  18787. /// <returns></returns>
  18788. [HttpPost]
  18789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18790. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18791. {
  18792. int userId = dto.DeleteUserId;
  18793. var id = dto.Id;
  18794. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18795. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18796. return Ok(await _restaurantRep.DelAsync(dto));
  18797. }
  18798. #endregion
  18799. // /// <summary>
  18800. // ///
  18801. // /// </summary>
  18802. // /// <param name="_dto"></param>
  18803. // /// <returns></returns>
  18804. // [HttpPost]
  18805. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18806. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18807. // {
  18808. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18809. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18810. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18811. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18812. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18813. // dic_psg.Add("客人", 974);
  18814. // dic_psg.Add("司机", 975);
  18815. // dic_psg.Add("导游", 976);
  18816. // dic_psg.Add("公司内部人员", 977);
  18817. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18818. // foreach (var item in list_visa)
  18819. // {
  18820. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18821. // temp.Id = item.Id;
  18822. // temp.DIId = item.DIId;
  18823. // temp.VisaClient = item.VisaClient;
  18824. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18825. // temp.VisaCurrency = item.VisaCurrency;
  18826. // temp.IsThird = item.IsThird;
  18827. // if (dic_psg.ContainsKey(item.PassengerType))
  18828. // {
  18829. // temp.PassengerType = dic_psg[item.PassengerType];
  18830. // }
  18831. // else {
  18832. // temp.PassengerType = -1;
  18833. // }
  18834. // temp.VisaNumber = item.VisaNumber;
  18835. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18836. // temp.CreateUserId = item.Operators;
  18837. // DateTime dt_ct;
  18838. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18839. // if (b_ct)
  18840. // {
  18841. // temp.CreateTime = dt_ct;
  18842. // }
  18843. // else
  18844. // {
  18845. // temp.CreateTime = DateTime.Now;
  18846. // }
  18847. // temp.DeleteTime = "";
  18848. // temp.DeleteUserId = 0;
  18849. // temp.Remark = item.Remark;
  18850. // if (string.IsNullOrEmpty(temp.Remark)) {
  18851. // temp.Remark = "";
  18852. // }
  18853. // temp.IsDel = item.IsDel;
  18854. // temp.VisaDescription = item.VisaAttachment;
  18855. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18856. //([Id]
  18857. // ,[DIId]
  18858. // ,[VisaClient]
  18859. // ,[VisaPrice]
  18860. // ,[VisaCurrency]
  18861. // ,[IsThird]
  18862. // ,[PassengerType]
  18863. // ,[VisaNumber]
  18864. // ,[VisaFreeNumber]
  18865. // ,[CreateUserId]
  18866. // ,[CreateTime]
  18867. // ,[DeleteTime]
  18868. // ,[DeleteUserId]
  18869. // ,[Remark]
  18870. // ,[IsDel]
  18871. // ,[visaDescription])
  18872. // VALUES
  18873. // ({0},{1},'{2}',{3},{4}
  18874. //,{5},{6},{7},{8},{9}
  18875. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18876. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18877. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18878. //);
  18879. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18880. // }
  18881. // return Ok(JsonView(true, "操作成功!"));
  18882. // }
  18883. /// <summary>
  18884. /// 123132123
  18885. /// </summary>
  18886. /// <param name="_dto"></param>
  18887. /// <returns></returns>
  18888. [HttpPost]
  18889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18890. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18891. {
  18892. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18893. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18894. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18895. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18896. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18897. dicDetail.Add(789, 1034);
  18898. dicDetail.Add(790, 1035);
  18899. dicDetail.Add(791, 1036);
  18900. dicDetail.Add(792, 1037);
  18901. dicDetail.Add(793, 1038);
  18902. dicDetail.Add(794, 1039);
  18903. dicDetail.Add(795, 1040);
  18904. dicDetail.Add(796, 1041);
  18905. dicDetail.Add(797, 1042);
  18906. dicDetail.Add(798, 1043);
  18907. dicDetail.Add(801, 1044);
  18908. dicDetail.Add(802, 1045);
  18909. dicDetail.Add(803, 1046);
  18910. Dictionary<int, int> dic = new Dictionary<int, int>();
  18911. dic.Add(806, 1027);
  18912. dic.Add(807, 1028);
  18913. dic.Add(808, 1029);
  18914. dic.Add(809, 1030);
  18915. dic.Add(810, 1031);
  18916. dic.Add(811, 1032);
  18917. dic.Add(812, 1033);
  18918. foreach (var item in list_visa)
  18919. {
  18920. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18921. temp.Coefficient = item.coefficient;
  18922. DateTime dtCrt;
  18923. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18924. if (b1)
  18925. {
  18926. temp.CreateTime = dtCrt;
  18927. }
  18928. else
  18929. {
  18930. temp.CreateTime = DateTime.Now;
  18931. }
  18932. temp.CreateUserId = item.Operators;
  18933. temp.DeleteTime = "";
  18934. temp.DeleteUserId = 0;
  18935. temp.DiId = int.Parse(item.DIID);
  18936. temp.FilePath = item.FilePath;
  18937. temp.IsDel = item.IsDel;
  18938. temp.Price = item.Price;
  18939. temp.PriceCount = 1;
  18940. temp.PriceCurrency = item.Currency;
  18941. int detailId = 0;
  18942. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18943. {
  18944. detailId = dicDetail[item.PriceTypeDetail];
  18945. }
  18946. temp.PriceDetailType = detailId;
  18947. temp.PriceDt = DateTime.Now;
  18948. temp.PriceName = item.PriceName;
  18949. temp.PriceSum = item.Price;
  18950. int tid = 0;
  18951. if (dic.ContainsKey(item.PriceType))
  18952. {
  18953. tid = dic[item.PriceType];
  18954. }
  18955. temp.PriceType = tid;
  18956. temp.Remark = item.Remark;
  18957. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18958. }
  18959. return Ok(JsonView(true, "操作成功!"));
  18960. }
  18961. [HttpPost]
  18962. public IActionResult TimeTest()
  18963. {
  18964. var jw = JsonView(false, "error");
  18965. _sqlSugar.BeginTran();
  18966. try
  18967. {
  18968. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18969. .Select(x => new Crm_NewClientData
  18970. {
  18971. Id = x.Id,
  18972. Client = x.Client,
  18973. Contact = x.Contact,
  18974. Location = x.Location,
  18975. })
  18976. .ToList();
  18977. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  18978. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18979. Stopwatch stopwatch = new Stopwatch();
  18980. // 开始计时
  18981. stopwatch.Start();
  18982. foreach (var item in clientList)
  18983. {
  18984. EncryptionProcessor.DecryptProperties(item);
  18985. }
  18986. stopwatch.Stop();
  18987. jw.Code = 200;
  18988. jw.Data = stopwatch.ElapsedMilliseconds;
  18989. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  18990. }
  18991. catch (Exception ex)
  18992. {
  18993. jw.Code = 400;
  18994. jw.Msg = ex.Message;
  18995. }
  18996. return Ok(jw);
  18997. }
  18998. }
  18999. }