GroupsController.cs 1019 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020
  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. var feeBasePermIds = new List<int>() { dto.UserId };
  7718. var feeBasePerm = AppSettingsHelper.Get<PermissionViewUserview>("FeeBasePerm");
  7719. if (feeBasePerm.Any()) feeBasePermIds.AddRange(feeBasePerm.Select(x => x.Id).ToList());
  7720. var permissions = new List<Grp_EnterExitCostPermission>();
  7721. foreach (var userId1 in feeBasePermIds)
  7722. {
  7723. permissions.Add(new Grp_EnterExitCostPermission()
  7724. {
  7725. GroupId = dto.GroupId,
  7726. UserId = userId1,
  7727. Permission = 1,
  7728. CreateUserId = dto.UserId,
  7729. });
  7730. }
  7731. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7732. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7733. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7734. newExterData.DiId = groupId;
  7735. newExterData.CreateUserId = userId;
  7736. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7737. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7738. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7739. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7740. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7741. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7742. //数据如果存在执行删除
  7743. if (enterExitCostInfo != null)
  7744. {
  7745. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7746. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7747. .Where(x => x.Id == enterExitCostInfo.Id)
  7748. .ExecuteCommand();
  7749. _sqlSugar.Updateable<Grp_DayAndCost>()
  7750. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7751. .Where(x => x.DiId == groupId)
  7752. .ExecuteCommand();
  7753. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7754. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7755. .Where(x => x.Diid == groupId)
  7756. .ExecuteCommand();
  7757. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7758. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7759. .Where(x => x.GroupId == groupId)
  7760. .ExecuteCommand();
  7761. }
  7762. //执行insert
  7763. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7764. if (insertId < 1)
  7765. {
  7766. _sqlSugar.RollbackTran();
  7767. return Ok(JsonView(false, "草稿数据导入失败!"));
  7768. }
  7769. if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
  7770. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7771. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7772. #region 默认添加权限
  7773. #endregion
  7774. _sqlSugar.CommitTran();
  7775. //执行操作之后
  7776. //生成默认文件pdf并且通知人员
  7777. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7778. {
  7779. DiId = groupId,
  7780. ExportType = 1,
  7781. SubTypeId = 1005
  7782. }, "pdf");
  7783. //发送通知
  7784. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7785. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7786. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7787. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7788. //汇率信息记录
  7789. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7790. return Ok(JsonView(true));
  7791. }
  7792. catch (Exception ex)
  7793. {
  7794. _sqlSugar.RollbackTran();
  7795. return Ok(JsonView(false, ex.Message));
  7796. }
  7797. }
  7798. #endregion
  7799. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7800. /// <summary>
  7801. /// 获取币种基础数据(含逻辑处理)
  7802. /// </summary>
  7803. /// <returns></returns>
  7804. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7805. {
  7806. //默认币种显示
  7807. var _currencyInfos = _currencyInit;
  7808. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7809. if (_currencyRate.Count > 0)
  7810. {
  7811. foreach (var item in _currencyInfos)
  7812. {
  7813. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7814. if (rateInfo != null)
  7815. {
  7816. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7817. rate1 *= 1.035M;
  7818. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7819. }
  7820. }
  7821. }
  7822. return _currencyInfos;
  7823. }
  7824. /// <summary>
  7825. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7826. /// </summary>
  7827. /// <returns></returns>
  7828. [HttpPost]
  7829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7830. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7831. {
  7832. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7833. //SetDataInfoView
  7834. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7835. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7836. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7837. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7838. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7839. //默认币种显示
  7840. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7841. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7842. return Ok(JsonView(true, "查询成功!", new
  7843. {
  7844. WordTypeData = _WordTypeData,
  7845. ExcelTypeData = _ExcelTypeData,
  7846. CurrencyInit = _currencyInfos,
  7847. viewPermissionData = viewPermissionData
  7848. }));
  7849. }
  7850. /// <summary>
  7851. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7852. /// </summary>
  7853. /// <returns></returns>
  7854. [HttpPost]
  7855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7856. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7857. {
  7858. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7859. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7860. RefAsync<int> total = 0;
  7861. int diId = 0;
  7862. var status = int.TryParse(dto.GroupName, out diId);
  7863. string sql = string.Format(@"SELECT
  7864. Id,
  7865. TeamName GroupName,
  7866. CASE WHEN EXISTS (
  7867. SELECT
  7868. 1
  7869. FROM
  7870. Grp_EnterExitCost
  7871. WHERE
  7872. IsDel = 0
  7873. AND DiId = di.Id
  7874. ) THEN 1 ELSE 0 END AS [IsNull],
  7875. CASE WHEN EXISTS(
  7876. SELECT
  7877. TOP 1 *
  7878. FROM
  7879. Grp_EnterExitCost
  7880. WHERE
  7881. IsDel = 0
  7882. AND DiId = di.Id
  7883. AND CreateUserId = {0}
  7884. ORDER BY
  7885. CreateTime DESC
  7886. ) THEN 1 ELSE 0 END AS [IsEdit],
  7887. CASE WHEN EXISTS(
  7888. SELECT
  7889. TOP 1 *
  7890. FROM
  7891. Grp_EnterExitCost
  7892. WHERE
  7893. IsDel = 0
  7894. AND DiId = di.Id
  7895. AND CreateUserId = {0}
  7896. ORDER BY
  7897. CreateTime DESC
  7898. ) THEN 1 WHEN EXISTS(
  7899. SELECT
  7900. TOP 1 *
  7901. FROM
  7902. Grp_EnterExitCostPermission
  7903. WHERE
  7904. IsDel = 0
  7905. AND GroupId = di.Id
  7906. AND Permission = 1
  7907. AND UserId = {0}
  7908. ORDER BY
  7909. CreateTime DESC
  7910. ) THEN 1 ELSE 0 END AS [IsView]
  7911. FROM
  7912. Grp_DelegationInfo di
  7913. WHERE
  7914. di.Isdel = 0 ", dto.CurrUserId);
  7915. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7916. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7917. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7918. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7919. .OrderByDescending(x => x.Id)
  7920. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7921. return Ok(JsonView(true, "查询成功!", data, total));
  7922. }
  7923. /// <summary>
  7924. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7925. /// </summary>
  7926. /// <returns></returns>
  7927. [HttpPost]
  7928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7929. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7930. {
  7931. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7932. RefAsync<int> total = 0;
  7933. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7934. .Where(x => x.IsDel == 0 && x.STid == 66)
  7935. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7936. .Select(x => new
  7937. {
  7938. id = x.Id,
  7939. name = x.Name,
  7940. remark = x.Remark,
  7941. })
  7942. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7943. return Ok(JsonView(true, "查询成功!", data, total));
  7944. }
  7945. /// <summary>
  7946. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7947. /// </summary>
  7948. /// <returns></returns>
  7949. [HttpPost]
  7950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7951. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7952. {
  7953. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7954. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7955. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7956. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7957. var groupOtherRateData = groupRateData.TeamRates;
  7958. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7959. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7960. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7961. groupOtherRateData = groupOtherRateData
  7962. .Select(x => new TeamRateDescAddCurrencyIdView
  7963. {
  7964. CurrencyId = x.CurrencyId,
  7965. CurrencyName = x.CurrencyName,
  7966. CurrencyCode = x.CurrencyCode,
  7967. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7968. }).ToList();
  7969. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7970. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7971. }
  7972. /// <summary>
  7973. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7974. /// </summary>
  7975. /// <returns></returns>
  7976. [HttpPost]
  7977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7978. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7979. {
  7980. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7981. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7982. var tipsData = new List<int>() { 1, 2, 3 };
  7983. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7984. if (dto.TipsType == 1)
  7985. {
  7986. //默认币种显示
  7987. var _currencyInfos = _currencyInit;
  7988. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7989. List<dynamic> reteInfos = new List<dynamic>();
  7990. if (_currencyRate.Count > 0)
  7991. {
  7992. foreach (var item in _currencyInfos)
  7993. {
  7994. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7995. if (rateInfo != null)
  7996. {
  7997. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7998. decimal rate1 = item.Rate;
  7999. rate1 *= 1.03M;
  8000. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  8001. reteInfos.Add(new
  8002. {
  8003. currCode = item.CurrencyCode,
  8004. currName = item.CurrencyName,
  8005. rate = rate2,
  8006. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  8007. });
  8008. }
  8009. }
  8010. }
  8011. return Ok(JsonView(true, "查询成功!", reteInfos));
  8012. }
  8013. else if (dto.TipsType == 2)
  8014. {
  8015. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  8016. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8017. }
  8018. else if (dto.TipsType == 3)
  8019. {
  8020. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8021. return Ok(JsonView(true, "查询成功!", airData.Data));
  8022. }
  8023. return Ok(JsonView(false));
  8024. }
  8025. /// <summary>
  8026. /// 团组模块 - 出入境国家费用标准-移动端 List
  8027. /// </summary>
  8028. /// <returns></returns>
  8029. [HttpPost]
  8030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8031. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8032. {
  8033. Stopwatch sw = new Stopwatch();
  8034. sw.Start();
  8035. RefAsync<int> total = 0;
  8036. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8037. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8038. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8039. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8040. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8041. .Select((ntf, sd, u) => new
  8042. {
  8043. Id = ntf.Id,
  8044. Area = $"{ntf.Country}-{ntf.City}",
  8045. Currency = ntf.Currency,
  8046. CurrencyCode = sd.Name,
  8047. CurrencyName = sd.Remark,
  8048. RoomCost = ntf.RoomCost,
  8049. FoodCost = ntf.FoodCost,
  8050. PublicCost = ntf.PublicCost,
  8051. LastUpdateUserId = ntf.LastUpdateUserId,
  8052. LastUpdateUserName = u.CnName,
  8053. LastUpdateTime = ntf.LastUpdateTime,
  8054. })
  8055. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8056. sw.Stop();
  8057. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8058. }
  8059. /// <summary>
  8060. /// 团组模块 - 出入境费用-移动端 - Info
  8061. /// </summary>
  8062. /// <returns></returns>
  8063. [HttpPost]
  8064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8065. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8066. {
  8067. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8068. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8069. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8070. return Ok(data);
  8071. }
  8072. /// <summary>
  8073. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8074. /// </summary>
  8075. /// <returns></returns>
  8076. [HttpPost]
  8077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8078. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8079. {
  8080. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8081. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8082. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8083. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8084. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8085. mobileInfo.DiId = dto.DiId;
  8086. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8087. if (eecInfo == null) return Ok(mobileInfo);
  8088. //验证查看权限
  8089. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8090. //if (!isView) return Ok(JsonView(false, msg));
  8091. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8092. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8093. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8094. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8095. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8096. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8097. {
  8098. SubId = dac.Id,
  8099. DiId = dac.DiId,
  8100. Type = dac.Type,
  8101. Days = dac.Days,
  8102. NationalTravelFeeId = dac.NationalTravelFeeId,
  8103. Arae = $"{ntf.Country}-{ntf.City}",
  8104. Cost = dac.Cost,
  8105. Currency = dac.Currency,
  8106. CurrencyName = sd.Name,
  8107. SubTotal = dac.SubTotal,
  8108. })
  8109. .ToList();
  8110. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8111. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8112. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8113. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8114. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8115. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8116. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8117. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8118. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8119. //其他款项
  8120. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8121. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8122. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8123. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8124. .OrderBy((dop, sd1, sd2) => dop.Index)
  8125. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8126. {
  8127. SubId = dop.Id,
  8128. DiId = dop.Diid,
  8129. Index = dop.Index,
  8130. SetDataId = dop.SetDataId,
  8131. SetDataName = sd1.Name,
  8132. Cost = dop.Cost,
  8133. Currency = dop.Currency,
  8134. CurrencyName = sd2.Remark,
  8135. SubTotal = dop.SubTotal,
  8136. Remark = dop.Remark,
  8137. })
  8138. .ToArray();
  8139. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8140. return Ok(mobileInfo);
  8141. }
  8142. /// <summary>
  8143. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8144. /// </summary>
  8145. /// <returns></returns>
  8146. [HttpPost]
  8147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8148. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8149. {
  8150. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8151. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8152. //验证查看权限
  8153. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8154. if (!isView) return Ok(JsonView(false, msg));
  8155. var userIds = Array.Empty<int>();
  8156. userIds = await _sqlSugar
  8157. .Queryable<Grp_EnterExitCostPermission>()
  8158. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8159. .Select(x => x.UserId)
  8160. .ToArrayAsync();
  8161. return Ok(userIds);
  8162. }
  8163. /// <summary>
  8164. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8165. /// </summary>
  8166. /// <returns></returns>
  8167. [HttpPost]
  8168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8169. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8170. {
  8171. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8172. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8173. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8174. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8175. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8176. //验证查看权限
  8177. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8178. //if (!isView) return Ok(JsonView(false, msg));
  8179. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8180. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8181. var subType = dto.SubType;
  8182. if (subType == 1) //1:境内费用
  8183. {
  8184. var oneData = new ChoiceOneMobileSubInfoView()
  8185. {
  8186. Id = eecInfo.Id,
  8187. ChoiceOne = eecInfo.ChoiceOne,
  8188. ChoiceOneTotalCost = eecInfo.InsidePay,
  8189. Visa = eecInfo.Visa,
  8190. VisaRemark = eecInfo.VisaRemark,
  8191. YiMiao = eecInfo.YiMiao,
  8192. HeSuan = eecInfo.HeSuan,
  8193. Service = eecInfo.Service,
  8194. Ticket = eecInfo.Ticket,
  8195. Safe = eecInfo.Safe,
  8196. FirstItemRemark = eecInfo.FirstItemRemark
  8197. };
  8198. return Ok(JsonView(oneData));
  8199. }
  8200. else if (subType == 2) //2:国际旅费
  8201. {
  8202. var twoData = new ChoiceTwoMobileSubInfoView()
  8203. {
  8204. Id = eecInfo.Id,
  8205. ChoiceTwoJJ = eecInfo.SumJJC,
  8206. OutsideJJPay = eecInfo.OutsideJJPay,
  8207. ChoiceTwoGW = eecInfo.SumGWC,
  8208. OutsideGWPay = eecInfo.OutsideGWPay,
  8209. ChoiceTwoTD = eecInfo.SumTDC,
  8210. OutsideTDPay = eecInfo.OutsideTDPay,
  8211. AirJJ = eecInfo.AirJJ,
  8212. AirGW = eecInfo.AirGW,
  8213. AirTD = eecInfo.AirTD,
  8214. CityTranffic = eecInfo.CityTranffic,
  8215. TwoItemRemark = eecInfo.TwoItemRemark
  8216. };
  8217. return Ok(JsonView(twoData));
  8218. }
  8219. else if (subType == 3) //3:住宿费
  8220. {
  8221. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8222. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8223. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8224. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8225. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8226. {
  8227. SubId = dac.Id,
  8228. DiId = dac.DiId,
  8229. Type = dac.Type,
  8230. Days = dac.Days,
  8231. NationalTravelFeeId = dac.NationalTravelFeeId,
  8232. Arae = $"{ntf.Country}-{ntf.City}",
  8233. Cost = dac.Cost,
  8234. Currency = dac.Currency,
  8235. CurrencyName = sd.Name,
  8236. SubTotal = dac.SubTotal,
  8237. })
  8238. .ToArray();
  8239. var data = new ChoiceMobileSubInfo3To6View()
  8240. {
  8241. ParentId = eecInfo.Id,
  8242. Choice = eecInfo.ChoiceThree,
  8243. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8244. Details = dayAndCostDatas
  8245. };
  8246. return Ok(JsonView(data));
  8247. }
  8248. else if (subType == 4) //4:伙食费
  8249. {
  8250. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8251. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8252. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8253. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8254. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8255. {
  8256. SubId = dac.Id,
  8257. DiId = dac.DiId,
  8258. Type = dac.Type,
  8259. Days = dac.Days,
  8260. NationalTravelFeeId = dac.NationalTravelFeeId,
  8261. Arae = $"{ntf.Country}-{ntf.City}",
  8262. Cost = dac.Cost,
  8263. Currency = dac.Currency,
  8264. CurrencyName = sd.Name,
  8265. SubTotal = dac.SubTotal,
  8266. })
  8267. .ToArray();
  8268. var data = new ChoiceMobileSubInfo3To6View()
  8269. {
  8270. ParentId = eecInfo.Id,
  8271. Choice = eecInfo.ChoiceFour,
  8272. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8273. Details = dayAndCostDatas
  8274. };
  8275. return Ok(JsonView(data));
  8276. }
  8277. else if (subType == 5) //5:公杂费
  8278. {
  8279. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8280. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8281. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8282. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8283. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8284. {
  8285. SubId = dac.Id,
  8286. DiId = dac.DiId,
  8287. Type = dac.Type,
  8288. Days = dac.Days,
  8289. NationalTravelFeeId = dac.NationalTravelFeeId,
  8290. Arae = $"{ntf.Country}-{ntf.City}",
  8291. Cost = dac.Cost,
  8292. Currency = dac.Currency,
  8293. CurrencyName = sd.Name,
  8294. SubTotal = dac.SubTotal,
  8295. })
  8296. .ToArray();
  8297. var data = new ChoiceMobileSubInfo3To6View()
  8298. {
  8299. ParentId = eecInfo.Id,
  8300. Choice = eecInfo.ChoiceFive,
  8301. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8302. Details = dayAndCostDatas
  8303. };
  8304. return Ok(JsonView(data));
  8305. }
  8306. else if (subType == 6) //6:培训费
  8307. {
  8308. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8309. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8310. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8311. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8312. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8313. {
  8314. SubId = dac.Id,
  8315. DiId = dac.DiId,
  8316. Type = dac.Type,
  8317. Days = dac.Days,
  8318. NationalTravelFeeId = dac.NationalTravelFeeId,
  8319. Arae = $"{ntf.Country}-{ntf.City}",
  8320. Cost = dac.Cost,
  8321. Currency = dac.Currency,
  8322. CurrencyName = sd.Name,
  8323. SubTotal = dac.SubTotal,
  8324. })
  8325. .ToArray();
  8326. var data = new ChoiceMobileSubInfo3To6View()
  8327. {
  8328. ParentId = eecInfo.Id,
  8329. Choice = eecInfo.ChoiceSix,
  8330. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8331. Details = dayAndCostDatas
  8332. };
  8333. return Ok(JsonView(data));
  8334. }
  8335. else if (subType == 7) //7:其他
  8336. {
  8337. //其他款项
  8338. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8339. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8340. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8341. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8342. .OrderBy((dop, sd1, sd2) => dop.Index)
  8343. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8344. {
  8345. SubId = dop.Id,
  8346. DiId = dop.Diid,
  8347. Index = dop.Index,
  8348. SetDataId = dop.SetDataId,
  8349. SetDataName = sd1.Name,
  8350. Cost = dop.Cost,
  8351. Currency = dop.Currency,
  8352. CurrencyName = sd2.Name,
  8353. SubTotal = dop.SubTotal,
  8354. Remark = dop.Remark,
  8355. })
  8356. .ToArray();
  8357. var data = new ChoiceSevenMobileSubInfoView()
  8358. {
  8359. ParentId = eecInfo.Id,
  8360. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8361. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8362. Details = otherData
  8363. };
  8364. return Ok(JsonView(data));
  8365. }
  8366. return Ok(JsonView(false));
  8367. }
  8368. #region op
  8369. /// <summary>
  8370. /// 移动端更新费用消息通知
  8371. /// </summary>
  8372. /// <param name="diid"></param>
  8373. /// <param name="id"></param>
  8374. /// <param name="currUserId"></param>
  8375. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8376. {
  8377. try
  8378. {
  8379. ////生成默认文件pdf并且通知人员
  8380. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8381. //{
  8382. // DiId = diid,
  8383. // ExportType = 1,
  8384. // SubTypeId = 1005
  8385. //}, "pdf");
  8386. ////发送通知
  8387. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8388. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8389. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8390. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8391. ////汇率信息记录
  8392. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8393. }
  8394. catch (Exception ex)
  8395. {
  8396. //记录日志
  8397. throw;
  8398. }
  8399. }
  8400. /// <summary>
  8401. /// 验证出入境费用数据是否存在
  8402. /// 不存在添加
  8403. /// </summary>
  8404. /// <param name="diId"></param>
  8405. /// <param name="currUserId"></param>
  8406. /// <returns></returns>
  8407. /// <exception cref="CustomException"></exception>
  8408. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8409. {
  8410. var parentId = 0;
  8411. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8412. if (info != null)
  8413. {
  8414. parentId = info.Id;
  8415. }
  8416. else
  8417. {
  8418. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8419. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8420. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8421. parentId = addId;
  8422. }
  8423. return parentId;
  8424. }
  8425. /// <summary>
  8426. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8427. /// </summary>
  8428. /// <returns></returns>
  8429. [HttpPost]
  8430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8431. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8432. {
  8433. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8434. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8435. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8436. //验证编辑权限
  8437. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8438. //if (!isEdit) return Ok(JsonView(false, msg));
  8439. var permissions = new List<Grp_EnterExitCostPermission>();
  8440. foreach (var userId in dto.UserIds)
  8441. {
  8442. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8443. }
  8444. if (permissions.Any())
  8445. {
  8446. _sqlSugar.BeginTran();
  8447. try
  8448. {
  8449. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8450. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8451. if (result < 1)
  8452. {
  8453. _sqlSugar.RollbackTran();
  8454. return Ok(JsonView(false));
  8455. }
  8456. }
  8457. catch (Exception ex)
  8458. {
  8459. _sqlSugar.RollbackTran();
  8460. return Ok(JsonView(false, ex.Message));
  8461. }
  8462. _sqlSugar.CommitTran();
  8463. return Ok(JsonView(true));
  8464. }
  8465. return Ok(JsonView(false));
  8466. }
  8467. /// <summary>
  8468. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8469. /// </summary>
  8470. /// <returns></returns>
  8471. [HttpPost]
  8472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8473. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8474. {
  8475. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8476. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8477. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8478. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8479. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8480. int id = dto.Id;
  8481. if (id <= 0) //add
  8482. {
  8483. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8484. if (add < 1) return Ok(JsonView(false));
  8485. id = add;
  8486. }
  8487. else //update
  8488. {
  8489. ////验证编辑权限
  8490. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8491. //if (!isEdit) return Ok(JsonView(false, msg));
  8492. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8493. if (upd < 1) return Ok(JsonView(false));
  8494. }
  8495. #region 汇率变更时更改币种相关费用
  8496. var opDayCosts = new List<Grp_DayAndCost>();
  8497. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8498. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8499. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8500. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8501. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8502. .Select((dac, sd) => new
  8503. {
  8504. dac.Id,
  8505. dac.DiId,
  8506. CurrencyCode = sd.Name,
  8507. dac.Cost
  8508. })
  8509. .ToList();
  8510. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8511. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8512. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8513. .Select((dop, sd) => new
  8514. {
  8515. dop.Id,
  8516. dop.Diid,
  8517. CurrencyCode = sd.Name,
  8518. dop.Cost
  8519. })
  8520. .ToList();
  8521. if (dayCosts.Count > 0)
  8522. {
  8523. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8524. foreach (var dc in new_dayCosts)
  8525. {
  8526. var thisCurrency = dc.Key.ToUpper();
  8527. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8528. if (thisRate == 0.00M) continue;
  8529. foreach (var dcSub in dc)
  8530. {
  8531. opDayCosts.Add(new Grp_DayAndCost()
  8532. {
  8533. Id = dcSub.Id,
  8534. DiId = dcSub.DiId,
  8535. Cost = dcSub.Cost,
  8536. SubTotal = dcSub.Cost * thisRate,
  8537. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8538. });
  8539. }
  8540. }
  8541. if (opDayCosts.Count > 0)
  8542. {
  8543. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8544. }
  8545. }
  8546. if (dayOtherCosts.Count > 0)
  8547. {
  8548. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8549. foreach (var dc in new_dayOtherCosts)
  8550. {
  8551. var thisCurrency = dc.Key.ToUpper();
  8552. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8553. if (thisRate == 0.00M) continue;
  8554. foreach (var dcSub in dc)
  8555. {
  8556. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8557. {
  8558. Id = dcSub.Id,
  8559. Diid = dcSub.Diid,
  8560. Cost = dcSub.Cost,
  8561. SubTotal = dcSub.Cost * thisRate,
  8562. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8563. });
  8564. }
  8565. }
  8566. if (opDayOtherCosts.Count > 0)
  8567. {
  8568. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8569. }
  8570. }
  8571. #endregion
  8572. //消息通知
  8573. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8574. //汇率信息记录
  8575. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8576. return Ok(JsonView(new { parentId = id }));
  8577. }
  8578. /// <summary>
  8579. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8580. /// </summary>
  8581. /// <returns></returns>
  8582. [HttpPost]
  8583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8584. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8585. {
  8586. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8587. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8588. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8589. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8590. int id = dto.Id;
  8591. if (id <= 0) //add
  8592. {
  8593. checkboxInfo.CreateUserId = dto.CurrUserId;
  8594. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8595. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8596. if (add < 1) return Ok(JsonView(false));
  8597. }
  8598. else //update
  8599. {
  8600. ////验证编辑权限
  8601. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8602. //if (!isEdit) return Ok(JsonView(false, msg));
  8603. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8604. .UpdateColumns(x => new
  8605. {
  8606. x.ChoiceOne,
  8607. x.ChoiceTwo,
  8608. x.SumJJC,
  8609. x.SumGWC,
  8610. x.SumTDC,
  8611. x.ChoiceThree,
  8612. x.ChoiceFour,
  8613. x.ChoiceFive,
  8614. x.ChoiceSix,
  8615. x.OtherExpenses_Checked
  8616. })
  8617. .Where(x => x.Id == id)
  8618. .ExecuteCommandAsync();
  8619. if (upd < 1) return Ok(JsonView(false));
  8620. }
  8621. return Ok(JsonView(new { parentId = id }));
  8622. }
  8623. /// <summary>
  8624. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8625. /// </summary>
  8626. /// <returns></returns>
  8627. [HttpPost]
  8628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8629. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8630. {
  8631. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8632. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8633. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8634. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8635. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8636. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8637. var checkboxInfo = new Grp_EnterExitCost()
  8638. {
  8639. Id = id,
  8640. DiId = diId,
  8641. CreateUserId = currUserId
  8642. };
  8643. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8644. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8645. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8646. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8647. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8648. if (id <= 0) //add
  8649. {
  8650. checkboxInfo.CreateUserId = dto.CurrUserId;
  8651. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8652. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8653. if (add < 1) return Ok(JsonView(false));
  8654. }
  8655. else //update
  8656. {
  8657. ////验证编辑权限
  8658. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8659. //if (!isEdit) return Ok(JsonView(false, msg));
  8660. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8661. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8662. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8663. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8664. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8665. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8666. .Where(x => x.Id == id)
  8667. .ExecuteCommandAsync();
  8668. if (upd < 1) return Ok(JsonView(false));
  8669. }
  8670. return Ok(JsonView(new { parentId = id }));
  8671. }
  8672. /// <summary>
  8673. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8674. /// </summary>
  8675. /// <returns></returns>
  8676. [HttpPost]
  8677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8678. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8679. {
  8680. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8681. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8682. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8683. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8684. info.FirstItemRemark = dto.FirstItemRemark;
  8685. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8686. int id = dto.Id;
  8687. if (id <= 0) //add
  8688. {
  8689. info.CreateUserId = dto.CurrUserId;
  8690. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8691. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8692. if (add < 1) return Ok(JsonView(false));
  8693. id = add;
  8694. }
  8695. else //update
  8696. {
  8697. ////验证编辑权限
  8698. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8699. //if (!isEdit) return Ok(JsonView(false, msg));
  8700. var upd = await _sqlSugar.Updateable(info)
  8701. .UpdateColumns(x => new
  8702. {
  8703. x.ChoiceOne,
  8704. x.InsidePay,
  8705. x.VisaRemark,
  8706. x.Visa,
  8707. x.Service,
  8708. x.Safe,
  8709. x.Ticket,
  8710. x.HeSuan,
  8711. x.YiMiao,
  8712. x.FirstItemRemark
  8713. })
  8714. .Where(x => x.Id == id)
  8715. .ExecuteCommandAsync();
  8716. if (upd < 1) return Ok(JsonView(false));
  8717. }
  8718. //消息通知
  8719. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8720. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8721. }
  8722. /// <summary>
  8723. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8724. /// </summary>
  8725. /// <returns></returns>
  8726. [HttpPost]
  8727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8728. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8729. {
  8730. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8731. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8732. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8733. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8734. info.OutsideJJPay = dto.OutsideJJPay;
  8735. info.OutsideGWPay = dto.OutsideGWPay;
  8736. info.OutsideTDPay = dto.OutsideTDPay;
  8737. info.AirJJ = dto.AirJJ;
  8738. info.AirGW = dto.AirGW;
  8739. info.AirTD = dto.AirTD;
  8740. info.CityTranffic = dto.CityTranffic;
  8741. info.TwoItemRemark = dto.TwoItemRemark;
  8742. info.SumJJC = dto.ChoiceTwoJJ;
  8743. info.SumGWC = dto.ChoiceTwoGW;
  8744. info.SumTDC = dto.ChoiceTwoTD;
  8745. int id = dto.Id;
  8746. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8747. if (id <= 0) //add
  8748. {
  8749. info.CreateUserId = dto.CurrUserId;
  8750. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8751. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8752. if (addId <= 0) return Ok(JsonView(false));
  8753. id = addId;
  8754. }
  8755. else //update
  8756. {
  8757. ////验证编辑权限
  8758. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8759. //if (!isEdit) return Ok(JsonView(false, msg));
  8760. var upd = await _sqlSugar.Updateable(info)
  8761. .UpdateColumns(x => new
  8762. {
  8763. x.SumJJC,
  8764. x.OutsideJJPay,
  8765. x.SumGWC,
  8766. x.OutsideGWPay,
  8767. x.SumTDC,
  8768. x.OutsideTDPay,
  8769. x.AirJJ,
  8770. x.AirGW,
  8771. x.AirTD,
  8772. x.CityTranffic,
  8773. x.TwoItemRemark
  8774. })
  8775. .Where(x => x.Id == id)
  8776. .ExecuteCommandAsync();
  8777. if (upd < 1) return Ok(JsonView(false));
  8778. }
  8779. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8780. gwcItemTotal = info.AirGW + info.CityTranffic;
  8781. tdcItemTotal = info.AirTD + info.CityTranffic;
  8782. //消息通知
  8783. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8784. return Ok(JsonView(new
  8785. {
  8786. parentId = id,
  8787. choiceTwoJJ = dto.ChoiceTwoJJ,
  8788. jjcItemTotal = jjcItemTotal,
  8789. choiceTwoGW = dto.ChoiceTwoGW,
  8790. gwcItemTotal = gwcItemTotal,
  8791. choiceTwoTD = dto.ChoiceTwoTD,
  8792. tdcItemTotal = tdcItemTotal
  8793. }));
  8794. }
  8795. /// <summary>
  8796. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8797. /// </summary>
  8798. /// <returns></returns>
  8799. [HttpPost]
  8800. [ApiExplorerSettings(IgnoreApi = true)]
  8801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8802. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8803. {
  8804. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8805. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8806. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8807. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8808. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8809. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8810. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8811. var infos = infos1.Select(x => new Grp_DayAndCost
  8812. {
  8813. Id = x.Id,
  8814. DiId = dto.DiId,
  8815. Type = dto.FeeType,
  8816. Days = x.Days,
  8817. NationalTravelFeeId = x.NationalTravelFeeId,
  8818. Cost = x.Cost,
  8819. Currency = x.Currency,
  8820. SubTotal = x.SubTotal,
  8821. CreateUserId = dto.CurrUserId
  8822. })
  8823. .ToList();
  8824. var adds = infos.Where(x => x.Id <= 0).ToList();
  8825. var upds = infos.Where(x => x.Id > 0).ToList();
  8826. if (adds.Count > 0)
  8827. {
  8828. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8829. if (add < 1) return Ok(JsonView(false));
  8830. }
  8831. if (upds.Count > 0)
  8832. {
  8833. var upd = await _sqlSugar.Updateable(adds)
  8834. .UpdateColumns(x => new
  8835. {
  8836. x.Days,
  8837. x.NationalTravelFeeId,
  8838. x.Cost,
  8839. x.Currency,
  8840. x.SubTotal
  8841. })
  8842. .WhereColumns(x => new { x.Id })
  8843. .ExecuteCommandAsync();
  8844. if (upd < 1) return Ok(JsonView(false));
  8845. }
  8846. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8847. //消息通知
  8848. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8849. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8850. return Ok(JsonView(new { itemTotal = itemTotal }));
  8851. }
  8852. /// <summary>
  8853. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8854. /// </summary>
  8855. /// <returns></returns>
  8856. [HttpPost]
  8857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8858. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8859. {
  8860. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8861. int subId = dto.SubId, feeType = dto.FeeType;
  8862. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8863. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8864. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8865. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8866. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8867. subInfo.Id = subId;
  8868. subInfo.DiId = dto.DiId;
  8869. if (feeType == 3) subInfo.Type = 1;
  8870. else if (feeType == 4) subInfo.Type = 2;
  8871. else if (feeType == 5) subInfo.Type = 3;
  8872. else if (feeType == 6) subInfo.Type = 4;
  8873. subInfo.CreateUserId = dto.CurrUserId;
  8874. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8875. if (parentId < 1) return Ok(JsonView(false));
  8876. //子表op
  8877. if (subId < 1)
  8878. {
  8879. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8880. if (subAdd < 1) return Ok(JsonView(false));
  8881. }
  8882. else
  8883. {
  8884. ////验证编辑权限
  8885. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8886. //if (!isEdit) return Ok(JsonView(false, msg));
  8887. var subUpd = await _sqlSugar.Updateable(subInfo)
  8888. .UpdateColumns(x => new
  8889. {
  8890. x.Days,
  8891. x.NationalTravelFeeId,
  8892. x.Cost,
  8893. x.Currency,
  8894. x.SubTotal
  8895. })
  8896. .WhereColumns(x => new { x.Id })
  8897. .ExecuteCommandAsync();
  8898. if (subUpd < 1) return Ok(JsonView(false));
  8899. }
  8900. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8901. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8902. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8903. }
  8904. /// <summary>
  8905. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8906. /// </summary>
  8907. /// <returns></returns>
  8908. [HttpPost]
  8909. [ApiExplorerSettings(IgnoreApi = true)]
  8910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8911. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8912. {
  8913. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8914. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8915. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8916. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8917. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8918. {
  8919. Id = x.Id,
  8920. Diid = dto.DiId,
  8921. SetDataId = x.SetDataId,
  8922. Index = x.Index,
  8923. Cost = x.Cost,
  8924. Currency = x.Currency,
  8925. SubTotal = x.SubTotal,
  8926. CreateUserId = dto.CurrUserId,
  8927. Remark = x.Remark
  8928. }).ToList();
  8929. var adds = infos.Where(x => x.Id <= 0).ToList();
  8930. var upds = infos.Where(x => x.Id > 0).ToList();
  8931. if (adds.Count > 0)
  8932. {
  8933. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8934. if (add < 1) return Ok(JsonView(false));
  8935. }
  8936. if (upds.Count > 0)
  8937. {
  8938. var upd = await _sqlSugar.Updateable(adds)
  8939. .UpdateColumns(x => new
  8940. {
  8941. x.Index,
  8942. x.SetDataId,
  8943. x.Cost,
  8944. x.Currency,
  8945. x.SubTotal,
  8946. x.Remark
  8947. })
  8948. .WhereColumns(x => new { x.Id })
  8949. .ExecuteCommandAsync();
  8950. if (upd < 1) return Ok(JsonView(false));
  8951. }
  8952. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8953. //消息通知
  8954. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8955. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8956. return Ok(JsonView(new { itemTotal = itemTotal }));
  8957. }
  8958. /// <summary>
  8959. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8960. /// </summary>
  8961. /// <returns></returns>
  8962. [HttpPost]
  8963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8964. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8965. {
  8966. int subId = dto.SubId;
  8967. int diId = dto.Diid;
  8968. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8969. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8970. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8971. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8972. subInfo.Id = subId;
  8973. subInfo.Diid = dto.Diid;
  8974. subInfo.CreateUserId = dto.CurrUserId;
  8975. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8976. if (parentId < 1) return Ok(JsonView(false));
  8977. #region 子表op
  8978. if (subId < 1)//add
  8979. {
  8980. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8981. if (subAdd < 1) return Ok(JsonView(false));
  8982. }
  8983. else //upd
  8984. {
  8985. ////验证编辑权限
  8986. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8987. //if (!isEdit) return Ok(JsonView(false, msg));
  8988. var subUpd = await _sqlSugar.Updateable(subInfo)
  8989. .UpdateColumns(x => new
  8990. {
  8991. x.Index,
  8992. x.SetDataId,
  8993. x.Cost,
  8994. x.Currency,
  8995. x.SubTotal,
  8996. x.Remark
  8997. })
  8998. .WhereColumns(x => new { x.Id })
  8999. .ExecuteCommandAsync();
  9000. if (subUpd < 1) return Ok(JsonView(false));
  9001. }
  9002. #endregion
  9003. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9004. //消息通知
  9005. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9006. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9007. }
  9008. /// <summary>
  9009. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9010. /// </summary>
  9011. /// <returns></returns>
  9012. [HttpPost]
  9013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9014. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9015. {
  9016. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9017. if (data.Code != 0)
  9018. {
  9019. return Ok(JsonView(false, data.Msg));
  9020. }
  9021. return Ok(JsonView(true, "操作成功!", data.Data));
  9022. }
  9023. /// <summary>
  9024. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9025. /// </summary>
  9026. /// <param name="dto"></param>
  9027. /// <returns></returns>
  9028. [HttpPost]
  9029. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9030. {
  9031. var data = new Grp_DayOtherPrice()
  9032. {
  9033. Id = dto.Id,
  9034. IsDel = 1,
  9035. DeleteUserId = dto.DeleteUserId,
  9036. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9037. };
  9038. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9039. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9040. return Ok(JsonView(false, "删除失败!"));
  9041. }
  9042. #endregion
  9043. #endregion
  9044. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9045. /// <summary>
  9046. /// 出入境费用-草稿 移动端
  9047. /// 获取币种基础数据(含逻辑处理)
  9048. /// </summary>
  9049. /// <returns></returns>
  9050. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9051. {
  9052. //默认币种显示
  9053. var _currencyInfos = _currencyInit;
  9054. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9055. if (_currencyRate.Count > 0)
  9056. {
  9057. foreach (var item in _currencyInfos)
  9058. {
  9059. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9060. if (rateInfo != null)
  9061. {
  9062. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  9063. rate1 *= 1.035M;
  9064. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9065. }
  9066. }
  9067. }
  9068. return _currencyInfos;
  9069. }
  9070. /// <summary>
  9071. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9072. /// </summary>
  9073. /// <returns></returns>
  9074. [HttpPost]
  9075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9076. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9077. {
  9078. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9079. //SetDataInfoView
  9080. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9081. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9082. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9083. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9084. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9085. //默认币种显示
  9086. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9087. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9088. return Ok(JsonView(true, "查询成功!", new
  9089. {
  9090. WordTypeData = _WordTypeData,
  9091. ExcelTypeData = _ExcelTypeData,
  9092. CurrencyInit = _currencyInfos,
  9093. viewPermissionData = viewPermissionData
  9094. }));
  9095. }
  9096. /// <summary>
  9097. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9098. /// </summary>
  9099. /// <returns></returns>
  9100. [HttpPost]
  9101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9102. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9103. {
  9104. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9105. RefAsync<int> total = 0;
  9106. int diId = 0;
  9107. var status = int.TryParse(dto.GroupName, out diId);
  9108. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9109. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9110. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9111. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9112. .Select(x => new
  9113. {
  9114. Id = x.Id,
  9115. GroupName = x.TeamName
  9116. })
  9117. .OrderByDescending(x => x.Id)
  9118. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9119. return Ok(JsonView(true, "查询成功!", data, total));
  9120. }
  9121. /// <summary>
  9122. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9123. /// </summary>
  9124. /// <returns></returns>
  9125. [HttpPost]
  9126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9127. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9128. {
  9129. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9130. RefAsync<int> total = 0;
  9131. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9132. .Where(x => x.IsDel == 0 && x.STid == 66)
  9133. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9134. .Select(x => new
  9135. {
  9136. id = x.Id,
  9137. name = x.Name,
  9138. remark = x.Remark,
  9139. })
  9140. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9141. return Ok(JsonView(true, "查询成功!", data, total));
  9142. }
  9143. /// <summary>
  9144. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9145. /// </summary>
  9146. /// <returns></returns>
  9147. [HttpPost]
  9148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9149. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9150. {
  9151. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9152. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9153. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9154. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9155. var groupOtherRateData = groupRateData.TeamRates;
  9156. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9157. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9158. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9159. groupOtherRateData = groupOtherRateData
  9160. .Select(x => new TeamRateDescAddCurrencyIdView
  9161. {
  9162. CurrencyId = x.CurrencyId,
  9163. CurrencyName = x.CurrencyName,
  9164. CurrencyCode = x.CurrencyCode,
  9165. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9166. }).ToList();
  9167. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9168. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9169. }
  9170. /// <summary>
  9171. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9172. /// </summary>
  9173. /// <returns></returns>
  9174. [HttpPost]
  9175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9176. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9177. {
  9178. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9179. var tipsData = new List<int>() { 1, 2, 3 };
  9180. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9181. if (dto.TipsType == 1)
  9182. {
  9183. //默认币种显示
  9184. var _currencyInfos = _currencyInit;
  9185. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9186. List<dynamic> reteInfos = new List<dynamic>();
  9187. if (_currencyRate.Count > 0)
  9188. {
  9189. foreach (var item in _currencyInfos)
  9190. {
  9191. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9192. if (rateInfo != null)
  9193. {
  9194. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9195. decimal rate1 = item.Rate;
  9196. rate1 *= 1.03M;
  9197. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9198. reteInfos.Add(new
  9199. {
  9200. currCode = item.CurrencyCode,
  9201. currName = item.CurrencyName,
  9202. rate = rate2,
  9203. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9204. });
  9205. }
  9206. }
  9207. }
  9208. return Ok(JsonView(true, "查询成功!", reteInfos));
  9209. }
  9210. else if (dto.TipsType == 2)
  9211. {
  9212. }
  9213. else if (dto.TipsType == 3)
  9214. {
  9215. }
  9216. return Ok(JsonView(false));
  9217. }
  9218. /// <summary>
  9219. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9220. /// </summary>
  9221. /// <returns></returns>
  9222. [HttpPost]
  9223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9224. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9225. {
  9226. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9227. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9228. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9229. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9230. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9231. if (eecInfo == null) return Ok(mobileInfo);
  9232. //验证查看权限
  9233. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9234. if (!isView) return Ok(JsonView(false, msg));
  9235. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9236. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9237. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9238. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9239. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9240. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9241. {
  9242. ParentId = dac.ParentId,
  9243. SubId = dac.Id,
  9244. Type = dac.Type,
  9245. Days = dac.Days,
  9246. NationalTravelFeeId = dac.NationalTravelFeeId,
  9247. Arae = $"{ntf.Country}-{ntf.City}",
  9248. Cost = dac.Cost,
  9249. Currency = dac.Currency,
  9250. CurrencyName = sd.Name,
  9251. SubTotal = dac.SubTotal,
  9252. })
  9253. .ToList();
  9254. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9255. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9256. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9257. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9258. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9259. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9260. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9261. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9262. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9263. //其他款项
  9264. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9265. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9266. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9267. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9268. .OrderBy((dop, sd1, sd2) => dop.Index)
  9269. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9270. {
  9271. ParentId = dop.ParentId,
  9272. SubId = dop.Id,
  9273. Index = dop.Index,
  9274. SetDataId = dop.SetDataId,
  9275. SetDataName = sd1.Name,
  9276. Cost = dop.Cost,
  9277. Currency = dop.Currency,
  9278. CurrencyName = sd2.Remark,
  9279. SubTotal = dop.SubTotal,
  9280. Remark = dop.Remark,
  9281. })
  9282. .ToArray();
  9283. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9284. return Ok(mobileInfo);
  9285. }
  9286. /// <summary>
  9287. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9288. /// </summary>
  9289. /// <returns></returns>
  9290. [HttpPost]
  9291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9292. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9293. {
  9294. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9295. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9296. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9297. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9298. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9299. //验证查看权限
  9300. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9301. if (!isView) return Ok(JsonView(false, msg));
  9302. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9303. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9304. var subType = dto.SubType;
  9305. if (subType == 1) //1:境内费用
  9306. {
  9307. var oneData = new ChoiceOneMobileSubInfoView()
  9308. {
  9309. Id = eecInfo.Id,
  9310. ChoiceOne = eecInfo.ChoiceOne,
  9311. ChoiceOneTotalCost = eecInfo.InsidePay,
  9312. Visa = eecInfo.Visa,
  9313. VisaRemark = eecInfo.VisaRemark,
  9314. YiMiao = eecInfo.YiMiao,
  9315. HeSuan = eecInfo.HeSuan,
  9316. Service = eecInfo.Service,
  9317. Ticket = eecInfo.Ticket,
  9318. Safe = eecInfo.Safe,
  9319. FirstItemRemark = eecInfo.FirstItemRemark
  9320. };
  9321. return Ok(JsonView(oneData));
  9322. }
  9323. else if (subType == 2) //2:国际旅费
  9324. {
  9325. var twoData = new ChoiceTwoMobileSubInfoView()
  9326. {
  9327. Id = eecInfo.Id,
  9328. ChoiceTwoJJ = eecInfo.SumJJC,
  9329. OutsideJJPay = eecInfo.OutsideJJPay,
  9330. ChoiceTwoGW = eecInfo.SumGWC,
  9331. OutsideGWPay = eecInfo.OutsideGWPay,
  9332. ChoiceTwoTD = eecInfo.SumTDC,
  9333. OutsideTDPay = eecInfo.OutsideTDPay,
  9334. AirJJ = eecInfo.AirJJ,
  9335. AirGW = eecInfo.AirGW,
  9336. AirTD = eecInfo.AirTD,
  9337. CityTranffic = eecInfo.CityTranffic,
  9338. TwoItemRemark = eecInfo.TwoItemRemark
  9339. };
  9340. return Ok(JsonView(twoData));
  9341. }
  9342. else if (subType == 3) //3:住宿费
  9343. {
  9344. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9345. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9346. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9347. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9348. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9349. {
  9350. ParentId = dac.ParentId,
  9351. SubId = dac.Id,
  9352. Type = dac.Type,
  9353. Days = dac.Days,
  9354. NationalTravelFeeId = dac.NationalTravelFeeId,
  9355. Arae = $"{ntf.Country}-{ntf.City}",
  9356. Cost = dac.Cost,
  9357. Currency = dac.Currency,
  9358. CurrencyName = sd.Name,
  9359. SubTotal = dac.SubTotal,
  9360. })
  9361. .ToArray();
  9362. var data = new ChoiceDraftMobileSubInfo3To6View()
  9363. {
  9364. ParentId = eecInfo.Id,
  9365. Choice = eecInfo.ChoiceThree,
  9366. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9367. Details = dayAndCostDatas
  9368. };
  9369. return Ok(JsonView(data));
  9370. }
  9371. else if (subType == 4) //4:伙食费
  9372. {
  9373. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9374. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9375. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9376. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9377. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9378. {
  9379. ParentId = dac.ParentId,
  9380. SubId = dac.Id,
  9381. Type = dac.Type,
  9382. Days = dac.Days,
  9383. NationalTravelFeeId = dac.NationalTravelFeeId,
  9384. Arae = $"{ntf.Country}-{ntf.City}",
  9385. Cost = dac.Cost,
  9386. Currency = dac.Currency,
  9387. CurrencyName = sd.Name,
  9388. SubTotal = dac.SubTotal,
  9389. })
  9390. .ToArray();
  9391. var data = new ChoiceDraftMobileSubInfo3To6View()
  9392. {
  9393. ParentId = eecInfo.Id,
  9394. Choice = eecInfo.ChoiceFour,
  9395. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9396. Details = dayAndCostDatas
  9397. };
  9398. return Ok(JsonView(data));
  9399. }
  9400. else if (subType == 5) //5:公杂费
  9401. {
  9402. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9403. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9404. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9405. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9406. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9407. {
  9408. ParentId = dac.ParentId,
  9409. SubId = dac.Id,
  9410. Type = dac.Type,
  9411. Days = dac.Days,
  9412. NationalTravelFeeId = dac.NationalTravelFeeId,
  9413. Arae = $"{ntf.Country}-{ntf.City}",
  9414. Cost = dac.Cost,
  9415. Currency = dac.Currency,
  9416. CurrencyName = sd.Name,
  9417. SubTotal = dac.SubTotal,
  9418. })
  9419. .ToArray();
  9420. var data = new ChoiceDraftMobileSubInfo3To6View()
  9421. {
  9422. ParentId = eecInfo.Id,
  9423. Choice = eecInfo.ChoiceFive,
  9424. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9425. Details = dayAndCostDatas
  9426. };
  9427. return Ok(JsonView(data));
  9428. }
  9429. else if (subType == 6) //6:培训费
  9430. {
  9431. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9432. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9433. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9434. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9435. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9436. {
  9437. ParentId = dac.ParentId,
  9438. SubId = dac.Id,
  9439. Type = dac.Type,
  9440. Days = dac.Days,
  9441. NationalTravelFeeId = dac.NationalTravelFeeId,
  9442. Arae = $"{ntf.Country}-{ntf.City}",
  9443. Cost = dac.Cost,
  9444. Currency = dac.Currency,
  9445. CurrencyName = sd.Name,
  9446. SubTotal = dac.SubTotal,
  9447. })
  9448. .ToArray();
  9449. var data = new ChoiceDraftMobileSubInfo3To6View()
  9450. {
  9451. ParentId = eecInfo.Id,
  9452. Choice = eecInfo.ChoiceSix,
  9453. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9454. Details = dayAndCostDatas
  9455. };
  9456. return Ok(JsonView(data));
  9457. }
  9458. else if (subType == 7) //7:其他
  9459. {
  9460. //其他款项
  9461. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9462. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9463. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9464. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9465. .OrderBy((dop, sd1, sd2) => dop.Index)
  9466. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9467. {
  9468. ParentId = dop.ParentId,
  9469. SubId = dop.Id,
  9470. Index = dop.Index,
  9471. SetDataId = dop.SetDataId,
  9472. SetDataName = sd1.Name,
  9473. Cost = dop.Cost,
  9474. Currency = dop.Currency,
  9475. CurrencyName = sd2.Name,
  9476. SubTotal = dop.SubTotal,
  9477. Remark = dop.Remark,
  9478. })
  9479. .ToArray();
  9480. var data = new ChoiceSevenDraftMobileSubInfoView()
  9481. {
  9482. ParentId = eecInfo.Id,
  9483. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9484. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9485. Details = otherData
  9486. };
  9487. return Ok(JsonView(data));
  9488. }
  9489. return Ok(JsonView(false));
  9490. }
  9491. #region op
  9492. /// <summary>
  9493. /// 移动端更新费用消息通知
  9494. /// </summary>
  9495. /// <param name="draftId"></param>
  9496. /// <param name="id"></param>
  9497. /// <param name="currUserId"></param>
  9498. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9499. {
  9500. try
  9501. {
  9502. ////生成默认文件pdf并且通知人员
  9503. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9504. //{
  9505. // DiId = draftId,
  9506. // ExportType = 1,
  9507. // SubTypeId = 1005
  9508. //}, "pdf");
  9509. ////发送通知
  9510. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9511. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9512. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9513. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9514. ////汇率信息记录
  9515. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9516. }
  9517. catch (Exception ex)
  9518. {
  9519. //记录日志
  9520. throw;
  9521. }
  9522. }
  9523. /// <summary>
  9524. /// 验证出入境费用数据是否存在
  9525. /// 不存在添加
  9526. /// </summary>
  9527. /// <param name="draftId"></param>
  9528. /// <param name="currUserId"></param>
  9529. /// <returns></returns>
  9530. /// <exception cref="CustomException"></exception>
  9531. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9532. {
  9533. var parentId = 0;
  9534. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9535. if (info != null) parentId = info.Id;
  9536. else
  9537. {
  9538. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9539. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9540. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9541. parentId = addId;
  9542. }
  9543. return parentId;
  9544. }
  9545. /// <summary>
  9546. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9547. /// </summary>
  9548. /// <returns></returns>
  9549. [HttpPost]
  9550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9551. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9552. {
  9553. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9554. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9555. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9556. //验证编辑权限
  9557. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9558. if (!isEdit) return Ok(JsonView(false, msg));
  9559. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9560. foreach (var userId in dto.UserIds)
  9561. {
  9562. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9563. }
  9564. if (permissions.Any())
  9565. {
  9566. _sqlSugar.BeginTran();
  9567. try
  9568. {
  9569. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9570. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9571. if (result < 1)
  9572. {
  9573. _sqlSugar.RollbackTran();
  9574. return Ok(JsonView(false));
  9575. }
  9576. }
  9577. catch (Exception ex)
  9578. {
  9579. _sqlSugar.RollbackTran();
  9580. return Ok(JsonView(false, ex.Message));
  9581. }
  9582. _sqlSugar.CommitTran();
  9583. return Ok(JsonView(true));
  9584. }
  9585. return Ok(JsonView(false));
  9586. }
  9587. /// <summary>
  9588. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9589. /// </summary>
  9590. /// <returns></returns>
  9591. [HttpPost]
  9592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9593. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9594. {
  9595. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9596. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9597. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9598. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9599. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9600. int id = dto.DraftId;
  9601. if (id <= 0) //add
  9602. {
  9603. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9604. if (add < 1) return Ok(JsonView(false));
  9605. id = add;
  9606. }
  9607. else //update
  9608. {
  9609. //验证编辑权限
  9610. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9611. if (!isEdit) return Ok(JsonView(false, msg));
  9612. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9613. if (upd < 1) return Ok(JsonView(false));
  9614. }
  9615. #region 汇率变更时更改币种相关费用
  9616. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9617. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9618. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9619. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9620. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9621. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9622. .Select((dac, sd) => new
  9623. {
  9624. dac.Id,
  9625. dac.ParentId,
  9626. CurrencyCode = sd.Name,
  9627. dac.Cost
  9628. })
  9629. .ToList();
  9630. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9631. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9632. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9633. .Select((dop, sd) => new
  9634. {
  9635. dop.Id,
  9636. dop.ParentId,
  9637. CurrencyCode = sd.Name,
  9638. dop.Cost
  9639. })
  9640. .ToList();
  9641. if (dayCosts.Count > 0)
  9642. {
  9643. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9644. foreach (var dc in new_dayCosts)
  9645. {
  9646. var thisCurrency = dc.Key.ToUpper();
  9647. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9648. if (thisRate == 0.00M) continue;
  9649. foreach (var dcSub in dc)
  9650. {
  9651. opDayCosts.Add(new Grp_DayAndCostDraft()
  9652. {
  9653. Id = dcSub.Id,
  9654. ParentId = dcSub.ParentId,
  9655. Cost = dcSub.Cost,
  9656. SubTotal = dcSub.Cost * thisRate,
  9657. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9658. });
  9659. }
  9660. }
  9661. if (opDayCosts.Count > 0)
  9662. {
  9663. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9664. }
  9665. }
  9666. if (dayOtherCosts.Count > 0)
  9667. {
  9668. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9669. foreach (var dc in new_dayOtherCosts)
  9670. {
  9671. var thisCurrency = dc.Key.ToUpper();
  9672. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9673. if (thisRate == 0.00M) continue;
  9674. foreach (var dcSub in dc)
  9675. {
  9676. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9677. {
  9678. Id = dcSub.Id,
  9679. ParentId = dcSub.ParentId,
  9680. Cost = dcSub.Cost,
  9681. SubTotal = dcSub.Cost * thisRate,
  9682. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9683. });
  9684. }
  9685. }
  9686. if (opDayOtherCosts.Count > 0)
  9687. {
  9688. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9689. }
  9690. }
  9691. #endregion
  9692. ////消息通知
  9693. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9694. ////汇率信息记录
  9695. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9696. return Ok(JsonView(new { parentId = id }));
  9697. }
  9698. /// <summary>
  9699. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9700. /// </summary>
  9701. /// <returns></returns>
  9702. [HttpPost]
  9703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9704. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9705. {
  9706. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9707. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9708. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9709. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9710. int id = dto.DraftId;
  9711. if (id <= 0) //add
  9712. {
  9713. checkboxInfo.CreateUserId = dto.CurrUserId;
  9714. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9715. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9716. if (add < 1) return Ok(JsonView(false));
  9717. }
  9718. else //update
  9719. {
  9720. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9721. .UpdateColumns(x => new
  9722. {
  9723. x.ChoiceOne,
  9724. x.ChoiceTwo,
  9725. x.SumJJC,
  9726. x.SumGWC,
  9727. x.SumTDC,
  9728. x.ChoiceThree,
  9729. x.ChoiceFour,
  9730. x.ChoiceFive,
  9731. x.ChoiceSix,
  9732. x.OtherExpenses_Checked
  9733. })
  9734. .Where(x => x.Id == id)
  9735. .ExecuteCommandAsync();
  9736. if (upd < 1) return Ok(JsonView(false));
  9737. }
  9738. return Ok(JsonView(new { parentId = id }));
  9739. }
  9740. /// <summary>
  9741. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9742. /// </summary>
  9743. /// <returns></returns>
  9744. [HttpPost]
  9745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9746. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9747. {
  9748. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9749. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9750. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9751. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9752. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9753. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9754. var checkboxInfo = new Grp_EnterExitCostDraft()
  9755. {
  9756. Id = draftId,
  9757. CreateUserId = currUserId
  9758. };
  9759. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9760. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9761. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9762. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9763. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9764. if (draftId <= 0) //add
  9765. {
  9766. checkboxInfo.CreateUserId = dto.CurrUserId;
  9767. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9768. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9769. if (add < 1) return Ok(JsonView(false));
  9770. }
  9771. else //update
  9772. {
  9773. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9774. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9775. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9776. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9777. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9778. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9779. .Where(x => x.Id == draftId)
  9780. .ExecuteCommandAsync();
  9781. if (upd < 1) return Ok(JsonView(false));
  9782. }
  9783. return Ok(JsonView(new { parentId = draftId }));
  9784. }
  9785. /// <summary>
  9786. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9787. /// </summary>
  9788. /// <returns></returns>
  9789. [HttpPost]
  9790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9791. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9792. {
  9793. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9794. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9795. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9796. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9797. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9798. info.FirstItemRemark = dto.FirstItemRemark;
  9799. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9800. if (id <= 0) //add
  9801. {
  9802. info.CreateUserId = dto.CurrUserId;
  9803. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9804. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9805. if (add < 1) return Ok(JsonView(false));
  9806. id = add;
  9807. }
  9808. else //update
  9809. {
  9810. var upd = await _sqlSugar.Updateable(info)
  9811. .UpdateColumns(x => new
  9812. {
  9813. x.ChoiceOne,
  9814. x.InsidePay,
  9815. x.VisaRemark,
  9816. x.Visa,
  9817. x.Service,
  9818. x.Safe,
  9819. x.Ticket,
  9820. x.HeSuan,
  9821. x.YiMiao,
  9822. x.FirstItemRemark
  9823. })
  9824. .Where(x => x.Id == id)
  9825. .ExecuteCommandAsync();
  9826. if (upd < 1) return Ok(JsonView(false));
  9827. }
  9828. ////消息通知
  9829. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9830. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9831. }
  9832. /// <summary>
  9833. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9834. /// </summary>
  9835. /// <returns></returns>
  9836. [HttpPost]
  9837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9838. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9839. {
  9840. int id = dto.DraftId;
  9841. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9842. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9843. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9844. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9845. info.OutsideJJPay = dto.OutsideJJPay;
  9846. info.OutsideGWPay = dto.OutsideGWPay;
  9847. info.OutsideTDPay = dto.OutsideTDPay;
  9848. info.AirJJ = dto.AirJJ;
  9849. info.AirGW = dto.AirGW;
  9850. info.AirTD = dto.AirTD;
  9851. info.CityTranffic = dto.CityTranffic;
  9852. info.TwoItemRemark = dto.TwoItemRemark;
  9853. info.SumJJC = dto.ChoiceTwoJJ;
  9854. info.SumGWC = dto.ChoiceTwoGW;
  9855. info.SumTDC = dto.ChoiceTwoTD;
  9856. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9857. if (id <= 0) //add
  9858. {
  9859. info.CreateUserId = dto.CurrUserId;
  9860. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9861. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9862. if (addId <= 0) return Ok(JsonView(false));
  9863. id = addId;
  9864. }
  9865. else //update
  9866. {
  9867. var upd = await _sqlSugar.Updateable(info)
  9868. .UpdateColumns(x => new
  9869. {
  9870. x.SumJJC,
  9871. x.OutsideJJPay,
  9872. x.SumGWC,
  9873. x.OutsideGWPay,
  9874. x.SumTDC,
  9875. x.OutsideTDPay,
  9876. x.AirJJ,
  9877. x.AirGW,
  9878. x.AirTD,
  9879. x.CityTranffic,
  9880. x.TwoItemRemark
  9881. })
  9882. .Where(x => x.Id == id)
  9883. .ExecuteCommandAsync();
  9884. if (upd < 1) return Ok(JsonView(false));
  9885. }
  9886. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9887. gwcItemTotal = info.AirGW + info.CityTranffic;
  9888. tdcItemTotal = info.AirTD + info.CityTranffic;
  9889. ////消息通知
  9890. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9891. return Ok(JsonView(new
  9892. {
  9893. parentId = id,
  9894. choiceTwoJJ = dto.ChoiceTwoJJ,
  9895. jjcItemTotal = jjcItemTotal,
  9896. choiceTwoGW = dto.ChoiceTwoGW,
  9897. gwcItemTotal = gwcItemTotal,
  9898. choiceTwoTD = dto.ChoiceTwoTD,
  9899. tdcItemTotal = tdcItemTotal
  9900. }));
  9901. }
  9902. /// <summary>
  9903. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9904. /// </summary>
  9905. /// <returns></returns>
  9906. [HttpPost]
  9907. [ApiExplorerSettings(IgnoreApi = true)]
  9908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9909. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9910. {
  9911. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9912. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9913. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9914. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9915. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9916. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9917. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9918. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9919. {
  9920. Id = x.Id,
  9921. ParentId = dto.DraftId,
  9922. Type = dto.FeeType,
  9923. Days = x.Days,
  9924. NationalTravelFeeId = x.NationalTravelFeeId,
  9925. Cost = x.Cost,
  9926. Currency = x.Currency,
  9927. SubTotal = x.SubTotal,
  9928. CreateUserId = dto.CurrUserId
  9929. })
  9930. .ToList();
  9931. var adds = infos.Where(x => x.Id <= 0).ToList();
  9932. var upds = infos.Where(x => x.Id > 0).ToList();
  9933. if (adds.Count > 0)
  9934. {
  9935. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9936. if (add < 1) return Ok(JsonView(false));
  9937. }
  9938. if (upds.Count > 0)
  9939. {
  9940. var upd = await _sqlSugar.Updateable(adds)
  9941. .UpdateColumns(x => new
  9942. {
  9943. x.Days,
  9944. x.NationalTravelFeeId,
  9945. x.Cost,
  9946. x.Currency,
  9947. x.SubTotal
  9948. })
  9949. .WhereColumns(x => new { x.Id })
  9950. .ExecuteCommandAsync();
  9951. if (upd < 1) return Ok(JsonView(false));
  9952. }
  9953. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9954. ////消息通知
  9955. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9956. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9957. return Ok(JsonView(new { itemTotal = itemTotal }));
  9958. }
  9959. /// <summary>
  9960. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9961. /// </summary>
  9962. /// <returns></returns>
  9963. [HttpPost]
  9964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9965. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9966. {
  9967. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9968. int subId = dto.SubId, feeType = dto.FeeType;
  9969. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9970. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9971. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9972. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9973. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9974. subInfo.Id = subId;
  9975. subInfo.ParentId = dto.DraftId;
  9976. if (feeType == 3) subInfo.Type = 1;
  9977. else if (feeType == 4) subInfo.Type = 2;
  9978. else if (feeType == 5) subInfo.Type = 3;
  9979. else if (feeType == 6) subInfo.Type = 4;
  9980. subInfo.CreateUserId = dto.CurrUserId;
  9981. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9982. if (parentId < 1) return Ok(JsonView(false));
  9983. //子表op
  9984. if (subId < 1)
  9985. {
  9986. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9987. if (subAdd < 1) return Ok(JsonView(false));
  9988. }
  9989. else
  9990. {
  9991. var subUpd = await _sqlSugar.Updateable(subInfo)
  9992. .UpdateColumns(x => new
  9993. {
  9994. x.Days,
  9995. x.NationalTravelFeeId,
  9996. x.Cost,
  9997. x.Currency,
  9998. x.SubTotal
  9999. })
  10000. .WhereColumns(x => new { x.Id })
  10001. .ExecuteCommandAsync();
  10002. if (subUpd < 1) return Ok(JsonView(false));
  10003. }
  10004. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10005. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10006. }
  10007. /// <summary>
  10008. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10009. /// </summary>
  10010. /// <returns></returns>
  10011. [HttpPost]
  10012. [ApiExplorerSettings(IgnoreApi = true)]
  10013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10014. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10015. {
  10016. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10017. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10018. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10019. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10020. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10021. {
  10022. Id = x.Id,
  10023. ParentId = dto.DraftId,
  10024. SetDataId = x.SetDataId,
  10025. Index = x.Index,
  10026. Cost = x.Cost,
  10027. Currency = x.Currency,
  10028. SubTotal = x.SubTotal,
  10029. CreateUserId = dto.CurrUserId,
  10030. Remark = x.Remark
  10031. }).ToList();
  10032. var adds = infos.Where(x => x.Id <= 0).ToList();
  10033. var upds = infos.Where(x => x.Id > 0).ToList();
  10034. if (adds.Count > 0)
  10035. {
  10036. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10037. if (add < 1) return Ok(JsonView(false));
  10038. }
  10039. if (upds.Count > 0)
  10040. {
  10041. var upd = await _sqlSugar.Updateable(adds)
  10042. .UpdateColumns(x => new
  10043. {
  10044. x.Index,
  10045. x.SetDataId,
  10046. x.Cost,
  10047. x.Currency,
  10048. x.SubTotal,
  10049. x.Remark
  10050. })
  10051. .WhereColumns(x => new { x.Id })
  10052. .ExecuteCommandAsync();
  10053. if (upd < 1) return Ok(JsonView(false));
  10054. }
  10055. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10056. //消息通知
  10057. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10058. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10059. return Ok(JsonView(new { itemTotal = itemTotal }));
  10060. }
  10061. /// <summary>
  10062. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10063. /// </summary>
  10064. /// <returns></returns>
  10065. [HttpPost]
  10066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10067. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10068. {
  10069. int subId = dto.SubId, id = dto.DarftId;
  10070. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10071. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10072. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10073. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10074. subInfo.Id = subId;
  10075. subInfo.ParentId = dto.DarftId;
  10076. subInfo.CreateUserId = dto.CurrUserId;
  10077. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10078. if (parentId < 1) return Ok(JsonView(false));
  10079. #region 子表op
  10080. if (subId < 1)//add
  10081. {
  10082. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10083. if (subAdd < 1) return Ok(JsonView(false));
  10084. }
  10085. else //upd
  10086. {
  10087. var subUpd = await _sqlSugar.Updateable(subInfo)
  10088. .UpdateColumns(x => new
  10089. {
  10090. x.Index,
  10091. x.SetDataId,
  10092. x.Cost,
  10093. x.Currency,
  10094. x.SubTotal,
  10095. x.Remark
  10096. })
  10097. .WhereColumns(x => new { x.Id })
  10098. .ExecuteCommandAsync();
  10099. if (subUpd < 1) return Ok(JsonView(false));
  10100. }
  10101. #endregion
  10102. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10103. ////消息通知
  10104. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10105. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10106. }
  10107. /// <summary>
  10108. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10109. /// </summary>
  10110. /// <returns></returns>
  10111. [HttpPost]
  10112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10113. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10114. {
  10115. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10116. if (data.Code != 0)
  10117. {
  10118. return Ok(JsonView(false, data.Msg));
  10119. }
  10120. return Ok(JsonView(true, "操作成功!", data.Data));
  10121. }
  10122. /// <summary>
  10123. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10124. /// </summary>
  10125. /// <param name="dto"></param>
  10126. /// <returns></returns>
  10127. [HttpPost]
  10128. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10129. {
  10130. var data = new Grp_DayOtherPriceDraft()
  10131. {
  10132. Id = dto.Id,
  10133. IsDel = 1,
  10134. DeleteUserId = dto.DeleteUserId,
  10135. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10136. };
  10137. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10138. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10139. return Ok(JsonView(false, "删除失败!"));
  10140. }
  10141. #endregion
  10142. #endregion
  10143. #region 签证费用录入
  10144. /// <summary>
  10145. /// 根据diid查询签证费用列表
  10146. /// </summary>
  10147. /// <param name="dto"></param>
  10148. /// <returns></returns>
  10149. [HttpPost]
  10150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10151. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10152. {
  10153. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10154. if (groupData.Code != 0)
  10155. {
  10156. return Ok(JsonView(false, groupData.Msg));
  10157. }
  10158. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10159. }
  10160. /// <summary>
  10161. /// 根据签证费用Id查询单条数据及c表数据
  10162. /// </summary>
  10163. /// <param name="dto"></param>
  10164. /// <returns></returns>
  10165. [HttpPost]
  10166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10167. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10168. {
  10169. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10170. if (groupData.Code != 0)
  10171. {
  10172. return Ok(JsonView(false, groupData.Msg));
  10173. }
  10174. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10175. }
  10176. /// <summary>
  10177. /// 签证费用删除
  10178. /// </summary>
  10179. /// <param name="dto"></param>
  10180. /// <returns></returns>
  10181. [HttpPost]
  10182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10183. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10184. {
  10185. _sqlSugar.BeginTran();
  10186. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10187. if (!res)
  10188. {
  10189. _sqlSugar.RollbackTran();
  10190. return Ok(JsonView(false, "删除失败"));
  10191. }
  10192. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10193. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10194. .SetColumns(a => new Grp_CreditCardPayment()
  10195. {
  10196. IsDel = 1,
  10197. DeleteUserId = dto.DeleteUserId,
  10198. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10199. })
  10200. .ExecuteCommand();
  10201. if (resSub < 1)
  10202. {
  10203. _sqlSugar.RollbackTran();
  10204. return Ok(JsonView(false, "删除失败"));
  10205. }
  10206. _sqlSugar.CommitTran();
  10207. return Ok(JsonView(true, "删除成功!"));
  10208. }
  10209. /// <summary>
  10210. /// 签证费用录入下拉框初始化
  10211. /// </summary>
  10212. /// <returns></returns>
  10213. [HttpPost]
  10214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10215. public async Task<IActionResult> VisaPriceAddSelect()
  10216. {
  10217. //支付方式
  10218. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10219. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10220. //币种
  10221. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10222. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10223. //乘客类型
  10224. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10225. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10226. //卡类型
  10227. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10228. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10229. //代办费类型
  10230. var agencyFeeTypeData = new List<dynamic>() {
  10231. new { id = 0 , Text = "未选择" },
  10232. new { id = 1 , Text = "小公务" },
  10233. new { id = 2 , Text = "大公务" },
  10234. };
  10235. //签证费用标准国家Data
  10236. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10237. var data = new
  10238. {
  10239. Payment = _Payment,
  10240. CurrencyList = _CurrencyList,
  10241. PassengerType = _PassengerType,
  10242. BankCard = _BankCard,
  10243. AgencyFeeType = agencyFeeTypeData,
  10244. CountryFeeData = visaCountryFeeData
  10245. };
  10246. return Ok(JsonView(true, "查询成功!", data));
  10247. }
  10248. /// <summary>
  10249. /// 签证费用录入操作(Status:1.新增,2.修改)
  10250. /// </summary>
  10251. /// <param name="dto"></param>
  10252. /// <returns></returns>
  10253. [HttpPost]
  10254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10255. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10256. {
  10257. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10258. if (groupData.Code != 0)
  10259. {
  10260. return Ok(JsonView(false, groupData.Msg));
  10261. }
  10262. #region 应用推送
  10263. try
  10264. {
  10265. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10266. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10267. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10268. //2024-10-21 新增LZ UID
  10269. var userIds = new List<int>() { 21 };
  10270. string title = $"系统通知";
  10271. string content = "";
  10272. var diId = dto.DiId;
  10273. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10274. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10275. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10276. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10277. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10278. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10279. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10280. }
  10281. catch (Exception ex)
  10282. {
  10283. }
  10284. #endregion
  10285. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10286. }
  10287. #endregion
  10288. #region 签证提成录入
  10289. /// <summary>
  10290. /// 签证提成录入
  10291. /// 基础数据
  10292. /// </summary>
  10293. /// <returns></returns>
  10294. [HttpGet]
  10295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10296. public async Task<IActionResult> VisaCommissionInit()
  10297. {
  10298. return Ok(await _visaCommissionRep.Init());
  10299. }
  10300. /// <summary>
  10301. /// 签证提成录入
  10302. /// Item
  10303. /// </summary>
  10304. /// <param name="_dto"></param>
  10305. /// <returns></returns>
  10306. [HttpPost]
  10307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10308. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10309. {
  10310. var validator = new VisaCommissionItemDtoValidator();
  10311. var validatorRes = await validator.ValidateAsync(_dto);
  10312. if (!validatorRes.IsValid)
  10313. {
  10314. StringBuilder sb = new StringBuilder();
  10315. foreach (var item in validatorRes.Errors)
  10316. {
  10317. sb.AppendLine(item.ErrorMessage);
  10318. }
  10319. return Ok(JsonView(false, sb.ToString()));
  10320. }
  10321. return Ok(await _visaCommissionRep.Item(_dto));
  10322. }
  10323. /// <summary>
  10324. /// 签证提成录入
  10325. /// Save
  10326. /// </summary>
  10327. /// <param name="_dto"></param>
  10328. /// <returns></returns>
  10329. [HttpPost]
  10330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10331. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10332. {
  10333. //参数验证
  10334. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10335. foreach (var item in _dto.Items)
  10336. {
  10337. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10338. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10339. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10340. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10341. }
  10342. return Ok(await _visaCommissionRep.Save(_dto));
  10343. }
  10344. /// <summary>
  10345. /// 签证提成录入
  10346. /// Create
  10347. /// </summary>
  10348. /// <param name="_dto"></param>
  10349. /// <returns></returns>
  10350. [HttpPost]
  10351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10352. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10353. {
  10354. var validator = new VisaCommissionCreateDtoValidator();
  10355. var validatorRes = await validator.ValidateAsync(_dto);
  10356. if (!validatorRes.IsValid)
  10357. {
  10358. StringBuilder sb = new StringBuilder();
  10359. foreach (var item in validatorRes.Errors)
  10360. {
  10361. sb.AppendLine(item.ErrorMessage);
  10362. }
  10363. return Ok(JsonView(false, sb.ToString()));
  10364. }
  10365. return Ok(await _visaCommissionRep.Create(_dto));
  10366. }
  10367. /// <summary>
  10368. /// 签证提成录入
  10369. /// Put(编辑)
  10370. /// </summary>
  10371. /// <param name="id"></param>
  10372. /// <param name="_dto"></param>
  10373. /// <returns></returns>
  10374. [HttpPut]
  10375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10376. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10377. {
  10378. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10379. var validator = new VisaCommissionCreateDtoValidator();
  10380. var validatorRes = await validator.ValidateAsync(_dto);
  10381. if (!validatorRes.IsValid)
  10382. {
  10383. StringBuilder sb = new StringBuilder();
  10384. foreach (var item in validatorRes.Errors)
  10385. {
  10386. sb.AppendLine(item.ErrorMessage);
  10387. }
  10388. return Ok(JsonView(false, sb.ToString()));
  10389. }
  10390. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10391. }
  10392. /// <summary>
  10393. /// 签证提成录入
  10394. /// Del
  10395. /// </summary>
  10396. /// <param name="id"></param>
  10397. /// <param name="currUserId"></param>
  10398. /// <returns></returns>
  10399. [HttpPost]
  10400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10401. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10402. {
  10403. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10404. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10405. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10406. }
  10407. #endregion
  10408. #region op费用录入
  10409. /// <summary>
  10410. /// 根据diid查询op费用列表
  10411. /// </summary>
  10412. /// <param name="dto"></param>
  10413. /// <returns></returns>
  10414. [HttpPost]
  10415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10416. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10417. {
  10418. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10419. if (groupData.Code != 0)
  10420. {
  10421. return Ok(JsonView(false, groupData.Msg));
  10422. }
  10423. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10424. }
  10425. /// <summary>
  10426. /// 根据op费用Id查询单条数据及c表数据
  10427. /// </summary>
  10428. /// <param name="dto"></param>
  10429. /// <returns></returns>
  10430. [HttpPost]
  10431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10432. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10433. {
  10434. try
  10435. {
  10436. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10437. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10438. var data = new
  10439. {
  10440. CarTouristGuideGround = _groupData,
  10441. CreditCardPayment = _creditCardPayment
  10442. };
  10443. return Ok(JsonView(true, "查询成功!", data));
  10444. }
  10445. catch (Exception ex)
  10446. {
  10447. return Ok(JsonView(false, "程序错误!"));
  10448. }
  10449. }
  10450. /// <summary>
  10451. /// op费用删除
  10452. /// </summary>
  10453. /// <param name="dto"></param>
  10454. /// <returns></returns>
  10455. [HttpPost]
  10456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10457. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10458. {
  10459. try
  10460. {
  10461. _sqlSugar.BeginTran();
  10462. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10463. if (!res)
  10464. {
  10465. return Ok(JsonView(false, "删除失败"));
  10466. }
  10467. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10468. {
  10469. IsDel = 1,
  10470. DeleteUserId = dto.DeleteUserId,
  10471. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10472. }).ExecuteCommandAsync();
  10473. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10474. {
  10475. IsDel = 1,
  10476. DeleteUserId = dto.DeleteUserId,
  10477. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10478. }).ExecuteCommandAsync();
  10479. #region 删除超支相关数据
  10480. //删除导入的超支数据
  10481. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10482. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10483. {
  10484. IsDel = 1,
  10485. DeleteUserId = dto.DeleteUserId,
  10486. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10487. }).ExecuteCommand();
  10488. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10489. {
  10490. IsDel = 1,
  10491. DeleteUserId = dto.DeleteUserId,
  10492. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10493. }).ExecuteCommand();
  10494. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10495. {
  10496. IsDel = 1,
  10497. DeleteUserId = dto.DeleteUserId,
  10498. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10499. }).ExecuteCommand();
  10500. #endregion
  10501. _sqlSugar.CommitTran();
  10502. return Ok(JsonView(true, "删除成功!"));
  10503. }
  10504. catch (Exception ex)
  10505. {
  10506. _sqlSugar.RollbackTran();
  10507. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10508. }
  10509. }
  10510. /// <summary>
  10511. /// op费用录入操作(Status:1.新增,2.修改)
  10512. /// </summary>
  10513. /// <param name="dto"></param>
  10514. /// <returns></returns>
  10515. [HttpPost]
  10516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10517. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10518. {
  10519. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10520. if (groupData.Code != 0)
  10521. {
  10522. return Ok(JsonView(false, groupData.Msg));
  10523. }
  10524. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10525. }
  10526. /// <summary>
  10527. /// 填写费用详细页面初始化绑定
  10528. /// </summary>
  10529. /// <param name="dto"></param>
  10530. /// <returns></returns>
  10531. [HttpPost]
  10532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10533. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10534. {
  10535. try
  10536. {
  10537. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10538. if (groupData.Code != 0)
  10539. {
  10540. return Ok(JsonView(false, groupData.Msg));
  10541. }
  10542. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10543. }
  10544. catch (Exception ex)
  10545. {
  10546. return Ok(JsonView(false, ex.Message));
  10547. }
  10548. }
  10549. /// <summary>
  10550. /// 根据op费用Id查询详细数据
  10551. /// </summary>
  10552. /// <param name="dto"></param>
  10553. /// <returns></returns>
  10554. [HttpPost]
  10555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10556. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10557. {
  10558. try
  10559. {
  10560. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10561. if (groupData.Code != 0)
  10562. {
  10563. return Ok(JsonView(false, groupData.Msg));
  10564. }
  10565. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10566. }
  10567. catch (Exception ex)
  10568. {
  10569. return Ok(JsonView(false, ex.Message));
  10570. }
  10571. }
  10572. /// <summary>
  10573. /// OP费用录入填写详情
  10574. /// </summary>
  10575. /// <param name="dto"></param>
  10576. /// <returns></returns>
  10577. [HttpPost]
  10578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10579. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10580. {
  10581. try
  10582. {
  10583. #region 参数校验
  10584. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10585. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10586. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10587. #endregion
  10588. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10589. if (groupData.Code != 0)
  10590. {
  10591. return Ok(JsonView(false, groupData.Msg));
  10592. }
  10593. //自动审核
  10594. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10595. #region 应用推送
  10596. try
  10597. {
  10598. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10599. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10600. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10601. //2024-10-21 新增LZ UID
  10602. var userIds = new List<int>() { 21 };
  10603. string title = $"系统通知";
  10604. var diId = dto.DiId;
  10605. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10606. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10607. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  10608. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10609. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10610. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10611. }
  10612. catch (Exception ex)
  10613. {
  10614. }
  10615. #endregion
  10616. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10617. }
  10618. catch (Exception ex)
  10619. {
  10620. return Ok(JsonView(false, ex.Message));
  10621. }
  10622. }
  10623. /// <summary>
  10624. /// 获取三公详细所有城市
  10625. /// </summary>
  10626. /// <returns></returns>
  10627. [HttpGet]
  10628. public IActionResult OpCarCityResult()
  10629. {
  10630. var jw = JsonView(false);
  10631. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10632. {
  10633. x.Id,
  10634. x.Country,
  10635. x.City,
  10636. }).ToList();
  10637. if (data.Count > 0)
  10638. {
  10639. jw = JsonView(true, "获取成功!", data);
  10640. }
  10641. else
  10642. {
  10643. jw.Msg = "城市数据为空!";
  10644. jw.Data = new string[0];
  10645. }
  10646. return Ok(jw);
  10647. }
  10648. /// <summary>
  10649. /// 导出地接费用明细
  10650. /// </summary>
  10651. /// <param name="dto"></param>
  10652. /// <returns></returns>
  10653. [HttpPost]
  10654. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10655. {
  10656. var jw = JsonView(false);
  10657. if (dto.Diid < 1)
  10658. {
  10659. jw.Msg = "请输入正确的diid!";
  10660. return Ok(jw);
  10661. }
  10662. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10663. if (group == null)
  10664. {
  10665. jw.Msg = "未找到团组信息!";
  10666. return Ok(jw);
  10667. }
  10668. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10669. if (localGuideArr.Count == 0)
  10670. {
  10671. jw.Msg = "该团组暂无地接信息!";
  10672. return Ok(jw);
  10673. }
  10674. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10675. var overspendSoure = new Dictionary<int, int>
  10676. {
  10677. { 91, 982 }, //车
  10678. { 92 , 1059} ,//导游
  10679. { 994 , 1073}, //翻译
  10680. { 988 , 1074 }, //早餐
  10681. { 93 , 1075 }, //午餐
  10682. { 989 , 1076 }, //晚餐
  10683. };
  10684. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10685. foreach (var groupArr in localGroup)
  10686. {
  10687. var keyValue = groupArr.Key;
  10688. if (int.TryParse(keyValue, out int cityid))
  10689. {
  10690. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10691. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10692. }
  10693. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10694. foreach (var item in groupArr)
  10695. {
  10696. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10697. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10698. new Grp_CarTouristGuideGroundReservationsContentExtend
  10699. {
  10700. Count = a.Count,
  10701. CreateTime = a.CreateTime,
  10702. CreateUserId = a.CreateUserId,
  10703. CTGGRId = a.CTGGRId,
  10704. Currency = a.Currency,
  10705. DatePrice = a.DatePrice,
  10706. DeleteTime = a.DeleteTime,
  10707. DeleteUserId = a.DeleteUserId,
  10708. DiId = a.DiId,
  10709. Id = a.Id,
  10710. IsDel = a.IsDel,
  10711. Price = a.Price,
  10712. PriceContent = a.PriceContent,
  10713. Remark = a.Remark,
  10714. SId = a.SId,
  10715. SidName = b.Name,
  10716. Units = a.Units,
  10717. }
  10718. ).ToList();
  10719. if (content.Count > 0)
  10720. {
  10721. contentArr.Add(content);
  10722. }
  10723. }
  10724. //open excel
  10725. //set excel
  10726. //save excel
  10727. try
  10728. {
  10729. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10730. IWorkbook workbook;
  10731. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10732. {
  10733. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10734. }
  10735. else
  10736. {
  10737. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10738. }
  10739. ISheet sheet = workbook.GetSheetAt(0);
  10740. var rowStartIndex = 2;
  10741. var clounmCount = 10;
  10742. var initStyleRow = sheet.GetRow(2);
  10743. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10744. //var overspendArrDetail =
  10745. var existsId = new List<CarCompare>();
  10746. var lastElem = arr.Last();
  10747. var thisSid = -1;
  10748. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10749. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10750. {
  10751. Name = "未知币种!",
  10752. Remark = "未知币种!",
  10753. };
  10754. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10755. Action cloneRowFn = () =>
  10756. {
  10757. rowStartIndex++;
  10758. var cloneRow = sheet.CreateRow(rowStartIndex);
  10759. // 复制样式
  10760. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10761. {
  10762. ICell sourceCell = initStyleRow.GetCell(i);
  10763. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10764. // 确保单元格存在样式
  10765. if (sourceCell.CellStyle != null)
  10766. {
  10767. targetCell.CellStyle = sourceCell.CellStyle;
  10768. }
  10769. }
  10770. };
  10771. var mergeRow = () =>
  10772. {
  10773. for (int i = 2; i < sheet.LastRowNum; i++)
  10774. {
  10775. var row = sheet.GetRow(i);
  10776. var cellFirst = row.GetCell(0);
  10777. var thisIndex = i + 1;
  10778. while (thisIndex < sheet.LastRowNum)
  10779. {
  10780. var nextRow = sheet.GetRow(thisIndex);
  10781. var nextCellFirst = nextRow.GetCell(0);
  10782. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10783. {
  10784. thisIndex++;
  10785. }
  10786. else
  10787. {
  10788. break;
  10789. }
  10790. }
  10791. thisIndex--;
  10792. if (thisIndex != i)
  10793. {
  10794. //合并row
  10795. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10796. i, // 起始行索引(0-based)
  10797. thisIndex, // 结束行索引(0-based)
  10798. 0, // 起始列索引(0-based)
  10799. 0 // 结束列索引(0-based)
  10800. );
  10801. sheet.AddMergedRegion(cellRangeAddress);
  10802. i = thisIndex;
  10803. }
  10804. }
  10805. };
  10806. var chaoshiNumber = 0;
  10807. var totalNumber = 0.00M;
  10808. string lastStr = "";
  10809. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10810. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10811. {
  10812. b.IsAuditGM,
  10813. x.Id,
  10814. x.Area,
  10815. b.PayPercentage,
  10816. b.PayMoney,
  10817. }).ToList();
  10818. string yesPayment = "", noPayment = "";
  10819. foreach (var item in queryCarArrByCityAndDiid)
  10820. {
  10821. if (item.IsAuditGM == 1)
  10822. {
  10823. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10824. }
  10825. else
  10826. {
  10827. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10828. }
  10829. }
  10830. lastStr = yesPayment + noPayment;
  10831. foreach (var item in arr)
  10832. {
  10833. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10834. {
  10835. if (thisSid != item.SId)
  10836. {
  10837. if (thisSid == -1)
  10838. {
  10839. thisSid = item.SId;
  10840. }
  10841. else
  10842. {
  10843. //合并小计行
  10844. //创建合并区域的实例
  10845. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10846. rowStartIndex, // 起始行索引(0-based)
  10847. rowStartIndex, // 结束行索引(0-based)
  10848. 0, // 起始列索引(0-based)
  10849. 3 // 结束列索引(0-based)
  10850. );
  10851. sheet.AddMergedRegion(cellRangeAddress);
  10852. var CellStyle = workbook.CreateCellStyle();
  10853. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10854. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10855. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10856. for (int i = 0; i <= clounmCount; i++)
  10857. {
  10858. if (i > 6)
  10859. {
  10860. var CellStyle1 = workbook.CreateCellStyle();
  10861. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10862. IFont Font = workbook.CreateFont(); // 创建字体
  10863. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10864. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10865. CellStyle1.SetFont(Font);
  10866. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10867. }
  10868. else
  10869. {
  10870. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10871. }
  10872. }
  10873. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10874. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10875. //超时合计
  10876. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10877. //超时数
  10878. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10879. //超时合计费用
  10880. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10881. thisSid = item.SId;
  10882. cloneRowFn();
  10883. chaoshiNumber = 0;
  10884. totalNumber = 0;
  10885. }
  10886. }
  10887. IRow row = sheet.GetRow(rowStartIndex);
  10888. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10889. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10890. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10891. if (isOpenOverspendSoure)
  10892. {
  10893. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10894. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10895. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10896. }
  10897. for (int i = 0; i <= clounmCount; i++)
  10898. {
  10899. var cell = row.GetCell(i);
  10900. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10901. if (cell == null)
  10902. {
  10903. cell = row.CreateCell(i);
  10904. }
  10905. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10906. fontRed.CloneStyleFrom(cell.CellStyle);
  10907. IFont Font = workbook.CreateFont(); // 创建字体
  10908. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10909. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10910. fontRed.SetFont(Font);
  10911. byte[] rgb = new byte[3] { 255, 242, 204 };
  10912. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10913. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10914. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10915. if (workbook is XSSFWorkbook)
  10916. {
  10917. BackgroundColor255_242_204.FillForegroundColor = 0;
  10918. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10919. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10920. }
  10921. else
  10922. {
  10923. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10924. }
  10925. if (i == 1 || i > 6)
  10926. {
  10927. if (i > 6)
  10928. {
  10929. fontRed.FillForegroundColor = 0;
  10930. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10931. fontRed.FillPattern = FillPattern.SolidForeground;
  10932. }
  10933. cell.CellStyle = fontRed;
  10934. }
  10935. if (i > 2 && i < 7)
  10936. {
  10937. cell.CellStyle = BackgroundColor255_242_204;
  10938. }
  10939. cell.SetCellValue(setCellValue); //写入单元格
  10940. }
  10941. if (overspendSoure.ContainsKey(thisSid))
  10942. {
  10943. var overspendId = overspendSoure[thisSid];
  10944. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10945. }
  10946. cloneRowFn();
  10947. existsId.Add(new CarCompare
  10948. {
  10949. DataPrice = item.DatePrice.ObjToDate(),
  10950. Sid = item.SId
  10951. });
  10952. }
  10953. if (item.Equals(lastElem))
  10954. {
  10955. //合并小计行
  10956. //创建合并区域的实例
  10957. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10958. rowStartIndex, // 起始行索引(0-based)
  10959. rowStartIndex, // 结束行索引(0-based)
  10960. 0, // 起始列索引(0-based)
  10961. 3 // 结束列索引(0-based)
  10962. );
  10963. sheet.AddMergedRegion(cellRangeAddress);
  10964. var CellStyle = workbook.CreateCellStyle();
  10965. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10966. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10967. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10968. for (int i = 0; i <= clounmCount; i++)
  10969. {
  10970. if (i > 6)
  10971. {
  10972. var CellStyle1 = workbook.CreateCellStyle();
  10973. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10974. IFont Font = workbook.CreateFont(); // 创建字体
  10975. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10976. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10977. CellStyle1.SetFont(Font);
  10978. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10979. }
  10980. else
  10981. {
  10982. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10983. }
  10984. }
  10985. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10986. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10987. //超时合计
  10988. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10989. //超时数
  10990. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10991. //超时合计费用
  10992. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10993. cloneRowFn();
  10994. // 创建合并区域的实例
  10995. cellRangeAddress = new CellRangeAddress(
  10996. rowStartIndex, // 起始行索引(0-based)
  10997. rowStartIndex, // 结束行索引(0-based)
  10998. 0, // 起始列索引(0-based)
  10999. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11000. );
  11001. // 添加合并区域
  11002. sheet.AddMergedRegion(cellRangeAddress);
  11003. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11004. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11005. }
  11006. }
  11007. mergeRow();
  11008. // 保存修改后的Excel文件到新文件
  11009. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11010. // new FileStream(newFilePath, FileMode.CreateNew)
  11011. using (var stream = new MemoryStream())
  11012. {
  11013. workbook.Write(stream, true);
  11014. stream.Flush();
  11015. stream.Seek(0, SeekOrigin.Begin);
  11016. MemoryStream memoryStream = new MemoryStream();
  11017. stream.CopyTo(memoryStream);
  11018. memoryStream.Seek(0, SeekOrigin.Begin);
  11019. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11020. }
  11021. workbook.Close();
  11022. workbook.Dispose();
  11023. }
  11024. catch (Exception ex)
  11025. {
  11026. jw.Msg = "出现异常!" + ex.Message;
  11027. return Ok(jw);
  11028. }
  11029. }
  11030. if (Zips.Count > 0)
  11031. {
  11032. IOOperatorHelper io = new IOOperatorHelper();
  11033. var byts = io.ConvertZipStream(Zips);
  11034. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11035. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11036. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11037. }
  11038. else
  11039. {
  11040. jw.Msg = "暂无生成文件!";
  11041. }
  11042. return Ok(jw);
  11043. }
  11044. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11045. {
  11046. string outStr = string.Empty;
  11047. switch (i)
  11048. {
  11049. case 0:
  11050. outStr = arr[0].SidName;
  11051. break;
  11052. case 1:
  11053. outStr = arr[0].DataPriceStr;
  11054. break;
  11055. case 2:
  11056. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11057. break;
  11058. case 4:
  11059. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11060. break;
  11061. case 7:
  11062. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11063. {
  11064. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11065. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11066. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11067. }
  11068. break;
  11069. case 8:
  11070. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11071. {
  11072. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11073. }
  11074. break;
  11075. case 9:
  11076. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11077. {
  11078. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11079. }
  11080. break;
  11081. case 10:
  11082. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11083. {
  11084. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11085. }
  11086. break;
  11087. }
  11088. return outStr;
  11089. }
  11090. #region OP行程单
  11091. /// <summary>
  11092. /// OP行程单初始化
  11093. /// </summary>
  11094. /// <param name="dto"></param>
  11095. /// <returns></returns>
  11096. [HttpPost]
  11097. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11098. {
  11099. var jw = JsonView(false);
  11100. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11101. var group = groupList.First();
  11102. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11103. if (group == null)
  11104. {
  11105. jw.Msg = "暂无团组!";
  11106. return Ok(jw);
  11107. }
  11108. group = groupList.Find(x => x.Id == diid);
  11109. if (group == null)
  11110. {
  11111. jw.Msg = "请输入正确的团组ID!";
  11112. return Ok(jw);
  11113. }
  11114. string city = string.Empty;
  11115. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11116. if (blackCode.Count > 0)
  11117. {
  11118. var black = blackCode.First();
  11119. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11120. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11121. if (blackSp.Length > 0)
  11122. {
  11123. try
  11124. {
  11125. var cityArrCode = new List<string>(20);
  11126. foreach (var item in blackSp)
  11127. {
  11128. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11129. var IndexSelect = itemSp[2];
  11130. var cityArrCodeLength = cityArrCode.Count - 1;
  11131. var startCity = IndexSelect.Substring(0, 3);
  11132. if (cityArrCodeLength > 0)
  11133. {
  11134. var arrEndCity = cityArrCode[cityArrCodeLength];
  11135. if (arrEndCity != startCity)
  11136. {
  11137. cityArrCode.Add(startCity.ToUpper());
  11138. }
  11139. }
  11140. else
  11141. {
  11142. cityArrCode.Add(startCity.ToUpper());
  11143. }
  11144. var endCity = IndexSelect.Substring(3, 3);
  11145. cityArrCode.Add(endCity.ToUpper());
  11146. }
  11147. var cityThree = string.Empty;
  11148. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11149. cityThree = cityThree.TrimEnd(',');
  11150. if (string.IsNullOrWhiteSpace(cityThree))
  11151. {
  11152. throw new
  11153. Exception("error");
  11154. }
  11155. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11156. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11157. foreach (var item in cityArrCode)
  11158. {
  11159. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11160. if (find != null)
  11161. {
  11162. city += find.City + "/";
  11163. }
  11164. else
  11165. {
  11166. city += item + "三字码未收入/";
  11167. }
  11168. }
  11169. city = city.TrimEnd('/');
  11170. }
  11171. catch (Exception e)
  11172. {
  11173. city = "黑屏代码格式不正确!";
  11174. }
  11175. }
  11176. }
  11177. else
  11178. {
  11179. city = "未录入黑屏代码";
  11180. }
  11181. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11182. {
  11183. Date = x.Date,
  11184. Days = x.Days,
  11185. Diffgroup = x.Diffgroup,
  11186. Diid = x.Diid,
  11187. Traffic_First = x.Traffic_First,
  11188. Traffic_Second = x.Traffic_Second,
  11189. Trip = x.Trip,
  11190. WeekDay = x.WeekDay,
  11191. Id = x.Id
  11192. }).ToList();
  11193. jw.Data = new
  11194. {
  11195. groupList = groupList.Select(x => new
  11196. {
  11197. x.Id,
  11198. x.TeamName,
  11199. x.TourCode
  11200. }).ToList(),
  11201. groupInfo = new
  11202. {
  11203. group.VisitDays,
  11204. group.TourCode,
  11205. group.VisitPNumber,
  11206. group.TeamName,
  11207. city
  11208. },
  11209. OpTravelList
  11210. };
  11211. jw.Code = 200;
  11212. jw.Msg = "操作成功!";
  11213. return Ok(jw);
  11214. }
  11215. /// <summary>
  11216. /// 删除团组行程单
  11217. /// </summary>
  11218. /// <returns></returns>
  11219. [HttpPost]
  11220. public IActionResult DelTravel(DelOpTravelDto dto)
  11221. {
  11222. var jw = JsonView(false);
  11223. if (dto.UserId <= 0 || dto.Diid <= 0)
  11224. {
  11225. jw.Msg = "请输入正确的参数!";
  11226. return Ok(jw);
  11227. }
  11228. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11229. .SetColumns(x => new Grp_TravelList
  11230. {
  11231. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11232. DeleteUserId = dto.UserId,
  11233. IsDel = 1,
  11234. }).ExecuteCommand();
  11235. jw = JsonView(true);
  11236. return Ok(jw);
  11237. }
  11238. /// <summary>
  11239. /// 行程单保存
  11240. /// </summary>
  11241. /// <returns></returns>
  11242. [HttpPost]
  11243. public IActionResult TravelSave(TravelSaveDto dto)
  11244. {
  11245. var jw = JsonView(false);
  11246. if (dto.Arr.Count > 0)
  11247. {
  11248. try
  11249. {
  11250. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11251. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11252. .ToList();
  11253. _sqlSugar.BeginTran();
  11254. foreach (var item in dto.Arr)
  11255. {
  11256. if (item.Id == 0)
  11257. {
  11258. throw new Exception("请传入正确的Id");
  11259. }
  11260. //比较上一次的差异
  11261. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11262. if (findTravel != null)
  11263. {
  11264. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11265. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11266. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11267. }
  11268. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11269. .SetColumns(x => new Grp_TravelList
  11270. {
  11271. Trip = item.Trip
  11272. }).ExecuteCommand();
  11273. }
  11274. _sqlSugar.CommitTran();
  11275. jw = JsonView(true);
  11276. }
  11277. catch (Exception ex)
  11278. {
  11279. _sqlSugar.RollbackTran();
  11280. jw.Msg = "程序异常!" + ex.Message;
  11281. }
  11282. }
  11283. else
  11284. {
  11285. jw.Msg = "请传入正确的参数!";
  11286. }
  11287. return Ok(jw);
  11288. }
  11289. private string CheckStr(string original, string changed)
  11290. {
  11291. // 创建diff_match_patch对象
  11292. var dmp = new diff_match_patch();
  11293. // 计算差异
  11294. List<Diff> diffs = dmp.diff_main(original, changed);
  11295. // 清理和合并差异
  11296. dmp.diff_cleanupSemantic(diffs);
  11297. // 使用StringBuilder构建最终的字符串
  11298. StringBuilder finalString = new StringBuilder();
  11299. // 输出差异结果,并构建变动后的字符串
  11300. foreach (Diff diff in diffs)
  11301. {
  11302. switch (diff.operation)
  11303. {
  11304. case Operation.EQUAL:
  11305. // 相等的部分,直接添加到最终字符串
  11306. finalString.Append(diff.text);
  11307. break;
  11308. case Operation.INSERT:
  11309. // 插入的部分,添加标记并添加到最终字符串
  11310. finalString.Append("[++]" + diff.text + "[++]");
  11311. break;
  11312. case Operation.DELETE:
  11313. // 删除的部分,不添加到最终字符串
  11314. //finalString.Append("[++]" + diff.text + "[++]");
  11315. break;
  11316. }
  11317. }
  11318. // 输出变动后的字符串
  11319. return finalString.ToString();
  11320. }
  11321. private class tagContent
  11322. {
  11323. public DateTime Date { get; set; }
  11324. public string StartTag { get; set; }
  11325. public string EndTag { get; set; }
  11326. public string Content { get; set; }
  11327. public static int tagLength { get { return 3; } }
  11328. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11329. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11330. public bool IsFinally { get; set; }
  11331. }
  11332. private List<string> ExtractContentBetweenTags(string input, string tag)
  11333. {
  11334. List<string> results = new List<string>();
  11335. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11336. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11337. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11338. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11339. string[] strValueArr = new string[1];
  11340. foreach (System.Text.RegularExpressions.Match match in matches)
  11341. {
  11342. var strValue = match.Groups[1].Value;
  11343. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11344. }
  11345. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11346. return results;
  11347. }
  11348. /// <summary>
  11349. /// 导出行程单
  11350. /// </summary>
  11351. /// <param name="dto"></param>
  11352. /// <returns></returns>
  11353. [HttpPost]
  11354. public IActionResult ExportTravel(ExportTravelDto dto)
  11355. {
  11356. var jw = JsonView(false);
  11357. jw.Data = "";
  11358. int diid = 0;
  11359. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11360. if (Find == null)
  11361. {
  11362. jw.Msg = "请选择正确的团组!";
  11363. return Ok(jw);
  11364. }
  11365. else
  11366. {
  11367. diid = Find.Id;
  11368. }
  11369. //数据源
  11370. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11371. DataTable dtBlack = null;
  11372. try
  11373. {
  11374. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11375. }
  11376. catch (Exception)
  11377. {
  11378. jw.Msg = "机票黑屏代码有误!";
  11379. return Ok(jw);
  11380. }
  11381. string CityStr = string.Empty;
  11382. if (dtBlack.Rows.Count == 0)
  11383. {
  11384. jw.Msg = "机票黑屏代码有误!";
  11385. return Ok(jw);
  11386. }
  11387. else
  11388. {
  11389. foreach (DataRow row in dtBlack.Rows)
  11390. {
  11391. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11392. {
  11393. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11394. return Ok(jw);
  11395. }
  11396. }
  11397. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11398. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11399. }
  11400. // 指定的文字
  11401. var targetTextDic = new Dictionary<string, List<string>>();
  11402. //创建数据源Table
  11403. DataTable dtSource = new DataTable();
  11404. dtSource.Columns.Add("Days", typeof(string));
  11405. dtSource.Columns.Add("Date", typeof(string));
  11406. dtSource.Columns.Add("Week", typeof(string));
  11407. dtSource.Columns.Add("Traffic", typeof(string));
  11408. dtSource.Columns.Add("Trip", typeof(string));
  11409. //获取数据,放到datatable
  11410. foreach (var item in _travelList)
  11411. {
  11412. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11413. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11414. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11415. .Replace("[++]", string.Empty);
  11416. DataRow dr = dtSource.NewRow();
  11417. dr["Days"] = item.Days;
  11418. dr["Date"] = item.Date;
  11419. dr["Week"] = item.WeekDay;
  11420. dr["Traffic"] = item.Traffic_First
  11421. + "\r\n"
  11422. + item.Traffic_Second;
  11423. dr["Trip"] = item.Trip;
  11424. dtSource.Rows.Add(dr);
  11425. }
  11426. Dictionary<string, string> dic = new Dictionary<string, string>();
  11427. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11428. dic.Add("City", CityStr);
  11429. dic.Add("Days", Find.VisitDays.ToString());
  11430. dic.Add("DeleCode", Find.TourCode);
  11431. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11432. //模板路径
  11433. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11434. //载入模板
  11435. Document doc = null;
  11436. DocumentBuilder builder = null;
  11437. try
  11438. {
  11439. //载入模板
  11440. doc = new Document(tempPath);
  11441. builder = new DocumentBuilder(doc);
  11442. }
  11443. catch (Exception)
  11444. {
  11445. jw.Msg = "模板位置不存在!";
  11446. return Ok(jw);
  11447. }
  11448. foreach (var key in dic.Keys)
  11449. {
  11450. Bookmark bookmark = doc.Range.Bookmarks[key];
  11451. if (bookmark != null)
  11452. {
  11453. builder.MoveToBookmark(key);
  11454. builder.Write(dic[key]);
  11455. }
  11456. }
  11457. //获取word里所有表格
  11458. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11459. //获取所填表格的序数
  11460. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11461. try
  11462. {
  11463. //循环赋值
  11464. for (int i = 0; i < dtSource.Rows.Count; i++)
  11465. {
  11466. builder.MoveToCell(0, i + 1, 0, 0);
  11467. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11468. builder.MoveToCell(0, i + 1, 1, 0);
  11469. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11470. builder.MoveToCell(0, i + 1, 2, 0);
  11471. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11472. var trip = dtSource.Rows[i]["Trip"].ToString();
  11473. builder.MoveToCell(0, i + 1, 3, 0);
  11474. builder.Write(trip);
  11475. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11476. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11477. // 获取特定索引的段落
  11478. Paragraph paragraph = (Paragraph)paragraphs[0];
  11479. Run run = paragraph.Runs[0];
  11480. Aspose.Words.Font font = run.Font;
  11481. font.Name = "黑体";
  11482. //设置双休红色
  11483. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11484. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11485. paragraph = (Paragraph)paragraphs[1];
  11486. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11487. {
  11488. run = paragraph.Runs[0];
  11489. font = run.Font;
  11490. font.Color = Color.Red;
  11491. }
  11492. }
  11493. }
  11494. catch (Exception ex)
  11495. {
  11496. }
  11497. //删除多余行
  11498. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11499. {
  11500. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11501. }
  11502. var targetTextList = new List<string>();
  11503. // 遍历文档中的表格
  11504. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11505. {
  11506. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11507. {
  11508. var cellIndex = 0;
  11509. foreach (Cell cell in row.Cells)
  11510. {
  11511. if (cellIndex == 1 && row.Cells.Count == 4)
  11512. {
  11513. foreach (var target in targetTextDic.Keys)
  11514. {
  11515. if (cell.GetText().Contains(target))
  11516. {
  11517. targetTextList = targetTextDic[target];
  11518. break;
  11519. }
  11520. }
  11521. }
  11522. // 遍历单元格中的所有段落
  11523. foreach (Paragraph paragraph in cell.Paragraphs)
  11524. {
  11525. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11526. List<Run> runs = new List<Run>();
  11527. foreach (Run run in paragraph.Runs)
  11528. {
  11529. runs.Add(run);
  11530. }
  11531. foreach (Run run in runs)
  11532. {
  11533. foreach (var targetText in targetTextList)
  11534. {
  11535. // 检查文字是否包含指定文字
  11536. if (run.Text.Contains(targetText))
  11537. {
  11538. // 将包含的部分设置为红色
  11539. HighlightText(run, targetText, Color.Red);
  11540. }
  11541. }
  11542. }
  11543. }
  11544. cellIndex++;
  11545. }
  11546. }
  11547. }
  11548. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11549. if (!Directory.Exists(savePath))
  11550. {
  11551. try
  11552. {
  11553. Directory.CreateDirectory(savePath);
  11554. }
  11555. catch
  11556. {
  11557. }
  11558. }
  11559. string path = savePath + Find.TeamName + "出访日程";
  11560. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11561. try
  11562. {
  11563. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11564. string postfix = ".docx";
  11565. if (dto.IsPDF == 1)
  11566. {
  11567. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11568. postfix = ".pdf";
  11569. }
  11570. doc.Save(path + postfix, saveFormat);
  11571. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11572. }
  11573. catch (Exception)
  11574. {
  11575. jw = JsonView(false);
  11576. }
  11577. return Ok(jw);
  11578. }
  11579. /// <summary>
  11580. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11581. /// </summary>
  11582. /// <param name="num"></param>
  11583. /// <returns></returns>
  11584. string GetNum(string num)
  11585. {
  11586. string str = "";
  11587. switch (num)
  11588. {
  11589. case "1":
  11590. str = "一";
  11591. break;
  11592. case "2":
  11593. str = "二";
  11594. break;
  11595. case "3":
  11596. str = "三";
  11597. break;
  11598. case "4":
  11599. str = "四";
  11600. break;
  11601. case "5":
  11602. str = "五";
  11603. break;
  11604. case "6":
  11605. str = "六";
  11606. break;
  11607. case "7":
  11608. str = "七";
  11609. break;
  11610. case "8":
  11611. str = "八";
  11612. break;
  11613. case "9":
  11614. str = "九";
  11615. break;
  11616. case "10":
  11617. str = "十";
  11618. break;
  11619. case "11":
  11620. str = "十一";
  11621. break;
  11622. case "12":
  11623. str = "十二";
  11624. break;
  11625. case "一":
  11626. str = "1";
  11627. break;
  11628. case "二":
  11629. str = "2";
  11630. break;
  11631. case "三":
  11632. str = "3";
  11633. break;
  11634. case "四":
  11635. str = "4";
  11636. break;
  11637. case "五":
  11638. str = "5";
  11639. break;
  11640. case "六":
  11641. str = "6";
  11642. break;
  11643. case "七":
  11644. str = "7";
  11645. break;
  11646. case "八":
  11647. str = "8";
  11648. break;
  11649. case "九":
  11650. str = "9";
  11651. break;
  11652. case "十":
  11653. str = "10";
  11654. break;
  11655. case "十一":
  11656. str = "11";
  11657. break;
  11658. case "十二":
  11659. str = "12";
  11660. break;
  11661. }
  11662. return str;
  11663. }
  11664. // 高亮包含指定文字的部分
  11665. void HighlightText(Run run, string targetText, Color color)
  11666. {
  11667. string text = run.Text;
  11668. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11669. if (startIndex >= 0)
  11670. {
  11671. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11672. // 前部分
  11673. if (startIndex > 0)
  11674. {
  11675. Run beforeRun = (Run)run.Clone(true);
  11676. beforeRun.Text = text.Substring(0, startIndex);
  11677. parentParagraph.InsertBefore(beforeRun, run);
  11678. }
  11679. // 匹配部分
  11680. Run matchRun = (Run)run.Clone(true);
  11681. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11682. matchRun.Font.Color = color;
  11683. parentParagraph.InsertBefore(matchRun, run);
  11684. // 后部分
  11685. if (startIndex + targetText.Length < text.Length)
  11686. {
  11687. Run afterRun = (Run)run.Clone(true);
  11688. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11689. parentParagraph.InsertBefore(afterRun, run);
  11690. }
  11691. // 删除原始Run
  11692. run.Remove();
  11693. }
  11694. }
  11695. #endregion
  11696. #endregion
  11697. #region 团组成本
  11698. /// <summary>
  11699. /// 团组成本数据初始化
  11700. /// </summary>
  11701. /// <param name="dto"></param>
  11702. /// <returns></returns>
  11703. [HttpPost]
  11704. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11705. {
  11706. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11707. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11708. WHEN COUNT(*) >= 0 THEN 'True'
  11709. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11710. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11711. ").ToList(); //团组列表
  11712. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11713. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11714. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11715. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11716. if (groupinfoValue != null)
  11717. {
  11718. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11719. var spArr = new string[1] { countryArr };
  11720. if (countryArr.Contains("|"))
  11721. {
  11722. spArr = countryArr.Split("|");
  11723. }
  11724. else if (countryArr.Contains("、"))
  11725. {
  11726. spArr = countryArr.Split("、");
  11727. }
  11728. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11729. {
  11730. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11731. if (dbQueryCountry != null)
  11732. {
  11733. visaCountryInfoArr.Add(dbQueryCountry);
  11734. }
  11735. }
  11736. }
  11737. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11738. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11739. var create = _GroupCostRepository.
  11740. CreateGroupCostByBlackCode(dto.Diid);
  11741. if (groupCost.Count == 0 && create.Code == 0)
  11742. {
  11743. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11744. }
  11745. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11746. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11747. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11748. groupCostMap = groupCostMap.Select(x =>
  11749. {
  11750. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11751. {
  11752. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11753. }
  11754. return x;
  11755. }).ToList();
  11756. //GroupCostParameter.Add(new
  11757. // Grp_GroupCostParameter());
  11758. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11759. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11760. return Ok(JsonView(new
  11761. {
  11762. groupList,
  11763. groupInfo,
  11764. groupChecks,
  11765. groupCost = groupCostMap,
  11766. hotelNumber,
  11767. GroupCostParameter = GroupCostParameterMap,
  11768. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11769. {
  11770. x.VisaCountry,
  11771. x.VisaPrice,
  11772. x.Id,
  11773. }).ToList(),
  11774. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11775. blackCodeIsTrue = create.Code == 0 ? true : false,
  11776. hotelIsTrue = hotelIsTrue,
  11777. }));
  11778. }
  11779. /// <summary>
  11780. /// 团组成本信息保存
  11781. /// </summary>
  11782. /// <param name="dto"></param>
  11783. /// <returns></returns>
  11784. [HttpPost]
  11785. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11786. {
  11787. if (dto.Diid <= 0 || dto.Userid <= 0)
  11788. {
  11789. return Ok(JsonView(false));
  11790. }
  11791. JsonView jw = null;
  11792. bool isTrue = false;
  11793. #region 复制团组成本
  11794. //if (dto.Diid == 2581)
  11795. //{
  11796. // dto.Diid = 2599;
  11797. // dto.CheckBoxs.ForEach(x =>
  11798. // {
  11799. // x.Diid = 2599;
  11800. // });
  11801. // dto.GroupCosts.ForEach(x =>
  11802. // {
  11803. // x.Diid = 2599;
  11804. // });
  11805. // dto.CostTypeHotelNumbers.ForEach(x =>
  11806. // {
  11807. // x.Diid = 2599;
  11808. // });
  11809. // dto.GroupCostParameters.ForEach(x =>
  11810. // {
  11811. // x.DiId = 2599;
  11812. // });
  11813. //}
  11814. #endregion
  11815. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11816. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11817. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11818. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11819. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11820. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11821. try
  11822. {
  11823. _sqlSugar.BeginTran();
  11824. isTrue = await _GroupCostRepository.
  11825. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11826. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11827. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11828. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11829. _sqlSugar.CommitTran();
  11830. jw = JsonView(true, "保存成功!", isTrue);
  11831. }
  11832. catch (Exception)
  11833. {
  11834. _sqlSugar.RollbackTran();
  11835. jw = JsonView(false);
  11836. }
  11837. return Ok(jw);
  11838. }
  11839. /// <summary>
  11840. /// 司兼导数据
  11841. /// </summary>
  11842. /// <param name="dto"></param>
  11843. /// <returns></returns>
  11844. [HttpPost]
  11845. public IActionResult GetCarGuides(CarGuidesDto dto)
  11846. {
  11847. JsonView jw = null;
  11848. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11849. jw = JsonView(true, "获取成功!", Data);
  11850. return Ok(jw);
  11851. }
  11852. /// <summary>
  11853. /// 导游数据
  11854. /// </summary>
  11855. /// <param name="dto"></param>
  11856. /// <returns></returns>
  11857. [HttpPost]
  11858. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11859. {
  11860. JsonView jw = null;
  11861. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11862. // 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
  11863. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11864. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11865. jw = JsonView(true, "获取成功!", Data);
  11866. return Ok(jw);
  11867. }
  11868. /// <summary>
  11869. /// 成本车数据
  11870. /// </summary>
  11871. /// <param name="dto"></param>
  11872. /// <returns></returns>
  11873. [HttpPost]
  11874. public IActionResult GetCarInfo(CarGuidesDto dto)
  11875. {
  11876. JsonView jw = null;
  11877. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11878. jw = JsonView(true, "获取成功!", Data);
  11879. return Ok(jw);
  11880. }
  11881. /// <summary>
  11882. /// 景点数据
  11883. /// </summary>
  11884. /// <param name="dto"></param>
  11885. /// <returns></returns>
  11886. [HttpPost]
  11887. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11888. {
  11889. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11890. return Ok(JsonView(true, "获取成功!", Data));
  11891. }
  11892. /// <summary>
  11893. /// 成本通知
  11894. /// </summary>
  11895. /// <param name="dto"></param>
  11896. /// <returns></returns>
  11897. [HttpPost]
  11898. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11899. {
  11900. if (dto.Diid < 0)
  11901. {
  11902. return Ok(JsonView(false));
  11903. }
  11904. JsonView jw = null;
  11905. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11906. if (GroupCostParameter != null)
  11907. {
  11908. int IsShare = 0;
  11909. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11910. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11911. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11912. string msg = string.Empty;
  11913. if (isTrue)
  11914. {
  11915. if (IsShare == 0)
  11916. {
  11917. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11918. }
  11919. else
  11920. {
  11921. #region 企微通知对应岗位用户
  11922. try
  11923. {
  11924. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11925. }
  11926. catch (Exception ex)
  11927. {
  11928. }
  11929. #endregion
  11930. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11931. }
  11932. jw = JsonView(isTrue, msg, new { IsShare });
  11933. }
  11934. else
  11935. {
  11936. msg = "修改失败!";
  11937. jw = JsonView(isTrue, msg);
  11938. }
  11939. }
  11940. else
  11941. {
  11942. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11943. }
  11944. return Ok(jw);
  11945. }
  11946. /// <summary>
  11947. /// 导出报价单
  11948. /// </summary>
  11949. /// <param name="dto"></param>
  11950. /// <returns></returns>
  11951. [HttpPost]
  11952. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11953. {
  11954. if (dto.Diid == 0)
  11955. {
  11956. return Ok(JsonView(false, "请传递团组id"));
  11957. }
  11958. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11959. if (deleInfo.Code != 0)
  11960. {
  11961. return Ok(JsonView(false, "团组信息查询失败!"));
  11962. }
  11963. var di = deleInfo.Data as DelegationInfoWebView;
  11964. if (di != null)
  11965. {
  11966. di.TeamName = di.TeamName.Replace("|", "、");
  11967. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11968. //文件名
  11969. string strFileName = di.TeamName + "-收款账单.doc";
  11970. //获取模板
  11971. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11972. //载入模板
  11973. Document doc = new Document(tmppath);
  11974. decimal TotalPrice = 0.00M;
  11975. string itemStr = string.Empty;
  11976. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11977. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11978. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11979. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11980. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11981. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11982. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11983. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11984. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11985. foreach (var cost in groupCostType)
  11986. {
  11987. var List = cost.ToList();
  11988. if (cost.Key == "A")
  11989. {
  11990. foreach (var ListItem in List)
  11991. {
  11992. if (ListItem.number > 0)
  11993. {
  11994. if (ListItem.code.Contains("TBR"))
  11995. {
  11996. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11997. }
  11998. else
  11999. {
  12000. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12001. }
  12002. TotalPrice += (ListItem.number * ListItem.price);
  12003. }
  12004. }
  12005. }
  12006. else
  12007. {
  12008. itemStr = itemStr.Insert(0, "A段\r\n");
  12009. itemStr += "B段\r\n";
  12010. foreach (var ListItem in List)
  12011. {
  12012. if (ListItem.number > 0)
  12013. {
  12014. if (ListItem.code.Contains("TBR"))
  12015. {
  12016. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12017. }
  12018. else
  12019. {
  12020. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12021. }
  12022. TotalPrice += (ListItem.number * ListItem.price);
  12023. }
  12024. }
  12025. }
  12026. }
  12027. #region 替换Word模板书签内容
  12028. Dictionary<string, string> marks = new Dictionary<string, string>();
  12029. marks.Add("To", di.ClientUnit);//付款方
  12030. marks.Add("ToTel", di.TellPhone);//付款方电话
  12031. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12032. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12033. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12034. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12035. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12036. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12037. marks.Add("PayItemContent", itemStr);//详细信息
  12038. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12039. #endregion
  12040. ////注
  12041. //if (doc.Range.Bookmarks["Attention"] != null)
  12042. //{
  12043. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12044. // mark.Text = frList[0].Attention;
  12045. //}
  12046. foreach (var item in marks.Keys)
  12047. {
  12048. if (doc.Range.Bookmarks[item] != null)
  12049. {
  12050. Bookmark mark = doc.Range.Bookmarks[item];
  12051. mark.Text = marks[item];
  12052. }
  12053. }
  12054. byte[] bytes = null;
  12055. using (MemoryStream stream = new MemoryStream())
  12056. {
  12057. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12058. bytes = stream.ToArray();
  12059. }
  12060. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12061. return Ok(JsonView(true, "", new
  12062. {
  12063. Data = bytes,
  12064. strFileName,
  12065. }));
  12066. }
  12067. else
  12068. {
  12069. return Ok(JsonView(false, "团组信息不存在!"));
  12070. }
  12071. }
  12072. /// <summary>
  12073. /// 导出团组成本
  12074. /// </summary>
  12075. /// <param name="dto"></param>
  12076. /// <returns></returns>
  12077. [HttpPost]
  12078. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12079. {
  12080. var jw = JsonView(false);
  12081. if (dto.Diid == 0)
  12082. {
  12083. return Ok(JsonView(false, "请传递团组id"));
  12084. }
  12085. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12086. if (deleInfo.Code != 0)
  12087. {
  12088. return Ok(JsonView(false, "团组信息查询失败!"));
  12089. }
  12090. var di = deleInfo.Data as DelegationInfoWebView;
  12091. if (di == null)
  12092. {
  12093. return Ok(JsonView(false, "团组信息查询失败!"));
  12094. }
  12095. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12096. WorkbookDesigner designer = new WorkbookDesigner();
  12097. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12098. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12099. for (int i = 0; i < List_GC.Count; i++)
  12100. {
  12101. GroupCost_Excel gc = new GroupCost_Excel();
  12102. gc.Id = List_GC[i].Id;
  12103. gc.Diid = List_GC[i].Diid.ToString();
  12104. gc.DAY = List_GC[i].DAY;
  12105. string week = "";
  12106. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12107. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12108. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12109. gc.ITIN = List_GC[i].ITIN;
  12110. gc.CarType = List_GC[i].CarType;
  12111. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12112. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12113. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12114. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12115. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12116. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12117. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12118. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12119. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12120. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12121. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12122. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12123. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12124. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12125. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12126. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12127. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12128. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12129. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12130. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12131. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12132. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12133. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12134. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12135. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12136. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12137. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12138. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12139. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12140. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12141. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12142. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12143. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12144. List_GC1.Add(gc);
  12145. }
  12146. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12147. dt.TableName = "TB";
  12148. //报表标题等不用dt的值
  12149. designer.SetDataSource("TeamName", dto.title.TeamName);
  12150. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12151. designer.SetDataSource("Tax", dto.title.Tax);
  12152. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12153. designer.SetDataSource("Currency", dto.title.Currency);
  12154. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12155. designer.SetDataSource("Rate", dto.title.Rate);
  12156. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12157. var Aparams = hotels.Find(x => x.Type == "Default");
  12158. if (Aparams == null)
  12159. {
  12160. return Ok(jw);
  12161. }
  12162. //酒店数量
  12163. var txtSGRNumber = Aparams.SGR.ToString();
  12164. var txtTBRNumber = Aparams.TBR.ToString();
  12165. var txtJSESNumber = Aparams.JSES.ToString();
  12166. var txtSUITENumbe = Aparams.SUITE.ToString();
  12167. if (dto.costType == "B")
  12168. {
  12169. Aparams = hotels.Find(x => x.Type == "A");
  12170. var Bparams = hotels.Find(x => x.Type == "B");
  12171. if (Aparams == null || Bparams == null)
  12172. {
  12173. return Ok(jw);
  12174. }
  12175. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12176. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12177. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12178. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12179. }
  12180. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12181. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12182. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12183. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12184. var ws = designer.Workbook.Worksheets[0];
  12185. int Row = List_GC.Count;
  12186. int startIndex = 11;
  12187. int HideRows = 0;
  12188. List<int> hideRowsList = new List<int>();
  12189. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12190. #region A段left数据
  12191. var left = dto.leftInfo.Find(x => x.Type == "A");
  12192. if (left == null)
  12193. {
  12194. return Ok(jw);
  12195. }
  12196. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12197. if (leftBindData != null)
  12198. {
  12199. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12200. designer.SetDataSource("VisaRS", leftBindData.rs);
  12201. designer.SetDataSource("VisaXS", leftBindData.xs);
  12202. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12203. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12204. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12205. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12206. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12207. }
  12208. else
  12209. {
  12210. hideRowsList.Add(Row + startIndex + HideRows);
  12211. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12212. }
  12213. HideRows += 2;
  12214. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12215. if (leftBindData != null)
  12216. {
  12217. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12218. designer.SetDataSource("BXRS", leftBindData.rs);
  12219. designer.SetDataSource("BXXS", leftBindData.xs);
  12220. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12221. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12222. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12223. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12224. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12225. }
  12226. else
  12227. {
  12228. hideRowsList.Add(Row + startIndex + HideRows);
  12229. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12230. }
  12231. HideRows += 2;
  12232. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12233. if (leftBindData != null)
  12234. {
  12235. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12236. designer.SetDataSource("HSRS", leftBindData.rs);
  12237. designer.SetDataSource("HSXS", leftBindData.xs);
  12238. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12239. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12240. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12241. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12242. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12243. }
  12244. else
  12245. {
  12246. hideRowsList.Add(Row + startIndex + HideRows);
  12247. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12248. }
  12249. HideRows += 2;
  12250. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12251. if (leftBindData != null)
  12252. {
  12253. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12254. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12255. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12256. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12257. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12258. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12259. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12260. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12261. }
  12262. else
  12263. {
  12264. hideRowsList.Add(Row + startIndex + HideRows);
  12265. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12266. }
  12267. HideRows += 2;
  12268. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12269. if (leftBindData != null)
  12270. {
  12271. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12272. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12273. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12274. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12275. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12276. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12277. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12278. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12279. }
  12280. else
  12281. {
  12282. hideRowsList.Add(Row + startIndex + HideRows);
  12283. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12284. }
  12285. HideRows += 2;
  12286. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12287. if (leftBindData != null)
  12288. {
  12289. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12290. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12291. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12292. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12293. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12294. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12295. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12296. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12297. }
  12298. else
  12299. {
  12300. hideRowsList.Add(Row + startIndex + HideRows);
  12301. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12302. }
  12303. HideRows += 2;
  12304. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12305. if (leftBindData != null)
  12306. {
  12307. ////TBR
  12308. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12309. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12310. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12311. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12312. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12313. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12314. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12315. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12316. }
  12317. else
  12318. {
  12319. hideRowsList.Add(Row + startIndex + HideRows);
  12320. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12321. }
  12322. HideRows += 2;
  12323. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12324. if (leftBindData != null)
  12325. {
  12326. ////SGR
  12327. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12328. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12329. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12330. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12331. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12332. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12333. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12334. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12335. }
  12336. else
  12337. {
  12338. hideRowsList.Add(Row + startIndex + HideRows);
  12339. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12340. }
  12341. HideRows += 2;
  12342. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12343. if (leftBindData != null)
  12344. {
  12345. ////JS/ES
  12346. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12347. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12348. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12349. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12350. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12351. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12352. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12353. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12354. }
  12355. else
  12356. {
  12357. hideRowsList.Add(Row + startIndex + HideRows);
  12358. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12359. }
  12360. HideRows += 2;
  12361. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12362. if (leftBindData != null)
  12363. {
  12364. ////SUITE
  12365. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12366. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12367. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12368. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12369. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12370. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12371. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12372. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12373. }
  12374. else
  12375. {
  12376. hideRowsList.Add(Row + startIndex + HideRows);
  12377. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12378. }
  12379. HideRows += 2;
  12380. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12381. if (leftBindData != null)
  12382. {
  12383. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12384. designer.SetDataSource("DJRS", leftBindData.rs);
  12385. designer.SetDataSource("DJXS", leftBindData.xs);
  12386. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12387. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12388. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12389. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12390. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12391. }
  12392. else
  12393. {
  12394. hideRowsList.Add(Row + startIndex + HideRows);
  12395. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12396. }
  12397. HideRows += 2;
  12398. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12399. if (leftBindData != null)
  12400. {
  12401. designer.SetDataSource("HCPCB", leftBindData.cb);
  12402. designer.SetDataSource("HCPRS", leftBindData.rs);
  12403. designer.SetDataSource("HCPXS", leftBindData.xs);
  12404. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12405. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12406. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12407. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12408. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12409. }
  12410. else
  12411. {
  12412. hideRowsList.Add(Row + startIndex + HideRows);
  12413. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12414. }
  12415. HideRows += 2;
  12416. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12417. if (leftBindData != null)
  12418. {
  12419. designer.SetDataSource("CPCB", leftBindData.cb);
  12420. designer.SetDataSource("CPRS", leftBindData.rs);
  12421. designer.SetDataSource("CPXS", leftBindData.xs);
  12422. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12423. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12424. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12425. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12426. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12427. }
  12428. else
  12429. {
  12430. hideRowsList.Add(Row + startIndex + HideRows);
  12431. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12432. }
  12433. HideRows += 2;
  12434. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12435. if (leftBindData != null)
  12436. {
  12437. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12438. designer.SetDataSource("GWRS", leftBindData.rs);
  12439. designer.SetDataSource("GWXS", leftBindData.xs);
  12440. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12441. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12442. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12443. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12444. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12445. }
  12446. else
  12447. {
  12448. hideRowsList.Add(Row + startIndex + HideRows);
  12449. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12450. }
  12451. HideRows += 2;
  12452. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12453. if (leftBindData != null)
  12454. {
  12455. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12456. designer.SetDataSource("LYJRS", leftBindData.rs);
  12457. designer.SetDataSource("LYJXS", leftBindData.xs);
  12458. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12459. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12460. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12461. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12462. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12463. }
  12464. else
  12465. {
  12466. hideRowsList.Add(Row + startIndex + HideRows);
  12467. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12468. }
  12469. #endregion
  12470. #region A段Right信息
  12471. var right = dto.rightInfo.Find(x => x.Type == "A");
  12472. if (right == null)
  12473. {
  12474. return Ok(jw);
  12475. }
  12476. HideRows += 4;
  12477. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12478. if (rightBindData != null)
  12479. {
  12480. //经济舱 + 双人间 TBR
  12481. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12482. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12483. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12484. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12485. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12486. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12487. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12488. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12489. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12490. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12491. }
  12492. else
  12493. {
  12494. hideRowsList.Add(Row + startIndex + HideRows);
  12495. }
  12496. HideRows += 2;
  12497. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12498. if (rightBindData != null)
  12499. {
  12500. //经济舱 + 单人间 SGR
  12501. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12502. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12503. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12504. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12505. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12506. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12507. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12508. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12509. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12510. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12511. }
  12512. else
  12513. {
  12514. hideRowsList.Add(Row + startIndex + HideRows);
  12515. }
  12516. HideRows += 2;
  12517. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12518. if (rightBindData != null)
  12519. {
  12520. //公务舱 + 单人间 SGR
  12521. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12522. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12523. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12524. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12525. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12526. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12527. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12528. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12529. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12530. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12531. }
  12532. else
  12533. {
  12534. hideRowsList.Add(Row + startIndex + HideRows);
  12535. }
  12536. HideRows += 2;
  12537. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12538. if (rightBindData != null)
  12539. {
  12540. //公务舱 + 小套房 JSES
  12541. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12542. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12543. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12544. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12545. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12546. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12547. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12548. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12549. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12550. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12551. }
  12552. else
  12553. {
  12554. hideRowsList.Add(Row + startIndex + HideRows);
  12555. }
  12556. HideRows += 2;
  12557. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12558. if (rightBindData != null)
  12559. {
  12560. //公务舱 + 小套房 JSES
  12561. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12562. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12563. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12564. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12565. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12566. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12567. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12568. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12569. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12570. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12571. }
  12572. else
  12573. {
  12574. hideRowsList.Add(Row + startIndex + HideRows);
  12575. }
  12576. HideRows += 2;
  12577. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12578. if (rightBindData != null)
  12579. {
  12580. //经济舱 + 大套房
  12581. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12582. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12583. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12584. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12585. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12586. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12587. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12588. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12589. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12590. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12591. }
  12592. else
  12593. {
  12594. hideRowsList.Add(Row + startIndex + HideRows);
  12595. }
  12596. HideRows += 2;
  12597. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12598. if (rightBindData != null)
  12599. {
  12600. //头等舱 + 小套房 JSES
  12601. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12602. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12603. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12604. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12605. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12606. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12607. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12608. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12609. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12610. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12611. }
  12612. else
  12613. {
  12614. hideRowsList.Add(Row + startIndex + HideRows);
  12615. }
  12616. HideRows += 2;
  12617. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12618. if (rightBindData != null)
  12619. {
  12620. //头等舱 + 大套房
  12621. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12622. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12623. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12624. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12625. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12626. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12627. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12628. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12629. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12630. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12631. }
  12632. else
  12633. {
  12634. hideRowsList.Add(Row + startIndex + HideRows);
  12635. }
  12636. #endregion
  12637. #region B段标题清空
  12638. designer.SetDataSource("CostBDRCB", "");
  12639. designer.SetDataSource("CostBRS", "");
  12640. designer.SetDataSource("CostBXS", "");
  12641. designer.SetDataSource("CostBZCB", "");
  12642. designer.SetDataSource("CostBDRBJ", "");
  12643. designer.SetDataSource("CostBZBJ", "");
  12644. designer.SetDataSource("CostBDRLR", "");
  12645. designer.SetDataSource("CostBZLR", "");
  12646. designer.SetDataSource("CostBDRCBOM", "");
  12647. designer.SetDataSource("CostBRSOM", "");
  12648. designer.SetDataSource("CostBZCBOM", "");
  12649. designer.SetDataSource("CostBDRBJOM", "");
  12650. designer.SetDataSource("CostBZBJOM", "");
  12651. designer.SetDataSource("CostBDRLROM", "");
  12652. designer.SetDataSource("CostBZLROM", "");
  12653. #endregion
  12654. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12655. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12656. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12657. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12658. designer.SetDataSource("DJName", "地接(CNY)");
  12659. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12660. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12661. designer.SetDataSource("GWName", "公务(CNY)");
  12662. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12663. designer.SetDataSource("LYJName", "零用金(CNY)");
  12664. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12665. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12666. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12667. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12668. designer.SetDataSource("BXName", "保险(CNY)");
  12669. designer.SetDataSource("VisaName", "签证(CNY)");
  12670. #region B段基本数据
  12671. if (dto.costType == "B")
  12672. {
  12673. left = dto.leftInfo.Find(x => x.Type == "B");
  12674. if (left == null)
  12675. {
  12676. return Ok(jw);
  12677. }
  12678. #region B段left数据
  12679. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12680. if (leftBindData != null)
  12681. {
  12682. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12683. designer.SetDataSource("BHSRS", leftBindData.rs);
  12684. designer.SetDataSource("BHSXS", leftBindData.xs);
  12685. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12686. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12687. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12688. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12689. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12690. }
  12691. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12692. if (leftBindData != null)
  12693. {
  12694. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12695. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12696. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12697. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12698. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12699. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12700. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12701. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12702. }
  12703. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12704. if (leftBindData != null)
  12705. {
  12706. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12707. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12708. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12709. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12710. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12711. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12712. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12713. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12714. }
  12715. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12716. if (leftBindData != null)
  12717. {
  12718. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12719. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12720. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12721. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12722. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12723. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12724. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12725. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12726. }
  12727. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12728. if (leftBindData != null)
  12729. {
  12730. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12731. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12732. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12733. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12734. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12735. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12736. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12737. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12738. }
  12739. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12740. if (leftBindData != null)
  12741. {
  12742. designer.SetDataSource("BCPCB", leftBindData.cb);
  12743. designer.SetDataSource("BCPRS", leftBindData.rs);
  12744. designer.SetDataSource("BCPXS", leftBindData.xs);
  12745. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12746. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12747. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12748. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12749. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12750. }
  12751. //TBR
  12752. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12753. if (leftBindData != null)
  12754. {
  12755. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12756. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12757. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12758. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12759. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12760. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12761. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12762. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12763. }
  12764. //SGR
  12765. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12766. if (leftBindData != null)
  12767. {
  12768. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12769. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12770. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12771. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12772. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12773. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12774. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12775. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12776. }
  12777. //JS/ES
  12778. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12779. if (leftBindData != null)
  12780. {
  12781. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12782. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12783. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12784. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12785. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12786. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12787. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12788. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12789. }
  12790. //SUITE
  12791. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12792. if (leftBindData != null)
  12793. {
  12794. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12795. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12796. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12797. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12798. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12799. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12800. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12801. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12802. }
  12803. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12804. if (leftBindData != null)
  12805. {
  12806. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12807. designer.SetDataSource("BDJRS", leftBindData.rs);
  12808. designer.SetDataSource("BDJXS", leftBindData.xs);
  12809. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12811. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12812. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12813. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12814. }
  12815. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12816. if (leftBindData != null)
  12817. {
  12818. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12819. designer.SetDataSource("BGWRS", leftBindData.rs);
  12820. designer.SetDataSource("BGWXS", leftBindData.xs);
  12821. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12822. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12823. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12824. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12825. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12826. }
  12827. #region 优化方案
  12828. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12829. //excelBind.Add("零用金", new {
  12830. //cb="",
  12831. //rs="",
  12832. //xs ="",
  12833. //zcb = "",
  12834. //});
  12835. #endregion
  12836. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12837. if (leftBindData != null)
  12838. {
  12839. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12840. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12841. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12842. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12843. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12844. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12845. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12846. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12847. }
  12848. #endregion
  12849. #region B段Right信息
  12850. right = dto.rightInfo.Find(x => x.Type == "B");
  12851. if (right == null)
  12852. {
  12853. return Ok(jw);
  12854. }
  12855. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12856. if (rightBindData != null)
  12857. {
  12858. //经济舱 + 双人间 TBR
  12859. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12860. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12861. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12862. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12863. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12864. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12865. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12866. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12867. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12868. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12869. }
  12870. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12871. if (rightBindData != null)
  12872. {
  12873. //经济舱 + 单人间 SGR
  12874. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12875. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12876. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12877. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12878. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12879. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12880. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12881. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12882. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12883. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12884. }
  12885. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12886. if (rightBindData != null)
  12887. {
  12888. //公务舱 + 单人间 SGR
  12889. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12890. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12891. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12892. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12893. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12894. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12895. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12896. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12897. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12898. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12899. }
  12900. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12901. if (rightBindData != null)
  12902. {
  12903. //公务舱 + 小套房 JSES
  12904. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12905. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12906. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12907. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12908. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12909. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12910. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12911. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12912. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12913. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12914. }
  12915. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12916. if (rightBindData != null)
  12917. {
  12918. //公务舱 + 小套房 JSES
  12919. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12920. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12921. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12922. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12923. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12924. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12925. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12926. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12927. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12928. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12929. }
  12930. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12931. if (rightBindData != null)
  12932. {
  12933. //经济舱 + 大套房
  12934. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12935. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12936. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12937. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12938. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12939. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12940. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12941. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12942. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12943. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12944. }
  12945. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12946. if (rightBindData != null)
  12947. {
  12948. //头等舱 + 小套房 JSES
  12949. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12950. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12951. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12952. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12953. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12954. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12955. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12956. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12957. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12958. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12959. }
  12960. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12961. if (rightBindData != null)
  12962. {
  12963. //头等舱 + 大套房
  12964. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12965. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12966. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12967. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12968. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12969. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12970. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12971. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12972. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12973. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12974. }
  12975. #endregion
  12976. #region 标题
  12977. designer.SetDataSource("CostBDRCB", "单人成本");
  12978. designer.SetDataSource("CostBRS", "人数");
  12979. designer.SetDataSource("CostBXS", "系数");
  12980. designer.SetDataSource("CostBZCB", "总成本");
  12981. designer.SetDataSource("CostBDRBJ", "单人报价");
  12982. designer.SetDataSource("CostBZBJ", "总报价");
  12983. designer.SetDataSource("CostBDRLR", "单人利润");
  12984. designer.SetDataSource("CostBZLR", "总利润");
  12985. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12986. designer.SetDataSource("CostBRSOM", "人数");
  12987. designer.SetDataSource("CostBZCBOM", "总成本");
  12988. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12989. designer.SetDataSource("CostBZBJOM", "总报价");
  12990. designer.SetDataSource("CostBDRLROM", "单人利润");
  12991. designer.SetDataSource("CostBZLROM", "总利润");
  12992. #endregion
  12993. }
  12994. #endregion
  12995. designer.SetDataSource("TzZCB2", TzZCB2);
  12996. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12997. designer.SetDataSource("TzZLR2", TzZLR2);
  12998. string[] dataSourceKeys = new string[]
  12999. {
  13000. "VF",
  13001. "TGS",
  13002. "TGOF",
  13003. "TGM",
  13004. "TGA",
  13005. "TGTF",
  13006. "TGEF",
  13007. "CFM",
  13008. "CFOF",
  13009. "B",
  13010. "L",
  13011. "D",
  13012. "TBR",
  13013. "SGR",
  13014. "JSES",
  13015. "Suite",
  13016. "TV",
  13017. "1L",
  13018. "IF",
  13019. "EF",
  13020. "BRF",
  13021. "TE",
  13022. "TGT",
  13023. "DRVT",
  13024. "PC",
  13025. "TLF",
  13026. "ECT"
  13027. };
  13028. foreach (var item in dataSourceKeys)
  13029. {
  13030. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13031. if (find != null)
  13032. {
  13033. designer.SetDataSource(item, find.text);
  13034. }
  13035. else
  13036. {
  13037. designer.SetDataSource(item, 0);
  13038. }
  13039. }
  13040. designer.SetDataSource(dt);
  13041. //根据数据源处理生成报表内容
  13042. designer.Process();
  13043. designer.Workbook.Worksheets[0].Name = "清单";
  13044. Worksheet sheet = designer.Workbook.Worksheets[0];
  13045. foreach (var Rowindex in hideRowsList)
  13046. {
  13047. ws.Cells.HideRows(Rowindex, 2);
  13048. }
  13049. byte[] bytes = null;
  13050. string strFileName = di.TeamName + "-团组-成本.xls";
  13051. using (MemoryStream stream = new MemoryStream())
  13052. {
  13053. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13054. bytes = stream.ToArray();
  13055. }
  13056. return Ok(JsonView(true, "", new
  13057. {
  13058. Data = bytes,
  13059. strFileName,
  13060. }));
  13061. }
  13062. /// <summary>
  13063. /// 导出客户报表
  13064. /// </summary>
  13065. /// <returns></returns>
  13066. [HttpPost]
  13067. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13068. {
  13069. var jw = JsonView(false);
  13070. if (dto.Diid == 0)
  13071. {
  13072. return Ok(JsonView(false, "请传递团组id"));
  13073. }
  13074. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13075. if (deleInfo.Code != 0)
  13076. {
  13077. return Ok(JsonView(false, "团组信息查询失败!"));
  13078. }
  13079. var di = deleInfo.Data as DelegationInfoWebView;
  13080. if (di == null)
  13081. {
  13082. return Ok(JsonView(false, "团组信息查询失败!"));
  13083. }
  13084. //文件名
  13085. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13086. //获取模板
  13087. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13088. //载入模板
  13089. Document doc = new Document(tmppath);
  13090. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13091. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13092. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13093. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13094. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13095. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13096. if (AParameter == null)
  13097. {
  13098. return Ok(JsonView(false, "系数不存在!"));
  13099. }
  13100. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13101. , TzAirDesc, TzZCost;
  13102. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13103. = TzAirDesc = TzZCost = string.Empty;
  13104. TzNumber = AParameter.CostTypenumber.ToString();
  13105. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13106. CarGuides1 = dto.CarGuides1;
  13107. Meal = dto.Meal;
  13108. SubsidizedMeals = dto.SubsidizedMeals;
  13109. NightRepair = dto.NightRepair;
  13110. AttractionsTickets = dto.AttractionsTickets;
  13111. MiscellaneousFees = dto.MiscellaneousFees;
  13112. ATip = dto.ATip;
  13113. TzHotelDesc = "";
  13114. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13115. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13116. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13117. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13118. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13119. TzAirDesc = "";
  13120. TzZCost = dto.TzZCost;
  13121. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13122. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13123. var index = 1;
  13124. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13125. foreach (var item in TzHotelDescArr)
  13126. {
  13127. if (AinfoArr != null)
  13128. {
  13129. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13130. if (Ainfo != null)
  13131. {
  13132. if (int.Parse(Ainfo.rs) <= 0)
  13133. {
  13134. continue;
  13135. }
  13136. var hotelText = string.Empty;
  13137. switch (item)
  13138. {
  13139. case "SGR":
  13140. hotelText = "单人间";
  13141. break;
  13142. case "JSES":
  13143. hotelText = "小套房";
  13144. break;
  13145. case "SUITE":
  13146. hotelText = "套房";
  13147. break;
  13148. case "TBR":
  13149. hotelText = "双人间";
  13150. break;
  13151. }
  13152. if (item != "TBR")
  13153. {
  13154. 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";
  13155. }
  13156. else
  13157. {
  13158. 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";
  13159. }
  13160. index++;
  13161. }
  13162. }
  13163. }
  13164. index = 1;
  13165. foreach (var item in TzAirDescArr)
  13166. {
  13167. if (AinfoArr != null)
  13168. {
  13169. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13170. if (Ainfo != null)
  13171. {
  13172. if (int.Parse(Ainfo.rs) <= 0)
  13173. {
  13174. continue;
  13175. }
  13176. 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";
  13177. index++;
  13178. }
  13179. }
  13180. }
  13181. if (dto.costType == "B")
  13182. {
  13183. if (BParameter == null)
  13184. {
  13185. return Ok(JsonView(false, "B段系数不存在!"));
  13186. }
  13187. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13188. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13189. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13190. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13191. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13192. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13193. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13194. foreach (var item in TzHotelDescArr)
  13195. {
  13196. if (AinfoArr != null)
  13197. {
  13198. TzHotelDesc += "B段信息 \r\n";
  13199. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13200. if (Ainfo != null)
  13201. {
  13202. if (int.Parse(Ainfo.rs) <= 0)
  13203. {
  13204. continue;
  13205. }
  13206. var hotelText = string.Empty;
  13207. switch (item)
  13208. {
  13209. case "SGR":
  13210. hotelText = "单人间";
  13211. break;
  13212. case "JSES":
  13213. hotelText = "小套房";
  13214. break;
  13215. case "SUITE":
  13216. hotelText = "套房";
  13217. break;
  13218. case "TBR":
  13219. hotelText = "双人间";
  13220. break;
  13221. }
  13222. if (item != "TBR")
  13223. {
  13224. 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";
  13225. }
  13226. else
  13227. {
  13228. 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";
  13229. }
  13230. index++;
  13231. }
  13232. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13233. }
  13234. }
  13235. index = 1;
  13236. foreach (var item in TzAirDescArr)
  13237. {
  13238. if (AinfoArr != null)
  13239. {
  13240. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13241. if (Ainfo != null)
  13242. {
  13243. if (int.Parse(Ainfo.rs) <= 0)
  13244. {
  13245. continue;
  13246. }
  13247. 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";
  13248. index++;
  13249. }
  13250. }
  13251. }
  13252. }
  13253. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13254. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13255. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13256. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13257. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13258. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13259. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13260. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13261. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13262. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13263. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13264. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13265. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13266. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13267. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13268. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13269. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13270. DickeyValue.Add("TzZCost", TzZCost);
  13271. foreach (var key in DickeyValue.Keys)
  13272. {
  13273. if (doc.Range.Bookmarks[key] != null)
  13274. {
  13275. Bookmark mark = doc.Range.Bookmarks[key];
  13276. mark.Text = DickeyValue[key];
  13277. }
  13278. }
  13279. byte[] bytes = null;
  13280. string strFileName = di.TeamName + "-客户报价.doc";
  13281. using (MemoryStream stream = new MemoryStream())
  13282. {
  13283. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13284. bytes = stream.ToArray();
  13285. }
  13286. return Ok(JsonView(true, "", new
  13287. {
  13288. Data = bytes,
  13289. strFileName,
  13290. }));
  13291. }
  13292. /// <summary>
  13293. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13294. /// </summary>
  13295. /// <param name="dto"></param>
  13296. /// <returns></returns>
  13297. [HttpPost]
  13298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13299. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13300. {
  13301. try
  13302. {
  13303. #region 参数验证
  13304. if (dto.DiId < 0)
  13305. {
  13306. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13307. }
  13308. List<int> cTableIds = new List<int>() {
  13309. 76 ,//酒店预订
  13310. 77 ,//行程
  13311. 79 ,//车/导游地接
  13312. 80 ,//签证
  13313. 81 ,//邀请/公务活
  13314. 82 ,//团组客户保险
  13315. 85 ,//机票预订
  13316. 98 ,//其他款项
  13317. 285 ,//收款退还
  13318. 751 ,//酒店早餐
  13319. 1015 // 超支费用
  13320. };
  13321. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13322. {
  13323. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13324. }
  13325. #endregion
  13326. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13327. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13328. if (_GroupCostParameters.Count <= 0)
  13329. {
  13330. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13331. }
  13332. if (_GroupCostParameters[0].IsShare == 0)
  13333. {
  13334. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13335. }
  13336. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13337. //处理date为空问题
  13338. if (_GroupCosts.Count > 0)
  13339. {
  13340. for (int i = 0; i < _GroupCosts.Count; i++)
  13341. {
  13342. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13343. {
  13344. if (i > 0)
  13345. {
  13346. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13347. }
  13348. }
  13349. }
  13350. }
  13351. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13352. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13353. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13354. string currCode = "";
  13355. #region currCode 验证
  13356. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13357. if (isInt)
  13358. {
  13359. var currData = currDatas.Find(it => it.Id == intCurrency);
  13360. if (currData != null)
  13361. {
  13362. currCode = currData.Name;
  13363. }
  13364. }
  13365. else
  13366. {
  13367. currCode = _GroupCostParameters[0].Currency.Trim();
  13368. }
  13369. #endregion
  13370. //op,酒店单段模式存储
  13371. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13372. {
  13373. CurrencyCode = currCode,
  13374. Rate = _GroupCostParameters[0].Rate,
  13375. CostType = _GroupCostParameters[0].CostType,
  13376. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13377. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13378. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13379. };
  13380. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13381. if (_GroupCostParameters.Count == 2)
  13382. {
  13383. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13384. }
  13385. foreach (var item in _GroupCostParameters)
  13386. {
  13387. decimal _rate = 1;
  13388. decimal _rate1 = item.Rate;
  13389. decimal _scale = 1;
  13390. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13391. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13392. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13393. //if (userInfo != null)
  13394. //{
  13395. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13396. // {
  13397. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13398. // {
  13399. // _scale = 1.00M;
  13400. // }
  13401. // }
  13402. //}
  13403. #endregion
  13404. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13405. {
  13406. CurrencyCode = currCode,
  13407. Rate = _rate1,
  13408. CostType = item.CostType,
  13409. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13410. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13411. CostTypeNumber = item.CostTypenumber
  13412. };
  13413. if (_GroupCostParameters.Count > 1)
  13414. {
  13415. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13416. }
  13417. else
  13418. {
  13419. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13420. }
  13421. if (dto.CTable == 79)//
  13422. {
  13423. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13424. modulePromptInfo.TotalCost = item.DJCB;
  13425. }
  13426. List<string> costTypes = new List<string>() { "A", "B" };
  13427. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13428. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13429. if (_GroupCostsDuplicates.Count() == 1)
  13430. {
  13431. _GroupCostsTypeData = _GroupCosts;
  13432. }
  13433. else
  13434. {
  13435. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13436. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13437. }
  13438. /*
  13439. * 76 酒店预订
  13440. * 77 行程
  13441. * 79 车/导游地接
  13442. * 80 签证
  13443. * 81 邀请/公务活动
  13444. * 82 团组客户保险
  13445. * 85 机票预订
  13446. * 98 其他款项
  13447. * 285 收款退还
  13448. * 751 酒店早餐
  13449. * 1015 超支费用
  13450. */
  13451. switch (dto.CTable)
  13452. {
  13453. case 76: // 酒店预订
  13454. _ModuleSubPromptInfo.AddRange(
  13455. _GroupCostsTypeData.Select(it => new
  13456. {
  13457. it.DAY,
  13458. it.Date,
  13459. it.ACCON,
  13460. it.ITIN,
  13461. it.SGR,
  13462. it.TBR,
  13463. it.JS_ES,
  13464. it.Suite
  13465. })
  13466. );
  13467. break;
  13468. case 79: // 车/导游地接
  13469. _ModuleSubPromptInfo.AddRange(
  13470. _GroupCostsTypeData.Select(it => new
  13471. {
  13472. Date = it.Date, //日期
  13473. CarFee = it.CarCost * _rate * _scale, //车费用
  13474. CarType = it.CarType, //车型
  13475. DriverFee = it.CFS * _rate * _scale, //司机工资
  13476. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13477. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13478. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13479. GuideFee = it.TGS * _rate * _scale, //导游费用
  13480. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13481. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13482. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13483. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13484. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13485. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13486. Breakfast = it.B * _rate * _scale, //早餐费
  13487. Lunch = it.L * _rate * _scale, //午餐费
  13488. Dinner = it.D * _rate * _scale, //晚餐费
  13489. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13490. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13491. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13492. TicketFee = it.EF * _rate * _scale, //门票费
  13493. TicketRemark = it.EFR, //门票费描述
  13494. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13495. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13496. SpentCash = it.PC * _rate * _scale, //零用金
  13497. LeadersFee = it.TLF * _rate * _scale, //领队费
  13498. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13499. })
  13500. );
  13501. break;
  13502. case 85: // 机票
  13503. List<dynamic> datas = new List<dynamic>();
  13504. datas.Add(
  13505. new
  13506. {
  13507. AirType = "经济舱",
  13508. AirNum = item.JJCRS,
  13509. AirDRCB = item.JJCCB,
  13510. AirZCB = (item.JJCRS * item.JJCCB)
  13511. }
  13512. );
  13513. datas.Add(
  13514. new
  13515. {
  13516. AirType = "公务舱",
  13517. AirNum = item.GWCRS,
  13518. AirDRCB = item.GWCCB,
  13519. AirZCB = (item.GWCRS * item.GWCCB)
  13520. }
  13521. );
  13522. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13523. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13524. modulePromptInfo.Data = new
  13525. {
  13526. airFeeData = datas,
  13527. airInitData = initDatas
  13528. };
  13529. _ModulePromptInfos.Add(modulePromptInfo);
  13530. break;
  13531. default:
  13532. break;
  13533. }
  13534. }
  13535. if (dto.CTable != 85)
  13536. {
  13537. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13538. _ModulePromptInfos.Add(_ModulePromptInfo);
  13539. }
  13540. _view.ModulePromptInfos = _ModulePromptInfos;
  13541. return Ok(JsonView(true, "操作成功!", _view));
  13542. }
  13543. catch (Exception ex)
  13544. {
  13545. return Ok(JsonView(false, ex.Message));
  13546. }
  13547. }
  13548. /// <summary>
  13549. /// 根据黑屏代码重新生成行程
  13550. /// </summary>
  13551. /// <param name="dto"></param>
  13552. /// <returns></returns>
  13553. [HttpPost]
  13554. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13555. {
  13556. var jw = JsonView(false);
  13557. var Create = _GroupCostRepository.
  13558. CreateGroupCostByBlackCode(dto.Diid);
  13559. jw.Msg = Create.Msg;
  13560. if (Create.Code == 0)
  13561. {
  13562. jw.Code = 200;
  13563. jw.Data = new
  13564. {
  13565. groupCost = Create.Data,
  13566. blackCodeIsTrue = true
  13567. };
  13568. }
  13569. else
  13570. {
  13571. jw.Code = 400;
  13572. jw.Data = new
  13573. {
  13574. groupCost = Create.Data,
  13575. blackCodeIsTrue = false,
  13576. };
  13577. }
  13578. return Ok(jw);
  13579. }
  13580. /// <summary>
  13581. /// 成本获取OP历史车费用
  13582. /// </summary>
  13583. /// <param name="dto"></param>
  13584. /// <returns></returns>
  13585. [HttpPost]
  13586. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13587. {
  13588. var jw = JsonView(false);
  13589. try
  13590. {
  13591. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13592. //获取现有所有车的数据
  13593. if (!dto.Param.IsNullOrWhiteSpace())
  13594. {
  13595. string sql = $@"
  13596. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13597. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13598. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13599. 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
  13600. AND gctggr.ServiceEndTime is not NULL
  13601. ORDER by gctggrc.id DESC
  13602. ";
  13603. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13604. var numeberResult = await Task.Run(() =>
  13605. {
  13606. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13607. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13608. return numberArr;
  13609. });
  13610. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13611. foreach (var item in numeberResult)
  13612. {
  13613. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13614. {
  13615. Country = "数据异常!",
  13616. City = string.Empty,
  13617. };
  13618. item.Area = find.Country + " " + find.City;
  13619. }
  13620. dbResult.AddRange(numeberResult);
  13621. if (dto.Param.Contains("、"))
  13622. {
  13623. var sp = dto.Param.Split("、");
  13624. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13625. .Where(x =>
  13626. {
  13627. return System.Array.Exists(sp, e =>
  13628. {
  13629. bool where = false;
  13630. if (x.Area != null)
  13631. {
  13632. where = x.Area.Contains(e);
  13633. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13634. {
  13635. return false;
  13636. }
  13637. }
  13638. if (x.PriceName != null && !where)
  13639. {
  13640. where = x.PriceName.Contains(e);
  13641. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13642. {
  13643. return false;
  13644. }
  13645. }
  13646. return where;
  13647. });
  13648. }).ToList();
  13649. }
  13650. else
  13651. {
  13652. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13653. .Where(x =>
  13654. {
  13655. bool where = false;
  13656. if (x.Area != null)
  13657. {
  13658. where = x.Area.Contains(dto.Param);
  13659. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13660. {
  13661. return false;
  13662. }
  13663. }
  13664. if (x.PriceName != null && !where)
  13665. {
  13666. where = x.PriceName.Contains(dto.Param);
  13667. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13668. {
  13669. return false;
  13670. }
  13671. }
  13672. return where;
  13673. }
  13674. )
  13675. .ToList();
  13676. }
  13677. }
  13678. var view = dbResult.Select(x =>
  13679. {
  13680. decimal dp = 0.00M;
  13681. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13682. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13683. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13684. {
  13685. if (startB && endB)
  13686. {
  13687. var timesp = endD.Subtract(startD);
  13688. if ((timesp.Days + 1) != 0)
  13689. {
  13690. dp = x.Price / (timesp.Days + 1);
  13691. }
  13692. }
  13693. }
  13694. else
  13695. {
  13696. dp = x.Price;
  13697. }
  13698. return new
  13699. {
  13700. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13701. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13702. x.Area,
  13703. x.id,
  13704. price = x.Price.ToString("F2"),
  13705. x.PriceName,
  13706. x.PriceContent,
  13707. x.TeamName,
  13708. x.DatePrice,
  13709. dayPrice = dp.ToString("F2"),
  13710. };
  13711. }).OrderByDescending(x => x.id).ToList();
  13712. jw = JsonView(true, "获取成功!", view);
  13713. }
  13714. catch (Exception e)
  13715. {
  13716. jw = JsonView(false, e.Message);
  13717. }
  13718. return Ok(jw);
  13719. }
  13720. #endregion
  13721. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13722. /// <summary>
  13723. /// 酒店预订
  13724. /// 酒店费用列表 根据团组Id查询
  13725. /// </summary>
  13726. /// <param name="_dto"></param>
  13727. /// <returns></returns>
  13728. [HttpPost]
  13729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13730. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13731. {
  13732. #region 参数验证
  13733. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13734. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13735. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13736. #region 团组操作权限验证 76 酒店预定模块
  13737. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13738. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13739. #endregion
  13740. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13741. #region 页面操作权限验证
  13742. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13743. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13744. #endregion
  13745. #endregion
  13746. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13747. }
  13748. /// <summary>
  13749. /// 酒店预订
  13750. /// 基础数据
  13751. /// </summary>
  13752. /// <param name="_dto"></param>
  13753. /// <returns></returns>
  13754. [HttpPost]
  13755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13756. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13757. {
  13758. #region 参数验证
  13759. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13760. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13761. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13762. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13763. #region 页面操作权限验证
  13764. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13765. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13766. #endregion
  13767. #region 团组操作权限验证 76 酒店预定模块
  13768. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13769. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13770. #endregion
  13771. #endregion
  13772. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13773. }
  13774. /// <summary>
  13775. /// 酒店预订
  13776. /// 创建 入住卷号码
  13777. /// </summary>
  13778. /// <param name="_dto"></param>
  13779. /// <returns></returns>
  13780. [HttpPost]
  13781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13782. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13783. {
  13784. #region 参数验证
  13785. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13786. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13787. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13788. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13789. #region 页面操作权限验证
  13790. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13791. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13792. #endregion
  13793. #region 团组操作权限验证 76 酒店预定模块
  13794. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13795. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13796. #endregion
  13797. #endregion
  13798. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13799. if (data.Code != 0)
  13800. {
  13801. return Ok(JsonView(false, data.Msg));
  13802. }
  13803. return Ok(JsonView(true, data.Msg, data.Data));
  13804. }
  13805. /// <summary>
  13806. /// 酒店预订
  13807. /// 详情
  13808. /// </summary>
  13809. /// <param name="_dto"></param>
  13810. /// <returns></returns>
  13811. [HttpPost]
  13812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13813. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13814. {
  13815. #region 参数验证
  13816. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13817. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13818. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13819. #region 团组操作权限验证 76 酒店预定模块
  13820. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13821. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13822. #endregion
  13823. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13824. #region 页面操作权限验证
  13825. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13826. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13827. #endregion
  13828. #endregion
  13829. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13830. }
  13831. /// <summary>
  13832. /// 酒店预订
  13833. /// Add Or Edit
  13834. /// </summary>
  13835. /// <param name="_dto"></param>
  13836. /// <returns></returns>
  13837. [HttpPost]
  13838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13839. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13840. {
  13841. #region 参数验证
  13842. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13843. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13844. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13845. #region 团组操作权限验证 76 酒店预定模块
  13846. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13847. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13848. #endregion
  13849. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13850. #region 页面操作权限验证
  13851. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13852. if (_dto.Id == 0) // Add
  13853. {
  13854. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13855. }
  13856. else if (_dto.Id > 1) // Edit
  13857. {
  13858. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13859. }
  13860. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13861. #endregion
  13862. #endregion
  13863. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13864. if (_view.Code != 200)
  13865. {
  13866. return Ok(_view);
  13867. }
  13868. #region 成本无酒店价格数据进入超支
  13869. _sqlSugar.BeginTran();
  13870. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13871. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13872. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13873. for (int i = 0; i < groupCost.Count; i++)
  13874. {
  13875. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13876. {
  13877. groupCost[i].Date = groupCost[i - 1].Date;
  13878. }
  13879. }
  13880. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13881. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13882. List<Fin_GroupExtraCostDto_OP>();
  13883. if (start_Bool && end_Bool)
  13884. {
  13885. while (start_Time < end_Time)
  13886. {
  13887. foreach (var item in groupCost_Grp)
  13888. {
  13889. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13890. {
  13891. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13892. {
  13893. extraCostList.Add(new
  13894. Fin_GroupExtraCostDto_OP
  13895. {
  13896. Area = _dto.AreaId,
  13897. coefficient = 1.5M,
  13898. createUser = _dto.UserId,
  13899. currency = _dto.CardPriceCurrency,
  13900. diId = _dto.DiId,
  13901. ManagerConfirm = 0,
  13902. SupervisorConfirm = 0,
  13903. SYsupervisorConfirm = 0,
  13904. editType = 1,
  13905. PortType = 1,
  13906. price = _dto.CardPrice,
  13907. PriceCount = 1,
  13908. priceType = 1027,
  13909. priceDetailType = 1044,
  13910. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13911. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13912. });
  13913. }
  13914. }
  13915. }
  13916. start_Time = start_Time.AddDays(1);
  13917. }
  13918. }
  13919. if (extraCostList.Any())
  13920. {
  13921. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13922. }
  13923. _sqlSugar.CommitTran();
  13924. #endregion
  13925. #region 应用推送
  13926. try
  13927. {
  13928. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13929. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13930. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13931. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13932. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13933. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13934. var diId = _dto.DiId;
  13935. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13936. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13937. #region 操作记录
  13938. var opInfo = new Crm_TableOperationRecord()
  13939. {
  13940. TableName = "Grp_HotelReservations",
  13941. PortType = _dto.PortType,
  13942. DataId = hotelId,
  13943. CreateUserId = _dto.UserId
  13944. };
  13945. //var opStatus = OperationEnum.NoOperation;
  13946. if (_dto.Id < 1) //添加操作
  13947. {
  13948. opInfo.OperationItem = OperationEnum.Add;
  13949. }
  13950. else if (_dto.Id > 0)
  13951. {
  13952. opInfo.OperationItem = OperationEnum.Edit;
  13953. }
  13954. string opRemark = string.Empty;
  13955. if (ccpInfo != null)
  13956. {
  13957. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13958. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13959. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13960. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13961. }
  13962. opInfo.Remark = opRemark;
  13963. await _tableorRep.AddAsync(opInfo);
  13964. #endregion
  13965. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13966. //2024-10-21 新增LZ UID
  13967. var userIds = new List<int>() { 21 };
  13968. string title = $"费用审核";
  13969. string content = "";
  13970. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13971. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13972. try
  13973. {
  13974. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13975. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13976. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13977. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13978. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13979. }
  13980. catch (Exception ex)
  13981. {
  13982. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13983. }
  13984. }
  13985. catch (Exception ex)
  13986. {
  13987. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13988. }
  13989. try
  13990. {
  13991. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13992. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13993. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13994. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13995. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13996. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13997. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13998. //自动审核
  13999. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14000. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14001. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14002. //2024-10-21 新增LZ UID
  14003. var userIds = new List<int>() { 21 };
  14004. string title = $"系统通知";
  14005. var diId = _dto.DiId;
  14006. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14007. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14008. string content = "";
  14009. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14010. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14011. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14012. }
  14013. catch (Exception ex)
  14014. {
  14015. }
  14016. #endregion
  14017. return Ok(_view);
  14018. }
  14019. /// <summary>
  14020. /// 酒店自动审核测试
  14021. /// Add Or Edit
  14022. /// </summary>
  14023. /// <param name="diid"></param>
  14024. /// <param name="dataId"></param>
  14025. /// <returns></returns>
  14026. [HttpPost]
  14027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14028. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14029. {
  14030. #region 应用推送
  14031. try
  14032. {
  14033. //自动审核
  14034. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14035. }
  14036. catch (Exception ex)
  14037. {
  14038. return Ok(JsonView(false, "操作失败"));
  14039. }
  14040. #endregion
  14041. return Ok(JsonView(false, "操作成功"));
  14042. }
  14043. /// <summary>
  14044. /// 酒店预订
  14045. /// Del
  14046. /// </summary>
  14047. /// <param name="_dto"></param>
  14048. /// <returns></returns>
  14049. [HttpPost]
  14050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14051. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14052. {
  14053. #region 参数验证
  14054. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14055. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14056. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14057. #region 团组操作权限验证 76 酒店预定模块
  14058. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14059. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14060. #endregion
  14061. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14062. #region 页面操作权限验证
  14063. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14064. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14065. #endregion
  14066. #endregion
  14067. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14068. #region 操作记录
  14069. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14070. {
  14071. TableName = "Grp_HotelReservations",
  14072. PortType = _dto.PortType,
  14073. OperationItem = OperationEnum.Del,
  14074. DataId = _dto.Id,
  14075. CreateUserId = _dto.UserId
  14076. });
  14077. #endregion
  14078. return Ok(data);
  14079. }
  14080. /// <summary>
  14081. /// 酒店预订
  14082. /// 生成VOUCHER
  14083. /// 2024.05.06 之前版本
  14084. /// </summary>
  14085. /// <param name="_dto"></param>
  14086. /// <returns></returns>
  14087. [HttpPost]
  14088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14089. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14090. {
  14091. try
  14092. {
  14093. #region 参数验证
  14094. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14095. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14096. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14097. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14098. #region 团组操作权限验证 76 酒店预定模块
  14099. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14100. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14101. #endregion
  14102. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14103. #region 页面操作权限验证
  14104. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14105. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14106. #endregion
  14107. #endregion
  14108. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14109. //判断数据是否完整
  14110. if (hr != null)
  14111. {
  14112. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14113. {
  14114. string strFileName = "HotelStatement/";
  14115. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14116. if (dele != null)
  14117. strFileName += dele.TourCode;
  14118. //载入模板
  14119. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14120. Document doc = new Document(sss);
  14121. DocumentBuilder builder = new DocumentBuilder(doc);
  14122. #region 替换Word模板书签内容
  14123. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14124. //入住卷预定号码
  14125. if (doc.Range.Bookmarks["VNO"] != null)
  14126. {
  14127. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14128. mark.Text = hr.CheckNumber;
  14129. }
  14130. //酒店时间
  14131. if (doc.Range.Bookmarks["Date"] != null)
  14132. {
  14133. Bookmark mark = doc.Range.Bookmarks["Date"];
  14134. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14135. }
  14136. //团号
  14137. if (doc.Range.Bookmarks["TNo"] != null)
  14138. {
  14139. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14140. mark.Text = dele.TourCode;
  14141. }
  14142. //预定号码
  14143. if (doc.Range.Bookmarks["BookingId"] != null)
  14144. {
  14145. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14146. mark.Text = hr.ReservationsNo;
  14147. }
  14148. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14149. {
  14150. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14151. mark.Text = hr.DetermineNo;
  14152. }
  14153. //酒店城市
  14154. if (doc.Range.Bookmarks["City"] != null)
  14155. {
  14156. Bookmark mark = doc.Range.Bookmarks["City"];
  14157. mark.Text = hr.City;
  14158. }
  14159. //酒店名称
  14160. if (doc.Range.Bookmarks["HName"] != null)
  14161. {
  14162. Bookmark mark = doc.Range.Bookmarks["HName"];
  14163. mark.Text = hr.HotelName;
  14164. }
  14165. //酒店地址
  14166. if (doc.Range.Bookmarks["Address"] != null)
  14167. {
  14168. Bookmark mark = doc.Range.Bookmarks["Address"];
  14169. mark.Text = hr.HotelAddress;
  14170. }
  14171. //酒店电话
  14172. if (doc.Range.Bookmarks["Tel"] != null)
  14173. {
  14174. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14175. mark.Text = hr.HotelTel;
  14176. }
  14177. //酒店传真
  14178. if (doc.Range.Bookmarks["Fax"] != null)
  14179. {
  14180. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14181. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14182. {
  14183. mark.Text = hr.HotelFax;
  14184. }
  14185. }
  14186. //入住时间
  14187. if (doc.Range.Bookmarks["CIn"] != null)
  14188. {
  14189. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14190. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14191. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14192. }
  14193. //退房时间
  14194. if (doc.Range.Bookmarks["COut"] != null)
  14195. {
  14196. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14197. Bookmark mark = doc.Range.Bookmarks["COut"];
  14198. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14199. }
  14200. //客户名称
  14201. if (doc.Range.Bookmarks["GName"] != null)
  14202. {
  14203. string guestName = "";
  14204. string[] clients = new string[] { };
  14205. if (hr.GuestName.Contains(","))
  14206. {
  14207. clients = hr.GuestName.Split(",");
  14208. }
  14209. else
  14210. {
  14211. clients = new string[] { hr.GuestName };
  14212. }
  14213. List<int> clientIds_int = new List<int>();
  14214. if (clients.Length > 0)
  14215. {
  14216. foreach (var item in clients)
  14217. {
  14218. if (item.IsNumeric())
  14219. {
  14220. clientIds_int.Add(int.Parse(item));
  14221. }
  14222. }
  14223. }
  14224. if (clientIds_int.Count > 0)
  14225. {
  14226. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14227. foreach (var client in _clientDatas)
  14228. {
  14229. //男
  14230. if (client.Sex == 0) guestName += $"Mr.";
  14231. //女
  14232. else if (client.Sex == 1) guestName += $"Ms.";
  14233. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14234. {
  14235. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14236. }
  14237. //guestName += $"{client.Pinyin},";
  14238. }
  14239. if (guestName.Length > 0)
  14240. {
  14241. guestName = guestName.Substring(0, guestName.Length - 1);
  14242. }
  14243. }
  14244. else
  14245. {
  14246. guestName = hr.GuestName;
  14247. }
  14248. Bookmark mark = doc.Range.Bookmarks["GName"];
  14249. mark.Text = guestName;
  14250. }
  14251. //房间介绍
  14252. if (doc.Range.Bookmarks["ROOM"] != null)
  14253. {
  14254. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14255. mark.Text = hr.RoomExplanation;
  14256. }
  14257. //报价描述
  14258. if (doc.Range.Bookmarks["NOTE"] != null)
  14259. {
  14260. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14261. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14262. if (ss != null)
  14263. mark.Text = ss.Name;
  14264. }
  14265. //入住时间
  14266. if (doc.Range.Bookmarks["CheckIn"] != null)
  14267. {
  14268. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14269. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14270. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14271. }
  14272. //退房时间
  14273. if (doc.Range.Bookmarks["CheckOut"] != null)
  14274. {
  14275. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14276. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14277. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14278. }
  14279. //日期
  14280. if (doc.Range.Bookmarks["DT"] != null)
  14281. {
  14282. Bookmark mark = doc.Range.Bookmarks["DT"];
  14283. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14284. }
  14285. //名称
  14286. if (doc.Range.Bookmarks["VName"] != null)
  14287. {
  14288. Bookmark mark = doc.Range.Bookmarks["VName"];
  14289. mark.Text = hr.HotelName;
  14290. }
  14291. //号码
  14292. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14293. {
  14294. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14295. mark.Text = hr.CheckNumber;
  14296. }
  14297. #endregion
  14298. strFileName += "VOUCHER.doc";
  14299. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14300. doc.Save(fileDir);
  14301. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14302. return Ok(JsonView(true, "操作成功!", Url));
  14303. }
  14304. else
  14305. {
  14306. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14307. }
  14308. }
  14309. else
  14310. {
  14311. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14312. }
  14313. }
  14314. catch (Exception ex)
  14315. {
  14316. return Ok(JsonView(false, ex.Message));
  14317. }
  14318. }
  14319. /// <summary>
  14320. /// 酒店预订
  14321. /// 生成VOUCHER
  14322. /// 2024.05.06 之后版本
  14323. /// </summary>
  14324. /// <param name="_dto"></param>
  14325. /// <returns></returns>
  14326. [HttpPost]
  14327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14328. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14329. {
  14330. #region 参数验证
  14331. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14332. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14333. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14334. #region 团组操作权限验证 76 酒店预定模块
  14335. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14336. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14337. #endregion
  14338. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14339. #region 页面操作权限验证
  14340. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14341. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14342. #endregion
  14343. #endregion
  14344. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14345. //判断数据是否完整
  14346. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14347. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14348. string strFileName = "HotelStatement/";
  14349. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14350. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14351. #region 数据处理
  14352. List<int> guestIds = new List<int>();
  14353. //int index = 0;
  14354. foreach (var item in hrDtas)
  14355. {
  14356. if (item.GuestName.Contains(","))
  14357. {
  14358. string[] guestIdArr = item.GuestName.Split(',');
  14359. foreach (var guestIdStr in guestIdArr)
  14360. {
  14361. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14362. if (guestBool)
  14363. {
  14364. guestIds.Add(guestId);
  14365. }
  14366. }
  14367. }
  14368. else guestNames += item.GuestName;
  14369. var voucherInfo = new HotelVoucherInfoView()
  14370. {
  14371. HotelName = item.HotelName,
  14372. CheckInDate = item.CheckInDate,
  14373. CheckOutDate = item.CheckOutDate,
  14374. ConfirmationNumber = item.DetermineNo.Trim(),
  14375. RoomType = item.RoomExplanation
  14376. };
  14377. vouchers.Add(voucherInfo);
  14378. }
  14379. if (guestIds.Count > 0)
  14380. {
  14381. guestIds = guestIds.Distinct().ToList();
  14382. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14383. if (guestDatas.Count > 0)
  14384. {
  14385. guestNames = "";
  14386. foreach (var guest in guestDatas)
  14387. {
  14388. string guestName = "";
  14389. if (guest.Sex == 0) guestName += @"MR.";
  14390. else if (guest.Sex == 1) guestName += @"MS.";
  14391. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14392. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14393. guestNames += @$"{guestName.Trim()}、";
  14394. }
  14395. if (guestNames.Length > 0)
  14396. {
  14397. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14398. }
  14399. }
  14400. }
  14401. #endregion
  14402. //载入模板
  14403. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14404. Document doc = new Document(sss);
  14405. DocumentBuilder builder = new DocumentBuilder(doc);
  14406. if (doc.Range.Bookmarks["GuestName"] != null)
  14407. {
  14408. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14409. mark.Text = guestNames;
  14410. }
  14411. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14412. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14413. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14414. for (int i = 1; i <= vouchers.Count; i++)
  14415. {
  14416. HotelVoucherInfoView hviv = vouchers[i - 1];
  14417. builder.MoveToCell(0, i, 0, 0);
  14418. builder.Write(hviv.HotelName);
  14419. builder.MoveToCell(0, i, 1, 0);
  14420. builder.Write(hviv.CheckInDate);
  14421. builder.MoveToCell(0, i, 2, 0);
  14422. builder.Write(hviv.CheckOutDate);
  14423. builder.MoveToCell(0, i, 3, 0);
  14424. builder.Write(hviv.RoomType);
  14425. builder.MoveToCell(0, i, 4, 0);
  14426. builder.Write(hviv.ConfirmationNumber);
  14427. }
  14428. //删除多余行
  14429. int currRowIndex = vouchers.Count + 1;
  14430. int delRows = 21 - currRowIndex;
  14431. if (delRows > 0)
  14432. {
  14433. for (int i = 0; i < delRows; i++)
  14434. {
  14435. table.Rows.RemoveAt(currRowIndex);
  14436. //cultivateRowIndex++;
  14437. }
  14438. }
  14439. strFileName += "VOUCHER.docx";
  14440. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14441. doc.Save(fileDir);
  14442. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14443. return Ok(JsonView(true, "操作成功!", Url));
  14444. }
  14445. /// <summary>
  14446. /// 酒店预订
  14447. /// 生成VOUCHER 批量生成
  14448. /// New
  14449. /// </summary>
  14450. /// <param name="_dto"></param>
  14451. /// <returns></returns>
  14452. [HttpPost]
  14453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14454. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14455. {
  14456. #region 参数验证
  14457. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14458. if (_dto.PageId < 1) _dto.PageId = 28;
  14459. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14460. #region 团组操作权限验证 76 酒店预定模块
  14461. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14462. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14463. #endregion
  14464. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14465. #region 页面操作权限验证
  14466. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14467. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14468. #endregion
  14469. #endregion
  14470. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14471. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14472. .OrderBy(x => x.CheckInDate)
  14473. .ToListAsync();
  14474. //判断数据是否完整
  14475. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14476. string strFileName = "HotelStatement/";
  14477. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14478. if (dele != null)
  14479. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14480. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14481. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14482. .Where(it => it.IsDel == 0)
  14483. .ToListAsync();
  14484. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14485. for (int i = 0; i < hrDtas.Count; i++)
  14486. {
  14487. string guestNames = string.Empty;
  14488. List<int> guestIds = new List<int>();
  14489. var item = hrDtas[i];
  14490. //处理客户姓名
  14491. if (item.GuestName.Contains(","))
  14492. {
  14493. string[] guestIdArr = item.GuestName.Split(',');
  14494. foreach (var guestIdStr in guestIdArr)
  14495. if (int.TryParse(guestIdStr, out int guestId))
  14496. guestIds.Add(guestId);
  14497. }
  14498. else
  14499. {
  14500. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14501. if (guestIdBool)
  14502. {
  14503. guestIds.Add(guestId);
  14504. }
  14505. //NaN
  14506. if (item.GuestName.Contains("NaN"))
  14507. {
  14508. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14509. }
  14510. }
  14511. if (guestIds.Count > 0)
  14512. {
  14513. guestIds = guestIds.Distinct().ToList();
  14514. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14515. if (guestDatas1.Count > 0)
  14516. {
  14517. guestNames = "";
  14518. foreach (var guest in guestDatas1)
  14519. {
  14520. string guestName = "";
  14521. if (guest.Sex == 0) guestName += @"MR.";
  14522. else if (guest.Sex == 1) guestName += @"MS.";
  14523. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14524. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14525. guestNames += @$"{guestName.Trim()}、";
  14526. }
  14527. if (guestNames.Length > 0)
  14528. {
  14529. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14530. }
  14531. }
  14532. }
  14533. //if (!string.IsNullOrEmpty(guestNames))
  14534. //{
  14535. hrDtas[i].GuestName = guestNames;
  14536. //}
  14537. }
  14538. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14539. Document doc = new Document();
  14540. DocumentBuilder builder = new DocumentBuilder(doc);
  14541. try
  14542. {
  14543. builder.MoveToDocumentStart();
  14544. foreach (var item in hrDtas)
  14545. {
  14546. //标题
  14547. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14548. builder.ParagraphFormat.LineSpacing = 1;
  14549. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14550. builder.ParagraphFormat.Style.Font.Size = 9;
  14551. builder.ParagraphFormat.Style.Font.Bold = true;
  14552. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14553. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14554. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14555. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14556. builder.ParagraphFormat.LineSpacing = 1;
  14557. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14558. builder.ParagraphFormat.Style.Font.Size = 9;
  14559. builder.ParagraphFormat.Style.Font.Bold = true;
  14560. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14561. builder.StartTable();
  14562. // 设置边框颜色
  14563. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14564. //设置边框样式
  14565. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14566. //表格
  14567. #region 第一行
  14568. builder.InsertCell();
  14569. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14570. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14571. //builder.CellFormat.AllowAutoFit = false;
  14572. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14573. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14574. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14575. builder.CellFormat.WrapText = true; //自动换行
  14576. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14577. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14578. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14579. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14580. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14581. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14582. builder.Write("TOUR NO:");
  14583. builder.InsertCell();
  14584. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14585. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14586. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14587. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14588. builder.ParagraphFormat.Style.Font.Bold = false;
  14589. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14590. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14591. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14592. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14593. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14594. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14595. builder.Write($"{dele?.TourCode ?? "-"}");
  14596. builder.InsertCell();
  14597. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14598. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14599. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14600. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14601. builder.ParagraphFormat.Style.Font.Bold = false;
  14602. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14603. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14604. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14605. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14606. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14607. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14608. builder.Write($"CITY:");
  14609. builder.InsertCell();
  14610. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14611. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14612. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14613. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14614. builder.ParagraphFormat.Style.Font.Bold = false;
  14615. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14616. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14617. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14618. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14619. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14620. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14621. builder.Write($"{item.City}");
  14622. builder.EndRow();
  14623. #endregion
  14624. #region 第二行
  14625. builder.InsertCell();
  14626. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14627. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14628. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14629. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14630. builder.ParagraphFormat.Style.Font.Bold = false;
  14631. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14632. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14633. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14634. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14635. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14636. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14637. builder.Write("CONFIRMATION NO:");
  14638. builder.InsertCell();
  14639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14640. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14641. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14642. builder.ParagraphFormat.Style.Font.Bold = false;
  14643. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14644. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14645. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14646. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14647. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14648. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14649. builder.CellFormat.VerticalMerge = CellMerge.None;
  14650. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14651. builder.Write($"{item.DetermineNo}");
  14652. builder.InsertCell();
  14653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14654. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14655. builder.InsertCell();
  14656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14657. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14658. builder.EndRow();
  14659. #endregion
  14660. #region 第三行
  14661. builder.InsertCell();
  14662. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14663. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14664. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14665. builder.ParagraphFormat.Style.Font.Bold = false;
  14666. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14667. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14668. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14669. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14670. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14671. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14672. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14673. builder.Write($"HOTEL NAME:");
  14674. builder.InsertCell();
  14675. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14676. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14677. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14678. builder.ParagraphFormat.Style.Font.Bold = false;
  14679. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14680. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14681. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14682. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14683. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14684. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14685. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14686. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14687. builder.Write($"{item.HotelName}");
  14688. builder.InsertCell();
  14689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14690. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14691. builder.InsertCell();
  14692. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14693. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14694. builder.EndRow();
  14695. #endregion
  14696. #region 第四行
  14697. builder.InsertCell();
  14698. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14699. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14700. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14701. builder.ParagraphFormat.Style.Font.Bold = false;
  14702. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14703. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14704. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14705. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14706. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14707. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14708. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14709. builder.Write($"HOTEL ADDRESS:");
  14710. builder.InsertCell();
  14711. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14712. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14713. builder.ParagraphFormat.Style.Font.Size = 8;
  14714. builder.ParagraphFormat.Style.Font.Bold = false;
  14715. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14716. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14717. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14718. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14719. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14720. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14721. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14722. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14723. builder.Write($"{item.HotelAddress}");
  14724. builder.InsertCell();
  14725. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14726. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14727. builder.InsertCell();
  14728. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14729. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14730. builder.EndRow();
  14731. #endregion
  14732. #region 第五行
  14733. builder.InsertCell();
  14734. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14735. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14736. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14737. builder.ParagraphFormat.Style.Font.Bold = false;
  14738. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14739. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14740. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14741. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14742. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14743. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14744. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14745. builder.Write("TEL:");
  14746. builder.InsertCell();
  14747. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14748. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14749. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14750. builder.ParagraphFormat.Style.Font.Bold = false;
  14751. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14752. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14753. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14754. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14755. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14756. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14757. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14758. builder.Write($"{item.HotelTel}");
  14759. builder.InsertCell();
  14760. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14761. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14762. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14763. builder.ParagraphFormat.Style.Font.Bold = false;
  14764. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14765. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14766. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14767. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14768. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14769. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14770. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14771. builder.Write($"FAX:");
  14772. builder.InsertCell();
  14773. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14774. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14775. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14776. builder.ParagraphFormat.Style.Font.Bold = false;
  14777. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14778. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14779. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14780. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14781. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14782. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14783. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14784. builder.Write($"{item.HotelFax}");
  14785. builder.EndRow();
  14786. #endregion
  14787. #region 第六行
  14788. builder.InsertCell();
  14789. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14790. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14791. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14792. builder.ParagraphFormat.Style.Font.Bold = false;
  14793. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14794. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14795. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14796. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14797. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14798. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14799. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14800. builder.Write("CHECK IN:");
  14801. builder.InsertCell();
  14802. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14803. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14804. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14805. builder.ParagraphFormat.Style.Font.Bold = false;
  14806. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14807. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14808. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14809. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14810. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14811. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14812. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14813. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14814. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14815. builder.Write($"{checkInStr}");
  14816. builder.InsertCell();
  14817. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14818. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14819. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14820. builder.ParagraphFormat.Style.Font.Bold = false;
  14821. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14822. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14823. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14824. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14825. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14826. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14827. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14828. builder.Write($"CHECK OUT:");
  14829. builder.InsertCell();
  14830. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14831. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14832. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14833. builder.ParagraphFormat.Style.Font.Bold = false;
  14834. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14835. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14836. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14837. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14838. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14839. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14840. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14841. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14842. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14843. builder.Write($"{checkOutStr}");
  14844. builder.EndRow();
  14845. #endregion
  14846. #region 第七行
  14847. builder.InsertCell();
  14848. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14849. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14850. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14851. builder.ParagraphFormat.Style.Font.Bold = false;
  14852. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14853. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14854. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14855. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14856. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14857. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14858. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14859. builder.Write($"GUEST NAME:");
  14860. builder.InsertCell();
  14861. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14862. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14863. builder.ParagraphFormat.Style.Font.Size = 8;
  14864. builder.ParagraphFormat.Style.Font.Bold = false;
  14865. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14866. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14867. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14868. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14869. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14870. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14871. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14872. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14873. builder.Write($"{item.GuestName}");
  14874. builder.InsertCell();
  14875. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14876. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14877. builder.InsertCell();
  14878. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14879. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14880. builder.EndRow();
  14881. #endregion
  14882. #region 第八行
  14883. builder.InsertCell();
  14884. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14885. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14886. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14887. builder.ParagraphFormat.Style.Font.Bold = false;
  14888. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14889. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14890. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14891. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14892. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14893. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14894. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14895. builder.Write($"ROOM TYPE:");
  14896. builder.InsertCell();
  14897. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14898. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14899. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14900. builder.ParagraphFormat.Style.Font.Bold = false;
  14901. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14902. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14903. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14904. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14905. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14906. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14907. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14908. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14909. builder.Write($"{item.RoomExplanation}");
  14910. builder.InsertCell();
  14911. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14912. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14913. builder.InsertCell();
  14914. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14915. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14916. builder.EndRow();
  14917. #endregion
  14918. #region 第九行
  14919. builder.InsertCell();
  14920. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14921. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14922. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14923. builder.ParagraphFormat.Style.Font.Bold = false;
  14924. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14925. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14926. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14927. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14928. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14929. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14930. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14931. builder.Write($"NOTE:");
  14932. builder.InsertCell();
  14933. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14934. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14935. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14936. builder.ParagraphFormat.Style.Font.Bold = false;
  14937. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14938. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14939. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14940. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14941. 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.");
  14942. builder.InsertCell();
  14943. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14944. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14945. builder.InsertCell();
  14946. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14947. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14948. builder.EndRow();
  14949. #endregion
  14950. builder.EndTable();
  14951. //换行
  14952. builder.Writeln("");
  14953. builder.Writeln("");
  14954. }
  14955. #region 获取文档中的所有表格 设置文字自适应
  14956. // 获取文档中的所有表格。
  14957. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14958. {
  14959. // 遍历表格中的所有行。
  14960. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14961. {
  14962. foreach (Cell cell in row.Cells)
  14963. {
  14964. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14965. cellFormat.Width = 0;
  14966. }
  14967. }
  14968. }
  14969. #endregion
  14970. #region 设置页眉
  14971. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14972. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14973. if (System.IO.File.Exists(voucherHeaderPath))
  14974. {
  14975. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14976. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14977. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14978. Shape shape = builder.InsertImage(imageBytes);
  14979. // 调整图片位置
  14980. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14981. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14982. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14983. shape.Left = 0; // 将图片距离页面左边缘的距离
  14984. shape.Width = 81; // 设置图片宽度
  14985. shape.Height = 36; // 设置图片高度
  14986. }
  14987. //靠右
  14988. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14989. //// 设置页脚上下边距
  14990. //builder.PageSetup.HeaderDistance = 42;
  14991. // 添加页眉线
  14992. Aspose.Words.Border borderHeader = null;
  14993. try
  14994. {
  14995. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14996. }
  14997. catch (Exception e)
  14998. {
  14999. // TODO Auto-generated catch block
  15000. //e.printStackTrace();
  15001. }
  15002. borderHeader.Shadow = true;
  15003. borderHeader.DistanceFromText = 2;
  15004. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15005. #endregion
  15006. }
  15007. catch (Exception ex)
  15008. {
  15009. }
  15010. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15011. doc.Save(fileDir);
  15012. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15013. return Ok(JsonView(true, "操作成功!", Url));
  15014. }
  15015. /// <summary>
  15016. /// 酒店预订
  15017. /// 生成 预定成本 Excel
  15018. /// </summary>
  15019. /// <param name="_dto"></param>
  15020. /// <returns></returns>
  15021. [HttpPost]
  15022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15023. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15024. {
  15025. #region 参数验证
  15026. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15027. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15028. if (!vadalitorRes.IsValid)
  15029. {
  15030. var errors = new StringBuilder();
  15031. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15032. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15033. }
  15034. #region 团组操作权限验证 76 酒店预定模块
  15035. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15036. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15037. #endregion
  15038. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15039. #region 页面操作权限验证
  15040. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15041. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15042. #endregion
  15043. #endregion
  15044. decimal _rate = 1.00M;
  15045. string _currency = string.Empty;
  15046. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15047. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15048. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15049. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15050. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15051. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15052. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15053. if (_GroupCostParameter == null)
  15054. {
  15055. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15056. bool isIntType = int.TryParse(_currency, out int currId);
  15057. if (isIntType)
  15058. {
  15059. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15060. }
  15061. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15062. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15063. if (currInfo == null)
  15064. {
  15065. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15066. }
  15067. else _rate = currInfo.Rate;
  15068. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15069. {
  15070. _rate = _GroupCostParameter.Rate;
  15071. }
  15072. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15073. //string strFileName = "HotelStatement/";
  15074. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15075. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15076. var rateDatas = new List<dynamic>();
  15077. #region 数据处理
  15078. foreach (var item in hrDtas)
  15079. {
  15080. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15081. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15082. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15083. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15084. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15085. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15086. {
  15087. continue;
  15088. }
  15089. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15090. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15091. string singleRoomFeeStr = string.Empty,
  15092. doubleRoomFeeStr = string.Empty,
  15093. suiteRoomFeeStr = string.Empty,
  15094. otherRoomFeeStr = string.Empty,
  15095. payMoneyStr = string.Empty,
  15096. cardPriceStr = string.Empty;
  15097. if (roomCurr.Equals("CNY"))
  15098. {
  15099. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15100. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15101. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15102. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15103. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15104. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15105. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15106. }
  15107. else
  15108. {
  15109. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15110. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15111. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15112. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15113. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15114. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15115. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15116. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15117. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15118. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15119. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15120. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15121. if (ccpPaymentCurrency.Equals("CNY"))
  15122. {
  15123. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15124. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15125. }
  15126. else
  15127. {
  15128. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15129. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15130. }
  15131. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15132. if (hotelcardPriceCurrency.Equals("CNY"))
  15133. {
  15134. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15135. }
  15136. else
  15137. {
  15138. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15139. }
  15140. }
  15141. string breakfastPriceStr = string.Empty,
  15142. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15143. governmentRentStr = string.Empty,
  15144. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15145. cityTaxStr = string.Empty,
  15146. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15147. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15148. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15149. {
  15150. if (breakfastCurrency1.Equals("CNY"))
  15151. {
  15152. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15153. }
  15154. else
  15155. {
  15156. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15157. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15158. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15159. }
  15160. }
  15161. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15162. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15163. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15164. {
  15165. if (governmentRentCurrency.Equals("CNY"))
  15166. {
  15167. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15168. }
  15169. else
  15170. {
  15171. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15172. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15173. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15174. }
  15175. }
  15176. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15177. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15178. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15179. {
  15180. if (cityTaxStrCurrency1.Equals("CNY"))
  15181. {
  15182. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15183. }
  15184. else
  15185. {
  15186. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15187. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15188. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15189. }
  15190. }
  15191. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15192. int payDId = roomInfo?.PayDId ?? 0;
  15193. pcfds.Add(new HotelReservations_PCFD_View()
  15194. {
  15195. City = item.City,
  15196. HotelName = item.HotelName,
  15197. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15198. // SingleRoomCount = item.SingleRoomCount,
  15199. SingleRoomPrice = singleRoomFeeStr,
  15200. // DoubleRoomCount = item.DoubleRoomCount,
  15201. DoubleRoomPrice = doubleRoomFeeStr,
  15202. //SuiteRoomCount = item.SuiteRoomCount,
  15203. SuiteRoomPrice = suiteRoomFeeStr,
  15204. OtherRoomPrice = otherRoomFeeStr,
  15205. //OtherRoomCount = item.OtherRoomCount,
  15206. BreakfastPrice = breakfastPriceStr,
  15207. GovernmentRent = governmentRentStr,
  15208. CityTax = cityTaxStr,
  15209. RoomExplanation = item.RoomExplanation,
  15210. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15211. PayTime = roomInfo?.ConsumptionDate,
  15212. BankNo = roomInfo?.BankNo,
  15213. PayMoney = payMoneyStr,
  15214. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15215. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15216. CardPrice = cardPriceStr,
  15217. Remark = ccpInfo.Remark
  15218. });
  15219. }
  15220. #endregion
  15221. //载入模板
  15222. WorkbookDesigner designer = new WorkbookDesigner();
  15223. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15224. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15225. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15226. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15227. var rateDatas1 = rateDatas.Distinct();
  15228. var rateStr = string.Empty;
  15229. foreach (var item in rateDatas1)
  15230. {
  15231. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15232. }
  15233. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15234. designer.SetDataSource("Opertor", userInfo.CnName);
  15235. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15236. dt.TableName = "ViewMyHotelReservations";
  15237. designer.SetDataSource(dt);
  15238. designer.Process();
  15239. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15240. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15241. designer.Workbook.Save(serverPath);
  15242. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15243. #region 删除指定行
  15244. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15245. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15246. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15247. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15248. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15249. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15250. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15251. cssIndex = dt.Columns["CityTax"].Ordinal,
  15252. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15253. remarkIndex = dt.Columns["Remark"].Ordinal;
  15254. //删除指定列
  15255. foreach (DataRow item in dt.Rows)
  15256. {
  15257. string singleStr = item["SingleRoomPrice"].ToString();
  15258. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15259. if (containsDigitButNotZero1) singleDel = false;
  15260. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15261. string doubleStr = item["DoubleRoomPrice"].ToString();
  15262. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15263. if (containsDigitButNotZero2) doubleDel = false;
  15264. string suiteStr = item["SuiteRoomPrice"].ToString();
  15265. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15266. if (containsDigitButNotZero3) suiteDel = false;
  15267. string otherStr = item["OtherRoomPrice"].ToString();
  15268. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15269. if (containsDigitButNotZero4) otherDel = false;
  15270. string zcStr = item["BreakfastPrice"].ToString();
  15271. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15272. if (containsDigitButNotZero5) zcDel = false;
  15273. string dsStr = item["GovernmentRent"].ToString();
  15274. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15275. if (containsDigitButNotZero6) dsDel = false;
  15276. string cssStr = item["CityTax"].ToString();
  15277. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15278. if (containsDigitButNotZero7) cssDel = false;
  15279. string cpStr = item["ConsumptionPatterns"].ToString();
  15280. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15281. string remarkStr = item["Remark"].ToString();
  15282. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15283. }
  15284. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15285. DeleteColumn(serverPath, cpIndex, cpDel);
  15286. DeleteColumn(serverPath, dsIndex, dsDel);
  15287. DeleteColumn(serverPath, cssIndex, cssDel);
  15288. DeleteColumn(serverPath, zcIndex, zcDel);
  15289. DeleteColumn(serverPath, otherIndex, otherDel);
  15290. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15291. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15292. DeleteColumn(serverPath, singleIndex, singleDel);
  15293. #endregion
  15294. //只保留第一个表格
  15295. DeleteSheet(serverPath);
  15296. return Ok(JsonView(true, "操作成功", url = rst));
  15297. }
  15298. else
  15299. {
  15300. _currency = _GroupCostParameter.Currency;
  15301. bool isIntType = int.TryParse(_currency, out int currId);
  15302. if (isIntType)
  15303. {
  15304. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15305. }
  15306. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15307. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15308. if (currInfo == null)
  15309. {
  15310. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15311. }
  15312. if (!_currency.ToUpper().Equals("CNY"))
  15313. {
  15314. _rate = _GroupCostParameter.Rate;
  15315. }
  15316. _rate = currInfo.Rate;
  15317. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15318. //string strFileName = "HotelStatement/";
  15319. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15320. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15321. #region 数据处理
  15322. foreach (var item in hrDtas)
  15323. {
  15324. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15325. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15326. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15327. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15328. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15329. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15330. string singleRoomFeeStr = string.Empty,
  15331. doubleRoomFeeStr = string.Empty,
  15332. suiteRoomFeeStr = string.Empty,
  15333. otherRoomFeeStr = string.Empty,
  15334. payMoneyStr = string.Empty,
  15335. cardPriceStr = string.Empty;
  15336. if (roomCurr.Equals(_currency))
  15337. {
  15338. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15339. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15340. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15341. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15342. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15343. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15344. }
  15345. else
  15346. {
  15347. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15348. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15349. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15350. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15351. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15352. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15353. }
  15354. string breakfastPriceStr = string.Empty,
  15355. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15356. governmentRentStr = string.Empty,
  15357. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15358. cityTaxStrStr = string.Empty,
  15359. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15360. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15361. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15362. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15363. int payDId = roomInfo?.PayDId ?? 0;
  15364. pcfds.Add(new HotelReservations_PCFD_View()
  15365. {
  15366. City = item.City,
  15367. HotelName = item.HotelName,
  15368. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15369. // SingleRoomCount = item.SingleRoomCount,
  15370. SingleRoomPrice = singleRoomFeeStr,
  15371. // DoubleRoomCount = item.DoubleRoomCount,
  15372. DoubleRoomPrice = doubleRoomFeeStr,
  15373. //SuiteRoomCount = item.SuiteRoomCount,
  15374. SuiteRoomPrice = suiteRoomFeeStr,
  15375. OtherRoomPrice = otherRoomFeeStr,
  15376. //OtherRoomCount = item.OtherRoomCount,
  15377. BreakfastPrice = breakfastPriceStr,
  15378. GovernmentRent = governmentRentStr,
  15379. CityTax = cityTaxStrStr,
  15380. RoomExplanation = item.RoomExplanation,
  15381. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15382. PayTime = roomInfo?.ConsumptionDate,
  15383. BankNo = roomInfo?.BankNo,
  15384. PayMoney = payMoneyStr,
  15385. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15386. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15387. CardPrice = cardPriceStr,
  15388. Remark = ccpInfo.Remark
  15389. });
  15390. }
  15391. #endregion
  15392. //载入模板
  15393. WorkbookDesigner designer = new WorkbookDesigner();
  15394. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15395. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15396. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15397. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15398. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15399. designer.SetDataSource("Opertor", userInfo.CnName);
  15400. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15401. dt.TableName = "ViewMyHotelReservations";
  15402. designer.SetDataSource(dt);
  15403. designer.Process();
  15404. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15405. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15406. designer.Workbook.Save(serverPath);
  15407. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15408. #region 删除指定行
  15409. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15410. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15411. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15412. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15413. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15414. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15415. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15416. cssIndex = dt.Columns["CityTax"].Ordinal,
  15417. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15418. remarkIndex = dt.Columns["Remark"].Ordinal;
  15419. //删除指定列
  15420. foreach (DataRow item in dt.Rows)
  15421. {
  15422. string singleStr = item["SingleRoomPrice"].ToString();
  15423. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15424. if (containsDigitButNotZero1) singleDel = false;
  15425. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15426. string doubleStr = item["DoubleRoomPrice"].ToString();
  15427. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15428. if (containsDigitButNotZero2) doubleDel = false;
  15429. string suiteStr = item["SuiteRoomPrice"].ToString();
  15430. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15431. if (containsDigitButNotZero3) suiteDel = false;
  15432. string otherStr = item["OtherRoomPrice"].ToString();
  15433. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15434. if (containsDigitButNotZero4) otherDel = false;
  15435. string zcStr = item["BreakfastPrice"].ToString();
  15436. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15437. if (containsDigitButNotZero5) zcDel = false;
  15438. string dsStr = item["GovernmentRent"].ToString();
  15439. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15440. if (containsDigitButNotZero6) dsDel = false;
  15441. string cssStr = item["CityTax"].ToString();
  15442. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15443. if (containsDigitButNotZero7) cssDel = false;
  15444. string cpStr = item["ConsumptionPatterns"].ToString();
  15445. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15446. string remarkStr = item["Remark"].ToString();
  15447. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15448. }
  15449. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15450. DeleteColumn(serverPath, cpIndex, cpDel);
  15451. DeleteColumn(serverPath, dsIndex, dsDel);
  15452. DeleteColumn(serverPath, cssIndex, cssDel);
  15453. DeleteColumn(serverPath, zcIndex, zcDel);
  15454. DeleteColumn(serverPath, otherIndex, otherDel);
  15455. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15456. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15457. DeleteColumn(serverPath, singleIndex, singleDel);
  15458. #endregion
  15459. //只保留第一个表格
  15460. DeleteSheet(serverPath);
  15461. return Ok(JsonView(true, "操作成功", url = rst));
  15462. }
  15463. //return Ok(JsonView(false));
  15464. }
  15465. /// <summary>
  15466. /// 删除指定列
  15467. /// </summary>
  15468. /// <param name="file"></param>
  15469. /// <param name="columnIndex"></param>
  15470. /// <param name="isDel"></param>
  15471. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15472. {
  15473. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15474. //wb.Save(file);
  15475. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15476. if (sheet1 != null)
  15477. {
  15478. if (isDel)
  15479. {
  15480. Cells cells = sheet1.Cells;
  15481. cells.DeleteColumn(columnIndex);
  15482. }
  15483. }
  15484. wb.Save(file);
  15485. }
  15486. /// <summary>
  15487. /// 删除sheet
  15488. /// </summary>
  15489. /// <param name="file"></param>
  15490. /// <param name="sheetName"></param>
  15491. private void DeleteSheet(string file, string sheetName = "")
  15492. {
  15493. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15494. //wb.Save(file);
  15495. List<string> sheets = new List<string>();
  15496. foreach (var item in wb.Worksheets)
  15497. {
  15498. sheets.Add(item.Name);
  15499. }
  15500. if (sheets.Count > 0)
  15501. {
  15502. sheets.RemoveAt(0);//不删除第一个sheet
  15503. foreach (var item in sheets)
  15504. {
  15505. wb.Worksheets.RemoveAt(item);
  15506. }
  15507. }
  15508. wb.Save(file);
  15509. }
  15510. /// <summary>
  15511. /// 酒店预订
  15512. /// 确认单
  15513. /// </summary>
  15514. /// <param name="_dto"></param>
  15515. /// <returns></returns>
  15516. [HttpPost]
  15517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15518. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15519. {
  15520. try
  15521. {
  15522. #region 参数验证
  15523. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15524. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15525. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15526. #region 团组操作权限验证 76 酒店预定模块
  15527. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15528. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15529. #endregion
  15530. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15531. #region 页面操作权限验证
  15532. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15533. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15534. #endregion
  15535. #endregion
  15536. //团组信息
  15537. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15538. //酒店数据
  15539. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15540. if (listhoteldata.Count < 0)
  15541. {
  15542. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15543. }
  15544. //利datatable存储
  15545. DataTable dt = new DataTable();
  15546. dt.Columns.Add("CheckInDate", typeof(string));
  15547. dt.Columns.Add("City", typeof(string));
  15548. dt.Columns.Add("Hotel", typeof(string));
  15549. dt.Columns.Add("Room", typeof(string));
  15550. for (int i = 0; i < listhoteldata.Count; i++)
  15551. {
  15552. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15553. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15554. while (dayStart < dayEnd)
  15555. {
  15556. string temp = "";
  15557. DataRow row = dt.NewRow();
  15558. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15559. row["City"] = listhoteldata[i].City;
  15560. row["Hotel"] = listhoteldata[i].HotelName;
  15561. if (listhoteldata[i].SingleRoomCount > 0)
  15562. {
  15563. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15564. }
  15565. if (listhoteldata[i].DoubleRoomCount > 0)
  15566. {
  15567. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15568. }
  15569. if (listhoteldata[i].SuiteRoomCount > 0)
  15570. {
  15571. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15572. }
  15573. if (listhoteldata[i].OtherRoomCount > 0)
  15574. {
  15575. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15576. }
  15577. row["Room"] = temp;
  15578. dt.Rows.Add(row);
  15579. dayStart = dayStart.AddDays(1);
  15580. }
  15581. }
  15582. Dictionary<string, string> dic = new Dictionary<string, string>();
  15583. dic.Add("Dele", di.TeamName);
  15584. dic.Add("City", di.VisitCountry);
  15585. //模板路径
  15586. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15587. //载入模板
  15588. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15589. DocumentBuilder builder = new DocumentBuilder(doc);
  15590. foreach (var key in dic.Keys)
  15591. {
  15592. builder.MoveToBookmark(key);
  15593. builder.Write(dic[key]);
  15594. }
  15595. //获取word里所有表格
  15596. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15597. //获取所填表格的序数
  15598. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15599. var rowStart = tableOne.Rows[0]; //获取第1行
  15600. //循环赋值
  15601. for (int i = 0; i < dt.Rows.Count; i++)
  15602. {
  15603. builder.MoveToCell(0, i + 1, 0, 0);
  15604. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15605. builder.MoveToCell(0, i + 1, 1, 0);
  15606. builder.Write(dt.Rows[i]["City"].ToString());
  15607. builder.MoveToCell(0, i + 1, 2, 0);
  15608. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15609. builder.MoveToCell(0, i + 1, 3, 0);
  15610. builder.Write(dt.Rows[i]["Room"].ToString());
  15611. }
  15612. //删除多余行
  15613. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15614. {
  15615. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15616. }
  15617. string strFileName = di.TeamName + "酒店确认单.doc";
  15618. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15619. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15620. return Ok(JsonView(true, "成功", url));
  15621. }
  15622. catch (Exception ex)
  15623. {
  15624. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15625. }
  15626. }
  15627. #endregion
  15628. #region 团组状态
  15629. /// <summary>
  15630. /// 团组状态列表 Page
  15631. /// </summary>
  15632. /// <param name="dto">团组列表请求dto</param>
  15633. /// <returns></returns>
  15634. [HttpPost]
  15635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15636. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15637. {
  15638. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15639. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15640. {
  15641. string sqlWhere = string.Empty;
  15642. if (dto.IsSure == 0) //未完成
  15643. {
  15644. sqlWhere += string.Format(@" And IsSure = 0");
  15645. }
  15646. else if (dto.IsSure == 1) //已完成
  15647. {
  15648. sqlWhere += string.Format(@" And IsSure = 1");
  15649. }
  15650. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15651. {
  15652. string tj = dto.SearchCriteria;
  15653. 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}%')",
  15654. tj, tj, tj, tj, tj);
  15655. }
  15656. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15657. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15658. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15659. From (
  15660. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15661. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15662. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15663. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15664. From Grp_DelegationInfo gdi
  15665. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15666. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15667. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15668. Where gdi.IsDel = 0 {0}
  15669. ) temp ", sqlWhere);
  15670. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15671. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15672. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15673. }
  15674. else
  15675. {
  15676. return Ok(JsonView(false, "查询失败"));
  15677. }
  15678. }
  15679. /// <summary>
  15680. /// 团组状态
  15681. /// 设置操作完成
  15682. /// </summary>
  15683. /// <param name="dto">团组列表请求dto</param>
  15684. /// <returns></returns>
  15685. [HttpPost]
  15686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15687. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15688. {
  15689. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15690. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15691. {
  15692. Id = dto.Id,
  15693. IsSure = 1
  15694. };
  15695. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15696. .UpdateColumns(it => new { it.IsSure })
  15697. .WhereColumns(it => new { it.Id })
  15698. .ExecuteCommandAsync();
  15699. if (result > 0)
  15700. {
  15701. return Ok(JsonView(true, "操作完成!"));
  15702. }
  15703. return Ok(JsonView(false, "操作失败!"));
  15704. }
  15705. #endregion
  15706. #region 保险费用录入
  15707. /// <summary>
  15708. /// 根据团组Id查询保险费用列表
  15709. /// </summary>
  15710. /// <param name="dto"></param>
  15711. /// <returns></returns>
  15712. [HttpPost]
  15713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15714. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15715. {
  15716. Result groupData = await _customersRep.CustomersByDiId(dto);
  15717. if (groupData.Code != 0)
  15718. {
  15719. return Ok(JsonView(false, groupData.Msg));
  15720. }
  15721. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15722. }
  15723. /// <summary>
  15724. /// 根据保险费用Id查询保险费用详细
  15725. /// </summary>
  15726. /// <param name="dto"></param>
  15727. /// <returns></returns>
  15728. [HttpPost]
  15729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15730. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15731. {
  15732. try
  15733. {
  15734. Result groupData = await _customersRep.CustomersById(dto);
  15735. if (groupData.Code != 0)
  15736. {
  15737. return Ok(JsonView(false, groupData.Msg));
  15738. }
  15739. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15740. }
  15741. catch (Exception ex)
  15742. {
  15743. return Ok(JsonView(false, ex.Message));
  15744. }
  15745. }
  15746. /// <summary>
  15747. /// 保险费用录入页面初始化绑定
  15748. /// </summary>
  15749. /// <param name="dto"></param>
  15750. /// <returns></returns>
  15751. [HttpPost]
  15752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15753. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15754. {
  15755. try
  15756. {
  15757. Result groupData = await _customersRep.CustomersInitialize(dto);
  15758. if (groupData.Code != 0)
  15759. {
  15760. return Ok(JsonView(false, groupData.Msg));
  15761. }
  15762. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15763. }
  15764. catch (Exception ex)
  15765. {
  15766. return Ok(JsonView(false, ex.Message));
  15767. }
  15768. }
  15769. /// <summary>
  15770. /// 保险费用操作(Status:1.新增,2.修改)
  15771. /// </summary>
  15772. /// <param name="dto"></param>
  15773. /// <returns></returns>
  15774. [HttpPost]
  15775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15776. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15777. {
  15778. Result groupData = await _customersRep.OpCustomers(dto);
  15779. if (groupData.Code != 0)
  15780. {
  15781. return Ok(JsonView(false, groupData.Msg));
  15782. }
  15783. #region 应用推送
  15784. try
  15785. {
  15786. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15787. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15788. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15789. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15790. //自动审核
  15791. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15792. //2024-10-21 新增LZ UID
  15793. var userIds = new List<int>() { 21 };
  15794. string title = $"系统通知";
  15795. var diId = dto.DiId;
  15796. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15797. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15798. string content = "";
  15799. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15800. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15801. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15802. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15803. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15804. }
  15805. catch (Exception ex)
  15806. {
  15807. }
  15808. #endregion
  15809. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15810. }
  15811. /// <summary>
  15812. /// 保险文件上传
  15813. /// </summary>
  15814. /// <param name="file"></param>
  15815. /// <returns></returns>
  15816. [HttpPost]
  15817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15818. public async Task<IActionResult> UploadCus(IFormFile file)
  15819. {
  15820. try
  15821. {
  15822. if (file != null)
  15823. {
  15824. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15825. //文件名称
  15826. string projectFileName = file.FileName;
  15827. //上传的文件的路径
  15828. string filePath = "";
  15829. if (!Directory.Exists(fileDir))
  15830. {
  15831. Directory.CreateDirectory(fileDir);
  15832. }
  15833. //上传的文件的路径
  15834. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15835. using (FileStream fs = System.IO.File.Create(filePath))
  15836. {
  15837. file.CopyTo(fs);
  15838. fs.Flush();
  15839. }
  15840. return Ok(JsonView(true, "上传成功!", projectFileName));
  15841. }
  15842. else
  15843. {
  15844. return Ok(JsonView(false, "上传失败!"));
  15845. }
  15846. }
  15847. catch (Exception ex)
  15848. {
  15849. return Ok(JsonView(false, "程序错误!"));
  15850. throw;
  15851. }
  15852. }
  15853. /// <summary>
  15854. /// 保险删除指定文件
  15855. /// </summary>
  15856. /// <param name="dto"></param>
  15857. /// <returns></returns>
  15858. [HttpPost]
  15859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15860. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15861. {
  15862. try
  15863. {
  15864. string filePath = "";
  15865. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15866. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15867. //int id = 0;
  15868. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15869. // 删除该文件
  15870. try
  15871. {
  15872. System.IO.File.Delete(filePath);
  15873. 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()
  15874. {
  15875. Attachment = "",
  15876. }).ExecuteCommandAsync();
  15877. if (result != 0)
  15878. {
  15879. return Ok(JsonView(true, "成功!"));
  15880. }
  15881. else
  15882. {
  15883. return Ok(JsonView(false, "失败!"));
  15884. }
  15885. }
  15886. catch (Exception)
  15887. {
  15888. 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()
  15889. {
  15890. Attachment = "",
  15891. }).ExecuteCommandAsync();
  15892. if (result != 0)
  15893. {
  15894. return Ok(JsonView(true, "成功!"));
  15895. }
  15896. else
  15897. {
  15898. return Ok(JsonView(false, "失败!"));
  15899. }
  15900. }
  15901. }
  15902. catch (Exception ex)
  15903. {
  15904. return Ok(JsonView(false, "程序错误!"));
  15905. throw;
  15906. }
  15907. }
  15908. /// <summary>
  15909. /// 保险费用操作(删除)
  15910. /// </summary>
  15911. /// <param name="dto"></param>
  15912. /// <returns></returns>
  15913. [HttpPost]
  15914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15915. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15916. {
  15917. try
  15918. {
  15919. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15920. if (!res)
  15921. {
  15922. return Ok(JsonView(false, "删除失败"));
  15923. }
  15924. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15925. {
  15926. IsDel = 1,
  15927. DeleteUserId = dto.DeleteUserId,
  15928. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15929. }).ExecuteCommandAsync();
  15930. return Ok(JsonView(true, "删除成功!"));
  15931. }
  15932. catch (Exception ex)
  15933. {
  15934. return Ok(JsonView(false, "程序错误!"));
  15935. throw;
  15936. }
  15937. }
  15938. #endregion
  15939. #region 接团客户名单 PageId 104
  15940. /// <summary>
  15941. /// 接团客户名单
  15942. /// 迁移数据(慎用!)
  15943. /// </summary>
  15944. /// <returns></returns>
  15945. [HttpPost]
  15946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15947. public async Task<IActionResult> PostTourClientListChange()
  15948. {
  15949. try
  15950. {
  15951. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15952. //var groupClinetData1
  15953. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15954. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15955. int updateCount = 0;
  15956. if (oldOAClientList.Count > 0)
  15957. {
  15958. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15959. _sqlSugar.BeginTran();
  15960. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15961. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15962. foreach (var item in oldOAClientList)
  15963. {
  15964. int comId = 0;
  15965. string format = "yyyy-MM-dd HH:mm:ss";
  15966. string data11 = "1990-01-01 00:00";
  15967. var data1 = IsValidDate(item.OPdate, format);
  15968. if (data1) data11 = item.OPdate;
  15969. //客户公司验证
  15970. if (!string.IsNullOrEmpty(item.Company))
  15971. {
  15972. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15973. if (clientComInfo == null) // add
  15974. {
  15975. var addInfo = new Crm_CustomerCompany()
  15976. {
  15977. CompanyAbbreviation = "",
  15978. CompanyFullName = item.Company,
  15979. Address = "",
  15980. PostCodes = "",
  15981. LastedOpUserId = item.OPer,
  15982. LastedOpDt = Convert.ToDateTime(data11),
  15983. CreateUserId = item.OPer,
  15984. CreateTime = Convert.ToDateTime(data11),
  15985. IsDel = 0
  15986. };
  15987. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15988. if (comId1 > 0) comId = comId1;
  15989. }
  15990. else comId = clientComInfo.Id;
  15991. }
  15992. //客户人员验证
  15993. int clientId = 0;
  15994. string name = item.LastName + item.Name;
  15995. if (!string.IsNullOrEmpty(name))
  15996. {
  15997. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15998. if (clientInfo == null)
  15999. {
  16000. DateTime? dateTime = null;
  16001. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16002. if (isDt) dateTime = birthDayDt;
  16003. var addInfo1 = new Crm_DeleClient()
  16004. {
  16005. CrmCompanyId = comId,
  16006. DiId = -1,
  16007. LastName = item.LastName,
  16008. FirstName = item.Name,
  16009. OldName = "",
  16010. Pinyin = item.Pinyin,
  16011. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16012. Marriage = 0,
  16013. Phone = item.Phone,
  16014. Job = item.Job,
  16015. BirthDay = dateTime
  16016. };
  16017. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16018. if (clientId1 > 0) clientId = clientId1;
  16019. }
  16020. else clientId = clientInfo.Id;
  16021. }
  16022. if (clientId < 1)
  16023. {
  16024. continue;
  16025. }
  16026. int airType = 0;
  16027. if (item.AirType == "超经舱") airType = 459;
  16028. else if (item.AirType == "公务舱") airType = 458;
  16029. else if (item.AirType == "经济舱") airType = 460;
  16030. else if (item.AirType == "其他") airType = 565;
  16031. else if (item.AirType == "头等舱") airType = 457;
  16032. var _TourClientListEntity = new Grp_TourClientList()
  16033. {
  16034. DiId = item.Diid,
  16035. ClientId = clientId,
  16036. CreateUserId = item.OPer,
  16037. CreateTime = Convert.ToDateTime(data11),
  16038. Remark = item.Remark,
  16039. IsDel = item.Isdel,
  16040. ShippingSpaceTypeId = airType,
  16041. ShippingSpaceSpecialNeeds = item.AirRemark,
  16042. HotelSpecialNeeds = item.RoomType
  16043. };
  16044. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16045. if (_TourClientList > 0)
  16046. {
  16047. updateCount++;
  16048. }
  16049. }
  16050. _sqlSugar.CommitTran();
  16051. }
  16052. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16053. }
  16054. catch (Exception ex)
  16055. {
  16056. _sqlSugar.RollbackTran();
  16057. return Ok(JsonView(false, ex.Message));
  16058. }
  16059. //return Ok(JsonView(true));
  16060. }
  16061. private bool IsValidDate(string dateString, string format)
  16062. {
  16063. DateTime dateValue;
  16064. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16065. return valid;
  16066. }
  16067. /// <summary>
  16068. /// 接团客户名单
  16069. /// 根据团组Id查询List
  16070. /// </summary>
  16071. /// <param name="_dto"></param>
  16072. /// <returns></returns>
  16073. [HttpPost]
  16074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16075. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16076. {
  16077. #region 参数验证
  16078. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16079. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16080. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16082. #region 页面操作权限验证
  16083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16084. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16085. #endregion
  16086. #endregion
  16087. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16088. if (viewData.Code != 0)
  16089. {
  16090. return Ok(JsonView(false, viewData.Msg));
  16091. }
  16092. return Ok(JsonView(viewData.Data));
  16093. }
  16094. /// <summary>
  16095. /// 接团客户名单
  16096. /// 基础数据 Init
  16097. /// </summary>
  16098. /// <param name="_dto"></param>
  16099. /// <returns></returns>
  16100. [HttpPost]
  16101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16102. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16103. {
  16104. #region 参数验证
  16105. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16106. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16107. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16108. #region 页面操作权限验证
  16109. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16110. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16111. #endregion
  16112. #endregion
  16113. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16114. }
  16115. /// <summary>
  16116. /// 接团客户名单
  16117. /// 根据 Id查询 Details
  16118. /// </summary>
  16119. /// <param name="_dto"></param>
  16120. /// <returns></returns>
  16121. [HttpPost]
  16122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16123. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16124. {
  16125. #region 参数验证
  16126. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16127. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16128. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16129. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16130. #region 页面操作权限验证
  16131. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16132. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16133. #endregion
  16134. #endregion
  16135. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16136. if (viewData.Code != 0)
  16137. {
  16138. return Ok(JsonView(false, viewData.Msg));
  16139. }
  16140. return Ok(JsonView(viewData.Data));
  16141. }
  16142. /// <summary>
  16143. /// 接团客户名单
  16144. /// Add Or Edit
  16145. /// </summary>
  16146. /// <param name="_dto"></param>
  16147. /// <returns></returns>
  16148. [HttpPost]
  16149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16150. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16151. {
  16152. #region 参数验证
  16153. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16154. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16155. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16156. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16157. #region 页面操作权限验证
  16158. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16159. if (_dto.Id == 0) //添加
  16160. {
  16161. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16162. }
  16163. else if (_dto.Id >= 0) //修改
  16164. {
  16165. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16166. }
  16167. #endregion
  16168. #endregion
  16169. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16170. if (viewData.Code != 0)
  16171. {
  16172. return Ok(JsonView(false, viewData.Msg));
  16173. }
  16174. return Ok(JsonView(true));
  16175. }
  16176. /// <summary>
  16177. /// 接团客户名单
  16178. /// json字符串 AddMultiple(添加多个)
  16179. /// </summary>
  16180. /// <param name="_dto"></param>
  16181. /// <returns></returns>
  16182. [HttpPost]
  16183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16184. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16185. {
  16186. #region 参数验证
  16187. string jsonLabel = _dto.JsonLabel;
  16188. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16189. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16190. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16191. #region 页面操作权限验证
  16192. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16193. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16194. #endregion
  16195. #endregion
  16196. var request = new TourClientListAddMultipleDto();
  16197. request.DiId = _dto.DiId;
  16198. request.UserId = _dto.UserId;
  16199. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16200. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16201. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16202. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16203. var infos = new List<TourClientListInfo>();
  16204. foreach (var data in datas)
  16205. {
  16206. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16207. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16208. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16209. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16210. {
  16211. continue;
  16212. }
  16213. infos.Add(new TourClientListInfo()
  16214. {
  16215. IsAccompany = 1,
  16216. LastName = lastName,
  16217. FirstName = firstName,
  16218. Pinyin = lastNameEn + @"/" + firstNameEn,
  16219. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16220. CompanyFullName = data.CompanyFullName,
  16221. Job = data.Job
  16222. });
  16223. }
  16224. if (infos.Any())
  16225. {
  16226. var viewData = await _tourClientListRep._AddMultiple(request);
  16227. if (viewData.Code != 0)
  16228. {
  16229. return Ok(JsonView(false, viewData.Msg));
  16230. }
  16231. return Ok(JsonView(true));
  16232. }
  16233. return Ok(JsonView(false));
  16234. }
  16235. /// <summary>
  16236. /// 接团客户名单
  16237. /// AddMultiple(添加多个)
  16238. /// </summary>
  16239. /// <param name="_dto"></param>
  16240. /// <returns></returns>
  16241. [HttpPost]
  16242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16243. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16244. {
  16245. #region 参数验证
  16246. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16247. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16248. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16249. #region 页面操作权限验证
  16250. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16251. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16252. #endregion
  16253. #endregion
  16254. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16255. if (viewData.Code != 0)
  16256. {
  16257. return Ok(JsonView(false, viewData.Msg));
  16258. }
  16259. return Ok(JsonView(true));
  16260. }
  16261. /// <summary>
  16262. /// 接团客户名单
  16263. /// Del
  16264. /// </summary>
  16265. /// <param name="_dto"></param>
  16266. /// <returns></returns>
  16267. [HttpPost]
  16268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16269. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16270. {
  16271. #region 参数验证
  16272. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16273. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16274. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16275. #region 页面操作权限验证
  16276. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16277. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16278. #endregion
  16279. #endregion
  16280. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16281. if (viewData.Code != 0)
  16282. {
  16283. return Ok(JsonView(false, viewData.Msg));
  16284. }
  16285. return Ok(JsonView(true));
  16286. }
  16287. /// <summary>
  16288. /// 接团客户名单
  16289. /// 文件下载 客户名单
  16290. /// </summary>
  16291. /// <param name="_dto"></param>
  16292. /// <returns></returns>
  16293. [HttpPost]
  16294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16295. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16296. {
  16297. #region 参数验证
  16298. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16299. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16300. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16301. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16302. #region 页面操作权限验证
  16303. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16304. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16305. #endregion
  16306. #endregion
  16307. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16308. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16309. From Grp_TourClientList tcl
  16310. Left Join
  16311. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16312. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16313. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16314. From Crm_DeleClient dc
  16315. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16316. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16317. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16318. Where dc.IsDel = 0) temp
  16319. On temp.DcId =tcl.ClientId
  16320. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16321. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16322. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16323. //载入模板
  16324. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16325. if (_dto.Language == 1)
  16326. {
  16327. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16328. }
  16329. //载入模板
  16330. var doc = new Document(tempPath);
  16331. DocumentBuilder builder = new DocumentBuilder(doc);
  16332. //获取word里所有表格
  16333. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16334. //获取所填表格的序数
  16335. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16336. var rowStart = tableOne.Rows[0]; //获取第1行
  16337. if (_dto.Language == 0)
  16338. {
  16339. //循环赋值
  16340. for (int i = 0; i < DcList.Count; i++)
  16341. {
  16342. EncryptionProcessor.DecryptProperties(DcList[i]);
  16343. builder.MoveToCell(0, i + 1, 0, 0);
  16344. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16345. builder.MoveToCell(0, i + 1, 1, 0);
  16346. int sex = DcList[i].Sex;
  16347. string sexStr = string.Empty;
  16348. if (sex == 0) sexStr = "男";
  16349. else if (sex == 1) sexStr = "女";
  16350. else sexStr = "未设置";
  16351. builder.Write(sexStr);
  16352. builder.MoveToCell(0, i + 1, 2, 0);
  16353. string birthDay = DcList[i].BirthDay;
  16354. string birthDayStr = string.Empty;
  16355. if (!string.IsNullOrEmpty(birthDay))
  16356. {
  16357. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16358. }
  16359. builder.Write(birthDayStr);
  16360. builder.MoveToCell(0, i + 1, 3, 0);
  16361. string company = "";
  16362. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16363. {
  16364. company = DcList[i].CompanyFullName.ToString();
  16365. }
  16366. builder.Write(company);
  16367. builder.MoveToCell(0, i + 1, 4, 0);
  16368. builder.Write(DcList[i].Job);
  16369. }
  16370. }
  16371. else if (_dto.Language == 1)
  16372. {
  16373. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16374. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16375. List<string> transArrayStr = new List<string>();
  16376. string transStrRes1 = "";
  16377. for (int i = 0; i < DcList.Count; i++)
  16378. {
  16379. var dc = DcList[i];
  16380. EncryptionProcessor.DecryptProperties(dc);
  16381. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16382. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16383. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16384. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16385. else transStrRes1 += $"{str1}|";
  16386. }
  16387. //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";
  16388. string transStrRes = "";
  16389. if (transStrRes1.Length > 0)
  16390. {
  16391. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16392. }
  16393. //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
  16394. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16395. //List<string> transArray = new List<string> { };
  16396. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16397. if (transStrRes.Contains("|"))
  16398. {
  16399. string[] transArray1 = transStrRes.Split('|');
  16400. if (transArray1.Length > 0)
  16401. {
  16402. foreach (var item in transArray1)
  16403. {
  16404. if (item.Contains("&"))
  16405. {
  16406. string[] transArray2 = item.Split('&');
  16407. int index = 0;
  16408. string companyName = "", job = "";
  16409. if (transArray2.Length > 0)
  16410. {
  16411. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16412. if (1 < transArray2.Length) companyName = transArray2[1];
  16413. if (2 < transArray2.Length) job = transArray2[2];
  16414. }
  16415. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16416. }
  16417. }
  16418. }
  16419. }
  16420. //循环赋值
  16421. for (int i = 0; i < DcList.Count; i++)
  16422. {
  16423. string PYName = "";
  16424. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16425. {
  16426. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16427. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16428. PYName = PY_First + " " + PY_Last;
  16429. }
  16430. else
  16431. {
  16432. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16433. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16434. PYName = PY_First + " " + PY_Last;
  16435. }
  16436. builder.MoveToCell(0, i + 1, 0, 0);
  16437. builder.Write(PYName);
  16438. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16439. builder.MoveToCell(0, i + 1, 1, 0);
  16440. builder.Write(sex);
  16441. DateTime birthDt;
  16442. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16443. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16444. builder.MoveToCell(0, i + 1, 2, 0);
  16445. builder.Write(birthday);
  16446. string company = string.Empty, job = string.Empty;
  16447. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16448. if (dcTransInfo != null)
  16449. {
  16450. company = dcTransInfo.CompanyName;
  16451. job = dcTransInfo.Job;
  16452. }
  16453. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16454. {
  16455. //查询对照表
  16456. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16457. if (tempCec != null)
  16458. {
  16459. company = tempCec.enName;
  16460. }
  16461. //翻译
  16462. else
  16463. {
  16464. }
  16465. }
  16466. builder.MoveToCell(0, i + 1, 3, 0);
  16467. builder.Write(company);
  16468. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16469. {
  16470. //查询对照表
  16471. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16472. if (tempPec != null)
  16473. {
  16474. job = tempPec.enName;
  16475. }
  16476. //翻译
  16477. else
  16478. {
  16479. }
  16480. }
  16481. builder.MoveToCell(0, i + 1, 4, 0);
  16482. builder.Write(job);
  16483. }
  16484. }
  16485. //删除多余行
  16486. while (tableOne.Rows.Count > DcList.Count + 1)
  16487. {
  16488. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16489. }
  16490. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16491. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16492. doc.Save(fileDir);
  16493. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16494. return Ok(JsonView(true, "操作成功!", Url));
  16495. }
  16496. private class TranslateInfo
  16497. {
  16498. public int Index { get; set; }
  16499. public string CompanyName { get; set; }
  16500. public string Job { get; set; }
  16501. }
  16502. #endregion
  16503. #region 团组倒推表
  16504. /// <summary>
  16505. /// 倒推表基础数据
  16506. /// Init
  16507. /// </summary>
  16508. /// <returns></returns>
  16509. [HttpPost]
  16510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16511. public async Task<IActionResult> PostInvertedListInit()
  16512. {
  16513. var viewData = await _invertedListRep._Init();
  16514. if (viewData.Code != 0)
  16515. {
  16516. return Ok(JsonView(false, viewData.Msg));
  16517. }
  16518. return Ok(JsonView(viewData.Data));
  16519. }
  16520. /// <summary>
  16521. /// 倒推表
  16522. /// Info
  16523. /// </summary>
  16524. /// <param name="dto"></param>
  16525. /// <returns></returns>
  16526. [HttpPost]
  16527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16528. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16529. {
  16530. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16531. if (viewData.Code != 0)
  16532. {
  16533. return Ok(JsonView(false, viewData.Msg));
  16534. }
  16535. return Ok(JsonView(viewData.Data));
  16536. }
  16537. /// <summary>
  16538. /// 倒推表
  16539. /// Create
  16540. /// </summary>
  16541. /// <param name="dto"></param>
  16542. /// <returns></returns>
  16543. [HttpPost]
  16544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16545. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16546. {
  16547. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16548. if (viewData.Code != 0)
  16549. {
  16550. return Ok(JsonView(false, viewData.Msg));
  16551. }
  16552. return Ok(JsonView(viewData.Data));
  16553. }
  16554. /// <summary>
  16555. /// 倒推表
  16556. /// Update
  16557. /// </summary>
  16558. /// <param name="dto"></param>
  16559. /// <returns></returns>
  16560. [HttpPost]
  16561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16562. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16563. {
  16564. var viewData = await _invertedListRep._Update(dto);
  16565. if (viewData.Code != 0)
  16566. {
  16567. return Ok(JsonView(false, viewData.Msg));
  16568. }
  16569. return Ok(JsonView(viewData.Data));
  16570. }
  16571. /// <summary>
  16572. /// 倒推表
  16573. /// File Download
  16574. /// </summary>
  16575. /// <param name="dto"></param>
  16576. /// <returns></returns>
  16577. [HttpPost]
  16578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16579. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16580. {
  16581. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16582. if (info2.Code != 0)
  16583. {
  16584. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16585. }
  16586. var info1 = info2.Data as InvertedListInfoView;
  16587. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16588. string teamName = "";
  16589. if (info != null) teamName = info.TeamName;
  16590. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  16591. var doc = new Document();
  16592. var builder = new DocumentBuilder(doc);
  16593. #region old insert
  16594. ////载入模板
  16595. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  16596. //Document doc = new Document(tempPath);
  16597. //DocumentBuilder builder = new DocumentBuilder(doc);
  16598. //利用键值对存放数据
  16599. //Dictionary<string, string> dic = new Dictionary<string, string>();
  16600. //dic.Add("TeamName", teamName);
  16601. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16602. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16603. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  16604. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16605. //dic.Add("SQRemark", info1.ApprovalRemark);
  16606. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16607. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16608. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16609. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  16610. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16611. //dic.Add("QZRemark", info1.VisaInformationRemark);
  16612. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16613. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  16614. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16615. //dic.Add("CQRemark", info1.IssueVisaRemark);
  16616. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16617. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16618. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16619. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16620. //#region 填充word模板书签内容
  16621. //foreach (var key in dic.Keys)
  16622. //{
  16623. // builder.MoveToBookmark(key);
  16624. // builder.Write(dic[key]);
  16625. //}
  16626. //#endregion
  16627. #endregion
  16628. #region New Insert
  16629. string titleFont = $"仿宋",
  16630. contentFont = $"仿宋";
  16631. var fontColor = Color.FromArgb(64, 64, 64);
  16632. //设置标题 团组名称
  16633. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16634. builder.Font.Name = titleFont;
  16635. builder.Font.Color = fontColor;
  16636. builder.Font.Size = 12;
  16637. builder.Font.Bold = true;
  16638. builder.Writeln(teamName);
  16639. //设置副标题 团组出访时间
  16640. builder.Font.Size = 12;
  16641. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  16642. builder.Writeln();
  16643. var backgroundColor = Color.FromArgb(199, 199, 199);
  16644. var table = builder.StartTable();
  16645. builder.InsertCell();
  16646. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  16647. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  16648. builder.CellFormat.Borders.LineWidth = 1;
  16649. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  16650. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  16651. builder.RowFormat.Height = 40;
  16652. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16653. builder.Font.Name = contentFont;
  16654. builder.Font.Size = 12;
  16655. builder.Font.Bold = true;
  16656. builder.Font.Color = fontColor;
  16657. builder.Write("时间");
  16658. builder.InsertCell();
  16659. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  16660. builder.Write("流程");
  16661. builder.InsertCell();
  16662. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  16663. builder.Write("说明");
  16664. builder.EndRow();
  16665. //报批资料准备
  16666. if (info1.IsSelectedAirportd)
  16667. {
  16668. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  16669. }
  16670. //报批/提供送签资料
  16671. if (info1.IsSelectedApprovalData)
  16672. {
  16673. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  16674. }
  16675. //出批件护照办理
  16676. if (info1.IsSelectedIssueApproval)
  16677. {
  16678. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  16679. }
  16680. //签证资料准备
  16681. if (info1.IsSelectedVisaInfo)
  16682. {
  16683. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  16684. }
  16685. //送签
  16686. if (info1.IsSelectedSendVisa)
  16687. {
  16688. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  16689. }
  16690. //出签
  16691. if (info1.IsSelectedIssueVisa)
  16692. {
  16693. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  16694. }
  16695. //机票
  16696. if (info1.IsSelectedAirTicket)
  16697. {
  16698. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  16699. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  16700. }
  16701. //酒店
  16702. if (info1.IsSelectedHotel)
  16703. {
  16704. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  16705. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  16706. }
  16707. //开行前会
  16708. if (info1.IsSelectedPreTripMeeting)
  16709. {
  16710. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  16711. }
  16712. //送机
  16713. if (info1.IsSelectedAirportdDropOff)
  16714. {
  16715. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  16716. }
  16717. builder.EndTable();
  16718. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  16719. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  16720. for (int i = 0; i < table.Rows.Count; i++)
  16721. {
  16722. var row = table.Rows[i];
  16723. //设置宽度
  16724. row.Cells[0].CellFormat.Width = 20.00;
  16725. row.Cells[1].CellFormat.Width = 30.00;
  16726. row.Cells[2].CellFormat.Width = 50.00;
  16727. if (i != 0)
  16728. {
  16729. //边框设置
  16730. InvertedListFileDownloadSetBorders(row.Cells, 0);
  16731. InvertedListFileDownloadSetBorders(row.Cells, 1);
  16732. InvertedListFileDownloadSetBorders(row.Cells, 2);
  16733. }
  16734. }
  16735. #region 页脚插入图片
  16736. // 创建页脚
  16737. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  16738. doc.FirstSection.HeadersFooters.Add(footer);
  16739. Paragraph para = new Paragraph(doc);
  16740. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  16741. footer.AppendChild(para);
  16742. builder.MoveTo(para);
  16743. string imagePath = "./Images/FMGJ_Log.png";
  16744. builder.InsertImage(imagePath);
  16745. #endregion
  16746. #endregion
  16747. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16748. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  16749. string filePath = fileDir + $@"InvertedList/{fileName}";
  16750. doc.Save(filePath);
  16751. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16752. return Ok(JsonView(true, "操作成功!", Url));
  16753. }
  16754. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  16755. {
  16756. var fontColor = Color.FromArgb(64, 64, 64);
  16757. builder.InsertCell();
  16758. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  16759. builder.RowFormat.Height = 40;
  16760. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16761. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16762. builder.Font.Name = fontName;
  16763. builder.Font.Size = 8;
  16764. builder.Font.Bold = true;
  16765. builder.Font.Color = fontColor;
  16766. builder.Write(dateTime);
  16767. builder.InsertCell();
  16768. builder.Font.Size = 9;
  16769. builder.Font.Bold = true;
  16770. builder.Font.Color = fontColor;
  16771. builder.Write(content);
  16772. builder.InsertCell();
  16773. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16774. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16775. builder.Font.Size = 9;
  16776. builder.Font.Bold = false;
  16777. builder.Font.Color = fontColor;
  16778. builder.Write(reamrk);
  16779. builder.EndRow();
  16780. }
  16781. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  16782. {
  16783. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  16784. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  16785. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  16786. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  16787. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  16788. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  16789. }
  16790. #endregion
  16791. #region 会务倒推表
  16792. /// <summary>
  16793. /// 会务倒推表
  16794. /// Init
  16795. /// </summary>
  16796. /// <returns></returns>
  16797. [HttpPost]
  16798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16799. public async Task<IActionResult> InforRetrogressTableInit()
  16800. {
  16801. var groupData = await _groupRepository.PostShareGroupInfos(1);
  16802. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  16803. return Ok(JsonView(false, groupData.Msg));
  16804. }
  16805. /// <summary>
  16806. /// 会务倒推表
  16807. /// ExcelDownload
  16808. /// </summary>
  16809. /// <param name="dto"></param>
  16810. /// <returns></returns>
  16811. [HttpPost]
  16812. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  16813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16814. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  16815. {
  16816. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  16817. var validatorRes = await validator.ValidateAsync(dto);
  16818. if (!validatorRes.IsValid)
  16819. {
  16820. StringBuilder sb = new StringBuilder();
  16821. foreach (var item in validatorRes.Errors)
  16822. {
  16823. sb.AppendLine(item.ErrorMessage);
  16824. }
  16825. return Ok(JsonView(false, sb.ToString()));
  16826. }
  16827. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  16828. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  16829. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  16830. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  16831. #region Excel
  16832. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  16833. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  16834. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  16835. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  16836. var fileNamePrefix = string.Empty;
  16837. if (days >= 30)
  16838. {
  16839. tempPath += $"会务工作倒推进度表(30天).xlsx";
  16840. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  16841. }
  16842. else if (days < 30 && days > 7)
  16843. {
  16844. tempPath += $"会务工作倒推进度表(15天).xlsx";
  16845. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  16846. }
  16847. else if (days <= 7)
  16848. {
  16849. tempPath += $"会务工作倒推进度表(7天).xlsx";
  16850. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  16851. }
  16852. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  16853. fileName = CommonFun.ValidFileName(fileName);
  16854. //载入模板
  16855. WorkbookDesigner designer = new WorkbookDesigner();
  16856. designer.Workbook = new Workbook(tempPath);
  16857. designer.Process();
  16858. if (!Directory.Exists(savePath))
  16859. {
  16860. Directory.CreateDirectory(savePath);
  16861. }
  16862. string serverPath = $"{savePath}{fileName}";
  16863. designer.Workbook.Save(serverPath);
  16864. string rst = $"{servicePath}{ftpPath}{fileName}";
  16865. #endregion
  16866. return Ok(JsonView(new { url = rst }));
  16867. }
  16868. #endregion
  16869. #region 三公签证费用(签证费、代办费)
  16870. /// <summary>
  16871. /// 三公签证费用(签证费、代办费)
  16872. /// List
  16873. /// </summary>
  16874. /// <returns></returns>
  16875. [HttpPost]
  16876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16877. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16878. {
  16879. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16880. if (_view.Code != 0)
  16881. {
  16882. return Ok(JsonView(false, _view.Msg));
  16883. }
  16884. return Ok(JsonView(true, "操作成功!", _view.Data));
  16885. }
  16886. /// <summary>
  16887. /// 三公签证费用(签证费、代办费)
  16888. /// Add Or Update
  16889. /// </summary>
  16890. /// <returns></returns>
  16891. [HttpPost]
  16892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16893. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16894. {
  16895. var _view = await _visaFeeInfoRep._Update(_dto);
  16896. if (_view.Code != 0)
  16897. {
  16898. return Ok(JsonView(false, _view.Msg));
  16899. }
  16900. return Ok(JsonView(true, _view.Msg));
  16901. }
  16902. #endregion
  16903. #region 酒店询价
  16904. /// <summary>
  16905. /// 酒店询价
  16906. /// Init
  16907. /// </summary>
  16908. /// <returns></returns>
  16909. [HttpPost]
  16910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16911. public async Task<IActionResult> PostHotelInquiryInit()
  16912. {
  16913. var res = await _hotelInquiryRep._Init();
  16914. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16915. return Ok(JsonView(true, res.Msg, res.Data));
  16916. }
  16917. /// <summary>
  16918. /// 酒店询价
  16919. /// page Item
  16920. /// </summary>
  16921. /// <param name="_dto"></param>
  16922. /// <returns></returns>
  16923. [HttpPost]
  16924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16925. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16926. {
  16927. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16928. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16929. var view = res.Data as PageDataViewBase;
  16930. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16931. }
  16932. /// <summary>
  16933. /// 酒店询价
  16934. /// info
  16935. /// </summary>
  16936. /// <param name="_dto"></param>
  16937. /// <returns></returns>
  16938. [HttpPost]
  16939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16940. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16941. {
  16942. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  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. /// Add Or Edit
  16949. /// </summary>
  16950. /// <param name="_dto"></param>
  16951. /// <returns></returns>
  16952. [HttpPost]
  16953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16954. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16955. {
  16956. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16957. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16958. return Ok(JsonView(true, res.Msg, res.Data));
  16959. }
  16960. /// <summary>
  16961. /// 酒店询价
  16962. /// Del
  16963. /// </summary>
  16964. /// <param name="_dto"></param>
  16965. /// <returns></returns>
  16966. [HttpPost]
  16967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16968. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16969. {
  16970. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16971. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16972. return Ok(JsonView(true, res.Msg, res.Data));
  16973. }
  16974. #endregion
  16975. #region 下载匹配op行程单
  16976. /// <summary>
  16977. /// 匹配op行程单
  16978. /// Init
  16979. /// </summary>
  16980. /// <param name="dto">团组列表请求dto</param>
  16981. /// <returns></returns>
  16982. [HttpPost]
  16983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16984. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16985. {
  16986. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16987. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16988. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16989. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16990. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16991. .Where(it => it.IsDel == 0)
  16992. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16993. .OrderByDescending(it => it.CreateUserId)
  16994. .ToList();
  16995. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16996. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16997. var diids = groupInfos.Select(it => it.Id).ToList();
  16998. List<string> countrys = new List<string>();
  16999. foreach (var item in country)
  17000. {
  17001. var data = _groupRepository.FormartTeamName(item);
  17002. var dataArray = _groupRepository.GroupSplitCountry(data);
  17003. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17004. }
  17005. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17006. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17007. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17008. foreach (var item in areaItem)
  17009. {
  17010. string areaStr = item.Value;
  17011. if (!string.IsNullOrEmpty(areaStr))
  17012. {
  17013. string[] str1 = areaStr.Split("-");
  17014. if (str1.Length > 0)
  17015. {
  17016. areaArray.AddRange(str1);
  17017. }
  17018. }
  17019. }
  17020. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17021. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17022. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17023. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17024. .ToList();
  17025. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17026. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17027. .Where(it => countriesIds.Contains(it.Id))
  17028. .Select(it => new { it.Id, Name = it.Name_CN })
  17029. .ToList();
  17030. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17031. .Select(it => it.TeamName).ToList();
  17032. stopwatch.Stop();
  17033. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17034. }
  17035. ///// <summary>
  17036. ///// 匹配op行程单
  17037. ///// Init 查询区域数据
  17038. ///// </summary>
  17039. ///// <param name="dto">团组列表请求dto</param>
  17040. ///// <returns></returns>
  17041. //[HttpPost]
  17042. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17043. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17044. //{
  17045. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17046. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17047. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17048. // if (string.IsNullOrEmpty(countriesDataStr))
  17049. // {
  17050. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17051. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17052. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17053. // }
  17054. // else
  17055. // {
  17056. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17057. // }
  17058. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17059. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17060. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17061. // List<dynamic> childList = new List<dynamic>();
  17062. // int parentId = dto.CountriesId;
  17063. // if (provinceData.Count > 1)
  17064. // {
  17065. // foreach (var item1 in provinceData)
  17066. // {
  17067. // List<dynamic> childList1 = new List<dynamic>();
  17068. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17069. // foreach (var item2 in citiesData1)
  17070. // {
  17071. // List<dynamic> childList2 = new List<dynamic>();
  17072. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17073. // foreach (var item3 in countiesData1)
  17074. // {
  17075. // childList2.Add(new
  17076. // {
  17077. // id = item3.Id,
  17078. // parentId = item2.Id,
  17079. // level = "district",
  17080. // name = item3.Name_CN,
  17081. // });
  17082. // }
  17083. // childList1.Add(new
  17084. // {
  17085. // id = item2.Id,
  17086. // parentId = item1.Id,
  17087. // level = "city",
  17088. // name = item2.Name_CN,
  17089. // childList = childList2
  17090. // });
  17091. // }
  17092. // childList.Add(new
  17093. // {
  17094. // id = item1.Id,
  17095. // parentId = parentId,
  17096. // level = "province",
  17097. // name = item1.Name_CN,
  17098. // childList = childList1
  17099. // });
  17100. // }
  17101. // //城市
  17102. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17103. // foreach (var item2 in citiesData2)
  17104. // {
  17105. // List<dynamic> childList22 = new List<dynamic>();
  17106. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17107. // foreach (var item3 in countiesData1)
  17108. // {
  17109. // childList22.Add(new
  17110. // {
  17111. // id = item3.Id,
  17112. // parentId = item2.Id,
  17113. // level = "district",
  17114. // name = item3.Name_CN,
  17115. // });
  17116. // }
  17117. // childList.Add(new
  17118. // {
  17119. // id = item2.Id,
  17120. // parentId = parentId,
  17121. // level = "city",
  17122. // name = item2.Name_CN,
  17123. // childList = childList22
  17124. // });
  17125. // }
  17126. // }
  17127. // else
  17128. // {
  17129. // foreach (var item2 in citiesData)
  17130. // {
  17131. // string cname = item2.Name_CN;
  17132. // List<dynamic> childList1 = new List<dynamic>();
  17133. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17134. // foreach (var item3 in countiesData1)
  17135. // {
  17136. // childList1.Add(new
  17137. // {
  17138. // Id = item3.Id,
  17139. // parentId = item2.Id,
  17140. // level = "district",
  17141. // name = item3.Name_CN
  17142. // });
  17143. // }
  17144. // childList.Add(new
  17145. // {
  17146. // id = item2.Id,
  17147. // parentId = parentId,
  17148. // level = "city",
  17149. // name = item2.Name_CN,
  17150. // childList = childList1
  17151. // });
  17152. // }
  17153. // }
  17154. // stopwatch.Stop();
  17155. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17156. //}
  17157. /// <summary>
  17158. /// 匹配op行程单
  17159. /// 接团信息列表 Page
  17160. /// </summary>
  17161. /// <param name="dto">团组列表请求dto</param>
  17162. /// <returns></returns>
  17163. [HttpPost]
  17164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17165. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17166. {
  17167. var swatch = new Stopwatch();
  17168. swatch.Start();
  17169. #region 参数验证
  17170. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17171. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17172. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17173. #region 页面操作权限验证
  17174. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17175. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17176. #endregion
  17177. #endregion
  17178. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17179. {
  17180. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17181. //string sqlWhere = "";
  17182. if (!string.IsNullOrEmpty(dto.Country))
  17183. {
  17184. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17185. }
  17186. if (!string.IsNullOrEmpty(dto.Area))
  17187. {
  17188. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17189. }
  17190. if (!string.IsNullOrEmpty(dto.TeamName))
  17191. {
  17192. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17193. }
  17194. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17195. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17196. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17197. swatch.Stop();
  17198. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17199. }
  17200. else
  17201. {
  17202. return Ok(JsonView(false, "查询失败"));
  17203. }
  17204. }
  17205. /// <summary>
  17206. /// 匹配op行程单
  17207. /// 行程单下载
  17208. /// </summary>
  17209. /// <param name="dto">团组列表请求dto</param>
  17210. /// <returns></returns>
  17211. [HttpPost]
  17212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17213. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17214. {
  17215. #region 参数验证
  17216. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17217. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17218. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17219. #region 页面操作权限验证
  17220. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17221. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17222. #endregion
  17223. #endregion
  17224. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17225. {
  17226. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17227. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17228. }
  17229. else
  17230. {
  17231. return Ok(JsonView(false, "下载失败!"));
  17232. }
  17233. }
  17234. #endregion
  17235. #region 国家信息 数据 注释
  17236. //[HttpPost]
  17237. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17238. //{
  17239. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17240. // foreach (var item in dto)
  17241. // {
  17242. // infos.Add(new Grp_GroupsTaskAssignment()
  17243. // {
  17244. // DIId = item,
  17245. // CTId = 82,
  17246. // UId = 248,
  17247. // IsEnable = 1,
  17248. // CreateUserId = 233,
  17249. // CreateTime = DateTime.Now,
  17250. // IsDel = 0
  17251. // });
  17252. // infos.Add(new Grp_GroupsTaskAssignment()
  17253. // {
  17254. // DIId = item,
  17255. // CTId = 82,
  17256. // UId = 286,
  17257. // IsEnable = 1,
  17258. // CreateUserId = 233,
  17259. // CreateTime = DateTime.Now,
  17260. // IsDel = 0
  17261. // });
  17262. // }
  17263. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17264. // return Ok("操作成功");
  17265. //}
  17266. //public class paramJsonDto
  17267. //{
  17268. // public List<CountriesInfo> str { get; set; }
  17269. //}
  17270. //[HttpPost]
  17271. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17272. //{
  17273. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17274. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17275. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17276. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17277. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17278. // _sqlSugar.BeginTran();
  17279. // int countitiesIndex = 0;
  17280. // foreach (var item in dto.str)
  17281. // {
  17282. // dynamic data = item.c;
  17283. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17284. // if (data != null)
  17285. // {
  17286. // countitiesIndex++;
  17287. // foreach (var item1 in data)
  17288. // {
  17289. // string cnname = item1.cn;
  17290. // string enname = item1.en;
  17291. // Sys_Cities provinceInfo = new Sys_Cities()
  17292. // {
  17293. // CountriesId = countriesId,
  17294. // Name_CN = cnname,
  17295. // Name_EN = enname,
  17296. // ParentId = 0,
  17297. // IsCapital = 1,
  17298. // CreateUserId = 208,
  17299. // CreateTime = DateTime.Now,
  17300. // IsDel = 0
  17301. // };
  17302. // if (item1.lv == "province") //省份
  17303. // {
  17304. // provinceInfo.Level = 1;
  17305. // int provinceId = 0;
  17306. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17307. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17308. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17309. // var data1 = item1.c;
  17310. // foreach (var item2 in data1)
  17311. // {
  17312. // if (item2.lv == "city")
  17313. // {
  17314. // string citycnname = item2.cn;
  17315. // string cityenname = item2.en;
  17316. // Sys_Cities cityInfo = new Sys_Cities()
  17317. // {
  17318. // CountriesId = countriesId,
  17319. // ParentId = provinceId,
  17320. // Level = 2,
  17321. // Name_CN = citycnname,
  17322. // Name_EN = cityenname,
  17323. // IsCapital = 1,
  17324. // CreateUserId = 208,
  17325. // CreateTime = DateTime.Now,
  17326. // IsDel = 0
  17327. // };
  17328. // if (item2.c != null)
  17329. // {
  17330. // int cityId = 0;
  17331. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17332. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17333. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17334. // foreach (var item3 in item2.c)
  17335. // {
  17336. // if (item3.lv == "district")
  17337. // {
  17338. // var districtInfo = new Sys_Cities()
  17339. // {
  17340. // CountriesId = countriesId,
  17341. // Name_CN = item3.cn,
  17342. // Name_EN = item3.en,
  17343. // Level = 3,
  17344. // ParentId = cityId,
  17345. // IsCapital = 1,
  17346. // CreateUserId = 208,
  17347. // CreateTime = DateTime.Now,
  17348. // IsDel = 0
  17349. // };
  17350. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17351. // //{
  17352. // districts.Add(districtInfo);
  17353. // //}
  17354. // }
  17355. // }
  17356. // }
  17357. // else
  17358. // {
  17359. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17360. // //{
  17361. // cities.Add(cityInfo);
  17362. // //}
  17363. // }
  17364. // }
  17365. // }
  17366. // }
  17367. // else if (item1.lv == "city")//城市
  17368. // {
  17369. // provinceInfo.Level = 2;
  17370. // if (item1.c != null)
  17371. // {
  17372. // int cityId = 0;
  17373. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17374. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17375. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17376. // foreach (var item3 in item1.c)
  17377. // {
  17378. // if (item3.lv == "district")
  17379. // {
  17380. // var districtInfo = new Sys_Cities()
  17381. // {
  17382. // CountriesId = countriesId,
  17383. // Name_CN = item3.cn,
  17384. // Name_EN = item3.en,
  17385. // Level = 3,
  17386. // ParentId = cityId,
  17387. // IsCapital = 1,
  17388. // CreateUserId = 208,
  17389. // CreateTime = DateTime.Now,
  17390. // IsDel = 0
  17391. // };
  17392. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17393. // //{
  17394. // districts.Add(districtInfo);
  17395. // //}
  17396. // }
  17397. // }
  17398. // }
  17399. // else
  17400. // {
  17401. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17402. // //{
  17403. // cities.Add(provinceInfo);
  17404. // //}
  17405. // }
  17406. // }
  17407. // }
  17408. // }
  17409. // }
  17410. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17411. // cities = cities.Distinct().ToList();
  17412. // districts = districts.Distinct().ToList();
  17413. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17414. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17415. // cities.AddRange(districts);
  17416. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17417. // //_sqlSugar.RollbackTran();
  17418. // _sqlSugar.CommitTran();
  17419. // return Ok(JsonView(false, "操作成功!"));
  17420. //}
  17421. //[HttpPost]
  17422. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17423. //{
  17424. // List<CountitiesInfo> infos = dto.MyProperty;
  17425. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17426. // _sqlSugar.BeginTran();
  17427. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17428. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17429. // foreach (var item in infos)
  17430. // {
  17431. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17432. // if (countryInfo != null)
  17433. // {
  17434. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17435. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17436. // if (cityInfo1 != null)
  17437. // {
  17438. // cityInfo1.IsCapital = 0;
  17439. // cityInfos.Add(cityInfo1);
  17440. // }
  17441. // }
  17442. // }
  17443. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17444. // .UpdateColumns(it => it.IsCapital)
  17445. // .WhereColumns(it => it.Id)
  17446. // .ExecuteCommand();
  17447. // //_sqlSugar.RollbackTran();
  17448. // _sqlSugar.CommitTran();
  17449. // return Ok(JsonView(false, "操作成功!"));
  17450. //}
  17451. //public class CounrtiesDto
  17452. //{
  17453. // public List<CountitiesInfo> MyProperty { get; set; }
  17454. //}
  17455. //public class CountitiesInfo
  17456. //{
  17457. // /// <summary>
  17458. // /// 圣约翰
  17459. // /// </summary>
  17460. // public string capital_name_chinese { get; set; }
  17461. // /// <summary>
  17462. // ///
  17463. // /// </summary>
  17464. // public string capital_name { get; set; }
  17465. // /// <summary>
  17466. // ///
  17467. // /// </summary>
  17468. // public string country_type { get; set; }
  17469. // /// <summary>
  17470. // /// 安提瓜和巴布达
  17471. // /// </summary>
  17472. // public string country_name_chinese { get; set; }
  17473. // /// <summary>
  17474. // /// 安提瓜和巴布达
  17475. // /// </summary>
  17476. // public string country_name_chinese_short { get; set; }
  17477. // /// <summary>
  17478. // /// 安提瓜和巴布达
  17479. // /// </summary>
  17480. // public string country_name_chinese_UN { get; set; }
  17481. // /// <summary>
  17482. // ///
  17483. // /// </summary>
  17484. // public string country_name_english_abbreviation { get; set; }
  17485. // /// <summary>
  17486. // ///
  17487. // /// </summary>
  17488. // public string country_name_english_formal { get; set; }
  17489. // /// <summary>
  17490. // ///
  17491. // /// </summary>
  17492. // public string country_name_english_UN { get; set; }
  17493. // /// <summary>
  17494. // ///
  17495. // /// </summary>
  17496. // public string continent_name { get; set; }
  17497. // /// <summary>
  17498. // ///
  17499. // /// </summary>
  17500. // public string subregion_name { get; set; }
  17501. // /// <summary>
  17502. // ///
  17503. // /// </summary>
  17504. // public string country_code2 { get; set; }
  17505. // /// <summary>
  17506. // ///
  17507. // /// </summary>
  17508. // public string country_code3 { get; set; }
  17509. // /// <summary>
  17510. // ///
  17511. // /// </summary>
  17512. // public string phone_code { get; set; }
  17513. //}
  17514. //public class CountriesInfo : BasicInfo
  17515. //{
  17516. // public List<CitiesInfo> c { get; set; }
  17517. //}
  17518. //public class CitiesInfo : BasicInfo
  17519. //{
  17520. // public List<AreaInfo> c { get; set; }
  17521. //}
  17522. //public class AreaInfo : BasicInfo
  17523. //{
  17524. // public List<AreaInfo> c { get; set; }
  17525. //}
  17526. //public class BasicInfo
  17527. //{
  17528. // public string code { get; set; }
  17529. // public string cn { get; set; }
  17530. // public string lv { get; set; }
  17531. // public string en { get; set; }
  17532. //}
  17533. #endregion
  17534. #region 查看邀请方
  17535. /// <summary>
  17536. /// 查看邀请方
  17537. /// 邀请方信息 Init
  17538. /// </summary>
  17539. /// <param name="dto"></param>
  17540. /// <returns></returns>
  17541. [HttpPost]
  17542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17543. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17544. {
  17545. string sqlWhere = string.Empty;
  17546. if (!string.IsNullOrEmpty(dto.Search))
  17547. {
  17548. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17549. }
  17550. string sql = string.Format($@"Select
  17551. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17552. Id,
  17553. UnitName
  17554. From Res_InvitationOfficialActivityData
  17555. Where IsDel = 0
  17556. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17557. RefAsync<int> total = 0;
  17558. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17559. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17560. }
  17561. /// <summary>
  17562. /// 查看邀请方
  17563. /// 国家信息 Init
  17564. /// </summary>
  17565. /// <param name="dto"></param>
  17566. /// <returns></returns>
  17567. [HttpPost]
  17568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17569. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17570. {
  17571. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17572. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17573. var diids = groupInfos.Select(it => it.Id).ToList();
  17574. List<string> countrys = new List<string>();
  17575. foreach (var item in country)
  17576. {
  17577. var data = _groupRepository.FormartTeamName(item);
  17578. var dataArray = _groupRepository.GroupSplitCountry(data);
  17579. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17580. }
  17581. countrys = countrys.Distinct().ToList();
  17582. for (int i = 0; i < countrys.Count; i++)
  17583. {
  17584. string item = countrys[i];
  17585. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17586. {
  17587. countrys.Remove(item);
  17588. i--;
  17589. }
  17590. }
  17591. RefAsync<int> total = 0;
  17592. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17593. .Where(it => countrys.Contains(it.Name_CN))
  17594. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17595. .Select(it => new { id = it.Id, name = it.Name_CN })
  17596. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17597. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17598. }
  17599. /// <summary>
  17600. /// 查看邀请方
  17601. /// 城市信息 Init
  17602. /// </summary>
  17603. /// <param name="dto"></param>
  17604. /// <returns></returns>
  17605. [HttpPost]
  17606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17607. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17608. {
  17609. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17610. RefAsync<int> total = 0;
  17611. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17612. .Where(it => it.CountriesId == dto.CountiesId)
  17613. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17614. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17615. .Select(it => new { id = it.Id, name = it.Name_CN })
  17616. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17617. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17618. }
  17619. /// <summary>
  17620. /// 查看邀请方
  17621. /// 团组名称 Init
  17622. /// </summary>
  17623. /// <param name="dto"></param>
  17624. /// <returns></returns>
  17625. [HttpPost]
  17626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17627. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17628. {
  17629. var watch = new Stopwatch();
  17630. watch.Start();
  17631. RefAsync<int> total = 0;
  17632. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17633. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17634. .Where((oa, di) => oa.IsDel == 0)
  17635. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17636. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17637. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17638. .Distinct()
  17639. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17640. watch.Stop();
  17641. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17642. }
  17643. /// <summary>
  17644. /// 查看邀请方
  17645. /// 团组 & 邀请方信息
  17646. /// </summary>
  17647. /// <param name="dto"></param>
  17648. /// <returns></returns>
  17649. [HttpPost]
  17650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17651. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17652. {
  17653. var watch = new Stopwatch();
  17654. watch.Start();
  17655. RefAsync<int> total = 0;
  17656. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17657. .AS("Grp_DelegationInfo")
  17658. .Includes(x => x.InvitingInfos)
  17659. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17660. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17661. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17662. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17663. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17664. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17665. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17666. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17667. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17668. infos.ForEach(x =>
  17669. {
  17670. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17671. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17672. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17673. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17674. });
  17675. watch.Stop();
  17676. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17677. }
  17678. #endregion
  17679. #region 报批行程
  17680. /// <summary>
  17681. /// 报批行程初始化
  17682. /// </summary>
  17683. /// <param name="dto"></param>
  17684. /// <returns></returns>
  17685. [HttpPost]
  17686. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17687. {
  17688. const int chiNumber = 5;
  17689. var jw = JsonView(false);
  17690. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17691. var group = groupList.First();
  17692. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17693. group = groupList.First(x => x.Id == diid);
  17694. if (group == null)
  17695. {
  17696. jw.Msg = "暂无团组!";
  17697. return Ok(jw);
  17698. }
  17699. var data = new
  17700. {
  17701. groupList = groupList.Select(x => new
  17702. {
  17703. x.TeamName,
  17704. x.Id
  17705. }),
  17706. content = new ArrayList(),
  17707. groupInfo = new
  17708. {
  17709. group.VisitDays,
  17710. group.TourCode,
  17711. group.VisitPNumber,
  17712. group.TeamName,
  17713. group.Id,
  17714. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17715. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17716. },
  17717. };
  17718. var resultArr = new ArrayList();
  17719. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17720. if (content.Count == 0)
  17721. {
  17722. var stay = "-";
  17723. var cityPath = "-";
  17724. //添加城市路径以及住宿地
  17725. //黑屏代码数据
  17726. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17727. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17728. {
  17729. jw = JsonView(true, "黑屏代码有误!", data);
  17730. return Ok(jw);
  17731. }
  17732. foreach (DataRow row in dtBlack.Rows)
  17733. {
  17734. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17735. {
  17736. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17737. return Ok(jw);
  17738. }
  17739. }
  17740. //黑屏代码获取时间区间
  17741. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17742. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17743. _sqlSugar.BeginTran();
  17744. for (int i = 0; i < timeArr.Count; i++)
  17745. {
  17746. stay = "-";
  17747. cityPath = "-";
  17748. DateTime NewData = DateTime.Parse(timeArr[i]);
  17749. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17750. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17751. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17752. if (tbSelect.Length > 0)
  17753. {
  17754. List<string> threeCodeStr = new List<string>();
  17755. foreach (var item in tbSelect)
  17756. {
  17757. var threeCode = item["Three"].ToString() ?? "";
  17758. if (threeCode.Length == 6)
  17759. {
  17760. var start = threeCode.Substring(0, 3);
  17761. var end = threeCode.Substring(3, 3);
  17762. if (threeCodeStr.Count == 0)
  17763. {
  17764. threeCodeStr.Add(start);
  17765. threeCodeStr.Add(end);
  17766. }
  17767. else
  17768. {
  17769. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17770. {
  17771. threeCodeStr.Add(end);
  17772. }
  17773. else
  17774. {
  17775. threeCodeStr.Add(start);
  17776. threeCodeStr.Add(end);
  17777. }
  17778. }
  17779. }
  17780. }
  17781. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17782. var last = threeCodeStr.Last();
  17783. foreach (var item in threeCodeStr)
  17784. {
  17785. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17786. if (item.Equals(last))
  17787. {
  17788. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17789. }
  17790. }
  17791. cityPath = cityPath.Trim('-');
  17792. }
  17793. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17794. appro.Diid = diid ?? -1;
  17795. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17796. appro.Id = thisId;
  17797. appro.CreateUserId = dto.UserId;
  17798. appro.CreateTime = DateTime.Now;
  17799. content.Add(appro);
  17800. }
  17801. _sqlSugar.CommitTran();
  17802. }
  17803. foreach (var x in content)
  17804. {
  17805. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17806. if (chiList.Count < chiNumber)
  17807. {
  17808. for (int i = chiList.Count; i < chiNumber; i++)
  17809. {
  17810. chiList.Add(new Grp_ApprovalTravelDetails());
  17811. }
  17812. }
  17813. resultArr.Add(new
  17814. {
  17815. x.Id,
  17816. x.Date,
  17817. x.Diid,
  17818. chiList = chiList.Select(x1 => new
  17819. {
  17820. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17821. x1.Details,
  17822. x1.ParentId,
  17823. x1.Id
  17824. })
  17825. });
  17826. }
  17827. data = data with
  17828. {
  17829. content = resultArr,
  17830. };
  17831. jw = JsonView(true, "获取成功!", data);
  17832. return Ok(jw);
  17833. }
  17834. /// <summary>
  17835. /// 报批行程删除
  17836. /// </summary>
  17837. /// <param name="dto"></param>
  17838. /// <returns></returns>
  17839. [HttpPost]
  17840. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17841. {
  17842. var jw = JsonView(false);
  17843. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17844. if (group == null)
  17845. {
  17846. jw.Msg = "团组参数有误!";
  17847. return Ok(jw);
  17848. }
  17849. try
  17850. {
  17851. _sqlSugar.BeginTran();
  17852. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17853. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17854. {
  17855. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17856. DeleteUserId = dto.uesrId,
  17857. IsDel = 1
  17858. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17859. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17860. {
  17861. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17862. DeleteUserId = dto.uesrId,
  17863. IsDel = 1
  17864. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17865. _sqlSugar.CommitTran();
  17866. jw = JsonView(true, "删除成功");
  17867. }
  17868. catch (Exception ex)
  17869. {
  17870. jw = JsonView(false, ex.Message);
  17871. }
  17872. return Ok(jw);
  17873. }
  17874. /// <summary>
  17875. /// 报批行程保存
  17876. /// </summary>
  17877. /// <param name="dto"></param>
  17878. /// <returns></returns>
  17879. [HttpPost]
  17880. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17881. {
  17882. var jw = JsonView(false);
  17883. var Find = dto.Arr.Find(x => x.id == 0);
  17884. if (Find != null)
  17885. {
  17886. jw.Msg = "生成的ID为0!";
  17887. return Ok(jw);
  17888. }
  17889. foreach (var item in dto.Arr)
  17890. {
  17891. foreach (var chi in item.chiList)
  17892. {
  17893. if (chi.parentId == 0)
  17894. {
  17895. chi.parentId = item.id;
  17896. }
  17897. }
  17898. }
  17899. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17900. _sqlSugar.BeginTran();
  17901. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17902. {
  17903. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17904. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17905. {
  17906. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17907. DeleteUserId = dto.UserId,
  17908. IsDel = 1
  17909. }).ExecuteCommand();
  17910. }
  17911. try
  17912. {
  17913. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17914. {
  17915. CreateTime = DateTime.Now,
  17916. CreateUserId = dto.UserId,
  17917. Details = x.details,
  17918. ParentId = x.parentId,
  17919. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17920. Remark = "",
  17921. IsDel = 0
  17922. }).ToList()).ExecuteCommand();
  17923. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17924. {
  17925. Id = x.id,
  17926. Details = x.details,
  17927. ParentId = x.parentId,
  17928. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17929. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17930. {
  17931. Details = x.Details,
  17932. ParentId = x.ParentId,
  17933. Time = x.Time
  17934. }).ExecuteCommand();
  17935. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17936. {
  17937. Id = x.id,
  17938. Date = x.date,
  17939. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17940. {
  17941. Date = x.Date
  17942. }).ExecuteCommand();
  17943. _sqlSugar.CommitTran();
  17944. jw = JsonView(true, "保存成功!");
  17945. }
  17946. catch (Exception ex)
  17947. {
  17948. _sqlSugar.RollbackTran();
  17949. jw = JsonView(false, "保存失败!" + ex.Message);
  17950. }
  17951. return Ok(jw);
  17952. }
  17953. /// <summary>
  17954. /// 报批行程生成
  17955. /// </summary>
  17956. /// <param name="dto"></param>
  17957. /// <returns></returns>
  17958. [HttpPost]
  17959. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17960. {
  17961. var jw = JsonView(false);
  17962. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17963. if (group == null)
  17964. {
  17965. jw.Msg = "暂无该团组!";
  17966. return Ok(jw);
  17967. }
  17968. //黑屏代码数据
  17969. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17970. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17971. {
  17972. jw.Msg = "黑屏代码有误!";
  17973. return Ok(jw);
  17974. }
  17975. foreach (DataRow row in dtBlack.Rows)
  17976. {
  17977. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17978. {
  17979. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17980. return Ok(jw);
  17981. }
  17982. }
  17983. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17984. var resultArr = new ArrayList();
  17985. if (officialActivitiesArr.Count == 0)
  17986. {
  17987. jw.Msg = "暂无公务出访信息!";
  17988. return Ok(jw);
  17989. }
  17990. try
  17991. {
  17992. _sqlSugar.BeginTran();
  17993. DeleteApprovalJourney(new
  17994. Domain.Dtos.Groups.DeleteApprovalJourney
  17995. {
  17996. Diid = dto.Diid,
  17997. uesrId = dto.Userid
  17998. });
  17999. var stay = "-";
  18000. var cityPath = "-";
  18001. //添加城市路径以及住宿地
  18002. //黑屏代码获取时间区间
  18003. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18004. var empty = "【未收入该三字码!请机票同事录入】";
  18005. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18006. for (int i = 0; i < timeArr.Count; i++)
  18007. {
  18008. stay = "-";
  18009. cityPath = "-";
  18010. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18011. DateTime NewData = DateTime.Parse(timeArr[i]);
  18012. 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();
  18013. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18014. if (tbSelect.Length > 0)
  18015. {
  18016. List<string> threeCodeStr = new List<string>();
  18017. bool isTrade = false;
  18018. string trip = string.Empty;
  18019. var rowLast = tbSelect.Last();
  18020. var rowFirst = tbSelect.First();
  18021. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18022. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18023. var takeOffTime = DateTime.Parse(timeArr[i]);
  18024. var fallToTime = DateTime.Parse(timeArr[i]);
  18025. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18026. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18027. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18028. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18029. foreach (var item in tbSelect)
  18030. {
  18031. var start = string.Empty;
  18032. var end = string.Empty;
  18033. var threeCode = item["Three"].ToString() ?? "";
  18034. if (threeCode.Length == 6)
  18035. {
  18036. start = threeCode.Substring(0, 3);
  18037. end = threeCode.Substring(3, 3);
  18038. if (threeCodeStr.Count == 0)
  18039. {
  18040. threeCodeStr.Add(start);
  18041. threeCodeStr.Add(end);
  18042. }
  18043. else
  18044. {
  18045. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18046. {
  18047. threeCodeStr.Add(end);
  18048. }
  18049. else
  18050. {
  18051. threeCodeStr.Add(start);
  18052. threeCodeStr.Add(end);
  18053. }
  18054. }
  18055. }
  18056. //处理机票信息
  18057. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18058. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18059. if (start_Object == null)
  18060. {
  18061. start_Object = new Res_ThreeCode()
  18062. {
  18063. AirPort = empty,
  18064. AirPort_En = empty,
  18065. City = empty,
  18066. Country = empty,
  18067. Four = empty,
  18068. Three = empty,
  18069. };
  18070. }
  18071. if (end_Object == null)
  18072. {
  18073. end_Object = new Res_ThreeCode()
  18074. {
  18075. AirPort = empty,
  18076. AirPort_En = empty,
  18077. City = empty,
  18078. Country = empty,
  18079. Four = empty,
  18080. Three = empty,
  18081. };
  18082. }
  18083. //机型判断
  18084. string airModel = item["AirModel"].ToString();
  18085. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18086. string flightTime = item["FlightTime"].ToString();
  18087. if (flightTime!.Contains(":"))
  18088. {
  18089. flightTime = flightTime.Replace(":", "小时");
  18090. flightTime += "分钟";
  18091. }
  18092. if (flightTime.Contains("H"))
  18093. {
  18094. flightTime = flightTime.Replace("H", "小时");
  18095. }
  18096. if (flightTime.Contains("M"))
  18097. {
  18098. flightTime = flightTime.Replace("M", "分钟");
  18099. }
  18100. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18101. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18102. {
  18103. flightTime = flightDataTime.Hour > 0
  18104. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18105. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18106. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18107. }
  18108. //航班号
  18109. string flightcode = item["Fliagtcode"].ToString();
  18110. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18111. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18112. if (aircompany == null)
  18113. {
  18114. aircompany = new Res_AirCompany
  18115. {
  18116. CnName = hsEmpty,
  18117. EnName = hsEmpty,
  18118. ShortCode = hsEmpty,
  18119. };
  18120. }
  18121. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18122. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18123. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18124. if (isTrade)
  18125. {
  18126. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18127. }
  18128. else
  18129. {
  18130. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18131. }
  18132. }
  18133. chiarr.Add(new Grp_ApprovalTravelDetails
  18134. {
  18135. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18136. CreateTime = DateTime.Now,
  18137. CreateUserId = dto.Userid,
  18138. ParentId = 0,
  18139. Details = trip
  18140. });
  18141. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18142. var last = threeCodeStr.Last();
  18143. foreach (var item in threeCodeStr)
  18144. {
  18145. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18146. if (item.Equals(last))
  18147. {
  18148. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18149. }
  18150. }
  18151. cityPath = cityPath.Trim('-');
  18152. }
  18153. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18154. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18155. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18156. appro.Diid = dto.Diid;
  18157. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18158. appro.Id = thisId;
  18159. appro.CreateUserId = dto.Userid;
  18160. appro.CreateTime = DateTime.Now;
  18161. foreach (var item in gwinfo)
  18162. {
  18163. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18164. chi.Details = "拜访" + item.Client;
  18165. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18166. {
  18167. chi.Details += "," + item.ReqSample;
  18168. }
  18169. chi.ParentId = thisId;
  18170. chi.Time = item.Time;
  18171. chiarr.Add(chi);
  18172. }
  18173. if (chiarr.Count < 5)
  18174. {
  18175. for (int j = chiarr.Count; j < 5; j++)
  18176. {
  18177. chiarr.Add(new
  18178. Grp_ApprovalTravelDetails());
  18179. }
  18180. }
  18181. resultArr.Add(new
  18182. {
  18183. appro.Id,
  18184. appro.Date,
  18185. appro.Diid,
  18186. chiList = chiarr.Select(x1 => new
  18187. {
  18188. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  18189. x1.Details,
  18190. x1.ParentId,
  18191. x1.Id
  18192. })
  18193. });
  18194. }
  18195. _sqlSugar.CommitTran();
  18196. jw = JsonView(true, "生成成功!", resultArr);
  18197. }
  18198. catch (Exception ex)
  18199. {
  18200. jw.Code = 400;
  18201. jw.Msg = "生成失败!" + ex.Message;
  18202. }
  18203. return Ok(jw);
  18204. }
  18205. /// <summary>
  18206. /// 报批行程word导出
  18207. /// </summary>
  18208. /// <param name="dto"></param>
  18209. /// <returns></returns>
  18210. [HttpPost]
  18211. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18212. {
  18213. var jw = JsonView(false);
  18214. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18215. if (group == null)
  18216. {
  18217. jw.Msg = "暂无该团组!";
  18218. return Ok(jw);
  18219. }
  18220. //模板路径
  18221. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18222. //载入模板
  18223. Document doc = new Document(tempPath);
  18224. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18225. //获取所填表格的序数
  18226. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18227. Aspose.Words.Tables.Row titleRowClone = null;
  18228. Aspose.Words.Tables.Row CenterRowClone = null;
  18229. int index = 0;
  18230. int indexChi = 0;
  18231. int SetIndex = 0;
  18232. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18233. //获取数据,放到datatable
  18234. foreach (var item in ApprovalTravelArr)
  18235. {
  18236. if (index > 0)
  18237. {
  18238. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18239. tableOne.AppendChild(titleRowClone);
  18240. }
  18241. var textTime = item.Date;
  18242. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18243. SetCells(tableOne, doc, SetIndex, 0, textTime);
  18244. SetIndex++;
  18245. if (ChiRep.Count > 0)
  18246. {
  18247. foreach (var itemChi in ChiRep)
  18248. {
  18249. var txtTime = itemChi.Time;
  18250. var txtDetail = itemChi.Details;
  18251. if (indexChi > 0)
  18252. {
  18253. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18254. tableOne.AppendChild(CenterRowClone);
  18255. }
  18256. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18257. {
  18258. SetCells(tableOne, doc, SetIndex, 0, "");
  18259. SetCells(tableOne, doc, SetIndex, 1, "");
  18260. indexChi++;
  18261. SetIndex++;
  18262. break;
  18263. }
  18264. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  18265. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  18266. indexChi++;
  18267. SetIndex++;
  18268. }
  18269. }
  18270. else
  18271. {
  18272. if (indexChi > 0)
  18273. {
  18274. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18275. tableOne.AppendChild(CenterRowClone);
  18276. }
  18277. SetCells(tableOne, doc, SetIndex, 0, "");
  18278. SetCells(tableOne, doc, SetIndex, 1, "");
  18279. indexChi++;
  18280. SetIndex++;
  18281. }
  18282. index++;
  18283. }
  18284. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  18285. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18286. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18287. jw.Code = 200;
  18288. jw.Msg = "";
  18289. return Ok(jw);
  18290. }
  18291. private string intToString(int numberVal)
  18292. {
  18293. string numberval = numberVal.ToString();
  18294. Dictionary<char, string> Number = new Dictionary<char, string>();
  18295. Number.Add('1', "一");
  18296. Number.Add('2', "二");
  18297. Number.Add('3', "三");
  18298. Number.Add('4', "四");
  18299. Number.Add('5', "五");
  18300. Number.Add('6', "六");
  18301. Number.Add('7', "七");
  18302. Number.Add('8', "八");
  18303. Number.Add('9', "九");
  18304. string stringNumberVal = string.Empty;
  18305. for (int i = 0; i < numberval.Length; i++)
  18306. {
  18307. if (i == 0)
  18308. {
  18309. stringNumberVal += Number[numberval[i]];
  18310. }
  18311. else if (i >= 1)
  18312. {
  18313. if (numberval[i] == '0')
  18314. {
  18315. stringNumberVal = "十";
  18316. }
  18317. else
  18318. {
  18319. stringNumberVal += "十" + Number[numberval[i]];
  18320. }
  18321. }
  18322. }
  18323. return stringNumberVal;
  18324. }
  18325. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  18326. {
  18327. //获取table中的某个单元格,从0开始
  18328. Cell lshCell = table.Rows[rows].Cells[cells];
  18329. //将单元格中段落移除
  18330. foreach (Node item in lshCell.Paragraphs)
  18331. {
  18332. lshCell.Paragraphs.Remove(item);
  18333. }
  18334. if (val.Contains("\r\n"))
  18335. {
  18336. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18337. foreach (var item in spArr)
  18338. {
  18339. //新建一个段落
  18340. Paragraph p = new Paragraph(doc);
  18341. var r = new Run(doc, item);
  18342. //把设置的值赋给之前新建的段落
  18343. p.AppendChild(r);
  18344. //将此段落加到单元格内
  18345. lshCell.AppendChild(p);
  18346. }
  18347. }
  18348. else
  18349. {
  18350. //新建一个段落
  18351. Paragraph p = new Paragraph(doc);
  18352. var r = new Run(doc, val);
  18353. //把设置的值赋给之前新建的段落
  18354. p.AppendChild(r);
  18355. //将此段落加到单元格内
  18356. lshCell.AppendChild(p);
  18357. }
  18358. }
  18359. [HttpPost]
  18360. public async Task<IActionResult> ServerHttp(string paramStr)
  18361. {
  18362. paramStr = paramStr.TrimEnd('\'');
  18363. paramStr = paramStr.TrimStart('\'');
  18364. JsonView jw = JsonView(false);
  18365. JObject param = JObject.Parse(paramStr);
  18366. if (!param.ContainsKey("url"))
  18367. {
  18368. jw.Msg = "url null";
  18369. return Ok(jw);
  18370. }
  18371. string url = param["url"]!.ToString();
  18372. var methon = "get";
  18373. Dictionary<string, string> headValues = null;
  18374. string bodyStr = string.Empty;
  18375. if (param.ContainsKey("methon"))
  18376. {
  18377. methon = param["methon"]!.ToString().ToLower();
  18378. }
  18379. if (param.ContainsKey("header"))
  18380. {
  18381. var header = param["header"]!.ToString();
  18382. JObject headerJobject = JObject.Parse(header);
  18383. headValues = new Dictionary<string, string>();
  18384. foreach (JProperty item in headerJobject.Properties())
  18385. {
  18386. var value = item.Value.ToString();
  18387. var head = item.Path;
  18388. headValues.Add(head, value);
  18389. }
  18390. }
  18391. HttpClient client = new HttpClient();
  18392. string responseString = string.Empty;
  18393. StringContent content = null;
  18394. if (headValues != null)
  18395. {
  18396. foreach (var item in headValues.Keys)
  18397. {
  18398. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18399. {
  18400. if (param.ContainsKey("body"))
  18401. {
  18402. bodyStr = param["body"]!.ToString();
  18403. }
  18404. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18405. }
  18406. else
  18407. {
  18408. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18409. }
  18410. }
  18411. }
  18412. try
  18413. {
  18414. if (methon == "get")
  18415. {
  18416. responseString = await client.GetStringAsync(url);
  18417. }
  18418. else if (methon == "post")
  18419. {
  18420. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18421. {
  18422. Content = content
  18423. };
  18424. var response = await client.SendAsync(request);
  18425. try
  18426. {
  18427. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18428. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18429. {
  18430. using (StreamReader reader = new StreamReader(gzipStream))
  18431. {
  18432. responseString = await reader.ReadToEndAsync();
  18433. }
  18434. }
  18435. }
  18436. catch (Exception)
  18437. {
  18438. responseString = await response.Content.ReadAsStringAsync();
  18439. }
  18440. }
  18441. else
  18442. {
  18443. responseString = "methon error";
  18444. }
  18445. jw = JsonView(true, "success", responseString);
  18446. }
  18447. catch (Exception ex)
  18448. {
  18449. jw.Msg = "error " + ex.Message;
  18450. jw.Data = ex.StackTrace;
  18451. }
  18452. finally
  18453. {
  18454. client.Dispose();
  18455. }
  18456. return Ok(jw);
  18457. }
  18458. #endregion
  18459. #region 团组接待意见调查
  18460. /// <summary>
  18461. /// 团组接待意见调查 - 信息管理
  18462. /// 基础数据(团组)
  18463. /// </summary>
  18464. /// <returns></returns>
  18465. [HttpGet]
  18466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18467. public async Task<IActionResult> OpinionaireInit()
  18468. {
  18469. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18470. .Select(x => new
  18471. {
  18472. x.Id,
  18473. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18474. })
  18475. .OrderByDescending(x => x.Id)
  18476. .ToListAsync();
  18477. return Ok(JsonView(groupData, groupData.Count));
  18478. }
  18479. /// <summary>
  18480. /// 团组接待意见调查 - 信息管理
  18481. /// 列表
  18482. /// </summary>
  18483. /// <param name="groupId"></param>
  18484. /// <returns></returns>
  18485. [HttpGet("{groupId}")]
  18486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18487. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18488. {
  18489. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18490. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18491. .Select(x => new
  18492. {
  18493. x.Id,
  18494. x.TourGuideName,
  18495. x.CityName,
  18496. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18497. x.CreateTime
  18498. })
  18499. .OrderBy(x => x.Id)
  18500. .ToListAsync();
  18501. return Ok(JsonView(data));
  18502. }
  18503. /// <summary>
  18504. /// 团组接待意见调查 - 信息管理
  18505. /// 保存
  18506. /// </summary>
  18507. /// <param name="dto"></param>
  18508. /// <returns></returns>
  18509. [HttpPost]
  18510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18511. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18512. {
  18513. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18514. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18515. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18516. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18517. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18518. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18519. _opinionaireRep.BeginTran();
  18520. if (addData != null && addData.Count > 0)
  18521. {
  18522. foreach (var item in addData)
  18523. {
  18524. item.CreateUserId = currUserInfo.UserId;
  18525. item.DiId = dto.DiId;
  18526. }
  18527. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18528. }
  18529. if (updData != null && updData.Count > 0)
  18530. {
  18531. var upd = await _opinionaireRep._sqlSugar
  18532. .Updateable(updData)
  18533. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18534. .WhereColumns(x => new { x.Id })
  18535. .ExecuteCommandAsync();
  18536. }
  18537. _opinionaireRep.CommitTran();
  18538. return Ok(JsonView("操作成功!"));
  18539. }
  18540. /// <summary>
  18541. /// 团组接待意见调查 - 信息管理
  18542. /// 删除
  18543. /// </summary>
  18544. /// <param name="id"></param>
  18545. /// <returns></returns>
  18546. [HttpDelete("{id}")]
  18547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18548. public async Task<IActionResult> OpinionaireManageDel(int id)
  18549. {
  18550. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18551. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18552. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18553. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18554. if (!del) return Ok(JsonView("操作失败!"));
  18555. return Ok(JsonView("操作成功!"));
  18556. }
  18557. /// <summary>
  18558. /// 团组接待意见调查 - 用户
  18559. /// 列表
  18560. /// </summary>
  18561. /// <param name="diId"></param>
  18562. /// <returns></returns>
  18563. [HttpGet("{diId}")]
  18564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18565. public async Task<IActionResult> OpinionaireUserList(int diId)
  18566. {
  18567. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18568. var sql = string.Format(@"
  18569. SELECT
  18570. o.Id,
  18571. o.DiId,
  18572. di.TeamName AS 'GroupName',
  18573. di.VisitPNumber AS 'PeopleNumber',
  18574. di.ClientName AS 'LeadGroup',
  18575. di.VisitCountry AS 'Travel',
  18576. di.VisitDays AS 'Days',
  18577. o.CityName,
  18578. o.TourGuideName,
  18579. o.Catering,
  18580. o.CateringReason,
  18581. o.Stay,
  18582. o.StayReason,
  18583. o.[Route],
  18584. o.RouteReason,
  18585. o.OfficialActivity,
  18586. o.OfficialActivityReason,
  18587. o.TourGuide,
  18588. o.TourGuideReason,
  18589. o.[Translate],
  18590. o.TranslateReason,
  18591. o.Trip,
  18592. o.TripReason,
  18593. o.ESFileName,
  18594. o.SignatureDate,
  18595. o.Remark
  18596. FROM
  18597. Grp_Opinionaire o
  18598. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18599. WHERE
  18600. o.IsDel = 0
  18601. AND o.DiId = {0}
  18602. ORDER BY
  18603. o.Id ASC", diId);
  18604. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18605. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18606. return Ok(JsonView(data));
  18607. }
  18608. /// <summary>
  18609. /// 团组接待意见调查 - 用户
  18610. /// 保存
  18611. /// </summary>
  18612. /// <param name="dto"></param>
  18613. /// <returns></returns>
  18614. [HttpPost]
  18615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18616. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18617. {
  18618. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18619. foreach (var item in dto)
  18620. {
  18621. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18622. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18623. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18624. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18625. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18626. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18627. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18628. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18629. }
  18630. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18631. if (!Directory.Exists(filePathBase))
  18632. {
  18633. Directory.CreateDirectory(filePathBase);
  18634. }
  18635. #region 上传文件
  18636. var filePaths = new List<string>();
  18637. foreach (var item in dto)
  18638. {
  18639. var file = item.File;
  18640. // 将文件保存到指定位置
  18641. var filePath = Path.Combine(filePathBase, file.FileName);
  18642. using (var stream = new FileStream(filePath, FileMode.Create))
  18643. {
  18644. await file.CopyToAsync(stream);
  18645. }
  18646. //验证文件是否上传成功
  18647. if (!System.IO.File.Exists(filePath))
  18648. {
  18649. foreach (var filePathStr in filePaths)
  18650. {
  18651. System.IO.File.Delete(filePathStr);
  18652. }
  18653. return Ok(JsonView(false, "文件上传失败!"));
  18654. }
  18655. item.ESFileName = file.FileName;
  18656. }
  18657. #endregion
  18658. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18659. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18660. .UpdateColumns(x => new
  18661. {
  18662. x.Catering,
  18663. x.CateringReason,
  18664. x.Stay,
  18665. x.StayReason,
  18666. x.Route,
  18667. x.RouteReason,
  18668. x.OfficialActivity,
  18669. x.OfficialActivityReason,
  18670. x.TourGuide,
  18671. x.TourGuideReason,
  18672. x.Translate,
  18673. x.TranslateReason,
  18674. x.Trip,
  18675. x.TripReason,
  18676. x.ESFileName,
  18677. x.SignatureDate,
  18678. x.Remark
  18679. })
  18680. .WhereColumns(x => new { x.Id })
  18681. .ExecuteCommandAsync();
  18682. if (upd < 1)
  18683. {
  18684. foreach (var filePathStr in filePaths)
  18685. {
  18686. System.IO.File.Delete(filePathStr);
  18687. }
  18688. return Ok(JsonView(false));
  18689. }
  18690. return Ok(JsonView(true));
  18691. }
  18692. #endregion
  18693. #region 团组餐厅相关信息
  18694. /// <summary>
  18695. /// 团组相关餐厅信息
  18696. /// 基础数据(团组)
  18697. /// </summary>
  18698. /// <returns></returns>
  18699. [HttpGet]
  18700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18701. public async Task<IActionResult> RestaurantInit()
  18702. {
  18703. return Ok(await _restaurantRep.InitAsync());
  18704. }
  18705. /// <summary>
  18706. /// 团组相关餐厅信息
  18707. /// Item
  18708. /// </summary>
  18709. /// <param name="dto"></param>
  18710. /// <returns></returns>
  18711. [HttpPost]
  18712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18713. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18714. {
  18715. int portType = dto.PortType,
  18716. groupId = dto.GroupId;
  18717. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18718. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18719. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  18720. }
  18721. /// <summary>
  18722. /// 团组相关餐厅信息
  18723. /// List
  18724. /// </summary>
  18725. /// <param name="dto"></param>
  18726. /// <returns></returns>
  18727. [HttpPost]
  18728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18729. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18730. {
  18731. int portType = dto.PortType,
  18732. groupId = dto.GroupId;
  18733. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18734. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18735. var sql = string.Format(@" SELECT
  18736. ri.Id,
  18737. ri.GroupId,
  18738. ri.Date,
  18739. ri.StartTime,
  18740. ri.EndTime,
  18741. CASE WHEN ri.Type = 1 THEN '早餐'
  18742. WHEN ri.Type = 2 THEN '午餐'
  18743. WHEN ri.Type = 3 THEN '晚餐'
  18744. ELSE '其他'
  18745. END AS 'Type',
  18746. ri.Name,
  18747. ri.Address,
  18748. ri.Tel,
  18749. ri.Remark,
  18750. ri.CreateTime,
  18751. u.CnName AS CreateUserName
  18752. FROM
  18753. Grp_RestaurantInfo ri
  18754. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18755. WHERE
  18756. ri.IsDel = 0
  18757. AND ri.GroupId = {0}
  18758. ORDER BY
  18759. ri.Date ASC
  18760. ", groupId);
  18761. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18762. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18763. return Ok(JsonView(infos));
  18764. }
  18765. /// <summary>
  18766. /// 团组相关餐厅信息
  18767. /// Info
  18768. /// </summary>
  18769. /// <param name="dto"></param>
  18770. /// <returns></returns>
  18771. [HttpPost]
  18772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18773. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18774. {
  18775. int portType = dto.PortType,
  18776. id = dto.Id;
  18777. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18778. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18779. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18780. }
  18781. /// <summary>
  18782. /// 团组相关餐厅信息
  18783. /// Op
  18784. /// </summary>
  18785. /// <param name="dto"></param>
  18786. /// <returns></returns>
  18787. [HttpPost]
  18788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18789. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18790. {
  18791. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18792. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18793. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18794. return Ok(await _restaurantRep.OpAsync(dto));
  18795. }
  18796. /// <summary>
  18797. /// 团组相关餐厅信息
  18798. /// Del
  18799. /// </summary>
  18800. /// <param name="dto"></param>
  18801. /// <returns></returns>
  18802. [HttpPost]
  18803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18804. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18805. {
  18806. int userId = dto.DeleteUserId;
  18807. var id = dto.Id;
  18808. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18809. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18810. return Ok(await _restaurantRep.DelAsync(dto));
  18811. }
  18812. #endregion
  18813. // /// <summary>
  18814. // ///
  18815. // /// </summary>
  18816. // /// <param name="_dto"></param>
  18817. // /// <returns></returns>
  18818. // [HttpPost]
  18819. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18820. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18821. // {
  18822. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18823. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18824. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18825. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18826. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18827. // dic_psg.Add("客人", 974);
  18828. // dic_psg.Add("司机", 975);
  18829. // dic_psg.Add("导游", 976);
  18830. // dic_psg.Add("公司内部人员", 977);
  18831. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18832. // foreach (var item in list_visa)
  18833. // {
  18834. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18835. // temp.Id = item.Id;
  18836. // temp.DIId = item.DIId;
  18837. // temp.VisaClient = item.VisaClient;
  18838. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18839. // temp.VisaCurrency = item.VisaCurrency;
  18840. // temp.IsThird = item.IsThird;
  18841. // if (dic_psg.ContainsKey(item.PassengerType))
  18842. // {
  18843. // temp.PassengerType = dic_psg[item.PassengerType];
  18844. // }
  18845. // else {
  18846. // temp.PassengerType = -1;
  18847. // }
  18848. // temp.VisaNumber = item.VisaNumber;
  18849. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18850. // temp.CreateUserId = item.Operators;
  18851. // DateTime dt_ct;
  18852. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18853. // if (b_ct)
  18854. // {
  18855. // temp.CreateTime = dt_ct;
  18856. // }
  18857. // else
  18858. // {
  18859. // temp.CreateTime = DateTime.Now;
  18860. // }
  18861. // temp.DeleteTime = "";
  18862. // temp.DeleteUserId = 0;
  18863. // temp.Remark = item.Remark;
  18864. // if (string.IsNullOrEmpty(temp.Remark)) {
  18865. // temp.Remark = "";
  18866. // }
  18867. // temp.IsDel = item.IsDel;
  18868. // temp.VisaDescription = item.VisaAttachment;
  18869. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18870. //([Id]
  18871. // ,[DIId]
  18872. // ,[VisaClient]
  18873. // ,[VisaPrice]
  18874. // ,[VisaCurrency]
  18875. // ,[IsThird]
  18876. // ,[PassengerType]
  18877. // ,[VisaNumber]
  18878. // ,[VisaFreeNumber]
  18879. // ,[CreateUserId]
  18880. // ,[CreateTime]
  18881. // ,[DeleteTime]
  18882. // ,[DeleteUserId]
  18883. // ,[Remark]
  18884. // ,[IsDel]
  18885. // ,[visaDescription])
  18886. // VALUES
  18887. // ({0},{1},'{2}',{3},{4}
  18888. //,{5},{6},{7},{8},{9}
  18889. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18890. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18891. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18892. //);
  18893. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18894. // }
  18895. // return Ok(JsonView(true, "操作成功!"));
  18896. // }
  18897. /// <summary>
  18898. /// 123132123
  18899. /// </summary>
  18900. /// <param name="_dto"></param>
  18901. /// <returns></returns>
  18902. [HttpPost]
  18903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18904. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18905. {
  18906. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18907. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18908. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18909. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18910. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18911. dicDetail.Add(789, 1034);
  18912. dicDetail.Add(790, 1035);
  18913. dicDetail.Add(791, 1036);
  18914. dicDetail.Add(792, 1037);
  18915. dicDetail.Add(793, 1038);
  18916. dicDetail.Add(794, 1039);
  18917. dicDetail.Add(795, 1040);
  18918. dicDetail.Add(796, 1041);
  18919. dicDetail.Add(797, 1042);
  18920. dicDetail.Add(798, 1043);
  18921. dicDetail.Add(801, 1044);
  18922. dicDetail.Add(802, 1045);
  18923. dicDetail.Add(803, 1046);
  18924. Dictionary<int, int> dic = new Dictionary<int, int>();
  18925. dic.Add(806, 1027);
  18926. dic.Add(807, 1028);
  18927. dic.Add(808, 1029);
  18928. dic.Add(809, 1030);
  18929. dic.Add(810, 1031);
  18930. dic.Add(811, 1032);
  18931. dic.Add(812, 1033);
  18932. foreach (var item in list_visa)
  18933. {
  18934. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18935. temp.Coefficient = item.coefficient;
  18936. DateTime dtCrt;
  18937. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18938. if (b1)
  18939. {
  18940. temp.CreateTime = dtCrt;
  18941. }
  18942. else
  18943. {
  18944. temp.CreateTime = DateTime.Now;
  18945. }
  18946. temp.CreateUserId = item.Operators;
  18947. temp.DeleteTime = "";
  18948. temp.DeleteUserId = 0;
  18949. temp.DiId = int.Parse(item.DIID);
  18950. temp.FilePath = item.FilePath;
  18951. temp.IsDel = item.IsDel;
  18952. temp.Price = item.Price;
  18953. temp.PriceCount = 1;
  18954. temp.PriceCurrency = item.Currency;
  18955. int detailId = 0;
  18956. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18957. {
  18958. detailId = dicDetail[item.PriceTypeDetail];
  18959. }
  18960. temp.PriceDetailType = detailId;
  18961. temp.PriceDt = DateTime.Now;
  18962. temp.PriceName = item.PriceName;
  18963. temp.PriceSum = item.Price;
  18964. int tid = 0;
  18965. if (dic.ContainsKey(item.PriceType))
  18966. {
  18967. tid = dic[item.PriceType];
  18968. }
  18969. temp.PriceType = tid;
  18970. temp.Remark = item.Remark;
  18971. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18972. }
  18973. return Ok(JsonView(true, "操作成功!"));
  18974. }
  18975. [HttpPost]
  18976. public IActionResult TimeTest()
  18977. {
  18978. var jw = JsonView(false, "error");
  18979. _sqlSugar.BeginTran();
  18980. try
  18981. {
  18982. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18983. .Select(x => new Crm_NewClientData
  18984. {
  18985. Id = x.Id,
  18986. Client = x.Client,
  18987. Contact = x.Contact,
  18988. Location = x.Location,
  18989. })
  18990. .ToList();
  18991. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  18992. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18993. Stopwatch stopwatch = new Stopwatch();
  18994. // 开始计时
  18995. stopwatch.Start();
  18996. foreach (var item in clientList)
  18997. {
  18998. EncryptionProcessor.DecryptProperties(item);
  18999. }
  19000. stopwatch.Stop();
  19001. jw.Code = 200;
  19002. jw.Data = stopwatch.ElapsedMilliseconds;
  19003. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19004. }
  19005. catch (Exception ex)
  19006. {
  19007. jw.Code = 400;
  19008. jw.Msg = ex.Message;
  19009. }
  19010. return Ok(jw);
  19011. }
  19012. }
  19013. }