GroupsController.cs 1019 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014
  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. var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  7717. var userIds = permissionUsers.Select(x => x.Id).ToList();
  7718. var permissions = new List<Grp_EnterExitCostPermission>();
  7719. if (userIds.Any())
  7720. {
  7721. foreach (var userId1 in userIds)
  7722. {
  7723. permissions.Add(new Grp_EnterExitCostPermission()
  7724. {
  7725. GroupId = groupId,
  7726. UserId = userId1,
  7727. CreateUserId = dto.UserId
  7728. });
  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. _sqlSugar.CommitTran();
  7773. //执行操作之后
  7774. //生成默认文件pdf并且通知人员
  7775. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7776. {
  7777. DiId = groupId,
  7778. ExportType = 1,
  7779. SubTypeId = 1005
  7780. }, "pdf");
  7781. //发送通知
  7782. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7783. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7784. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7785. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7786. //汇率信息记录
  7787. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7788. return Ok(JsonView(true));
  7789. }
  7790. catch (Exception ex)
  7791. {
  7792. _sqlSugar.RollbackTran();
  7793. return Ok(JsonView(false, ex.Message));
  7794. }
  7795. }
  7796. #endregion
  7797. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7798. /// <summary>
  7799. /// 获取币种基础数据(含逻辑处理)
  7800. /// </summary>
  7801. /// <returns></returns>
  7802. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7803. {
  7804. //默认币种显示
  7805. var _currencyInfos = _currencyInit;
  7806. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7807. if (_currencyRate.Count > 0)
  7808. {
  7809. foreach (var item in _currencyInfos)
  7810. {
  7811. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7812. if (rateInfo != null)
  7813. {
  7814. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7815. rate1 *= 1.035M;
  7816. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7817. }
  7818. }
  7819. }
  7820. return _currencyInfos;
  7821. }
  7822. /// <summary>
  7823. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7824. /// </summary>
  7825. /// <returns></returns>
  7826. [HttpPost]
  7827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7828. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7829. {
  7830. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7831. //SetDataInfoView
  7832. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7833. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7834. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7835. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7836. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7837. //默认币种显示
  7838. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7839. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7840. return Ok(JsonView(true, "查询成功!", new
  7841. {
  7842. WordTypeData = _WordTypeData,
  7843. ExcelTypeData = _ExcelTypeData,
  7844. CurrencyInit = _currencyInfos,
  7845. viewPermissionData = viewPermissionData
  7846. }));
  7847. }
  7848. /// <summary>
  7849. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7850. /// </summary>
  7851. /// <returns></returns>
  7852. [HttpPost]
  7853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7854. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7855. {
  7856. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7857. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7858. RefAsync<int> total = 0;
  7859. int diId = 0;
  7860. var status = int.TryParse(dto.GroupName, out diId);
  7861. string sql = string.Format(@"SELECT
  7862. Id,
  7863. TeamName GroupName,
  7864. CASE WHEN EXISTS (
  7865. SELECT
  7866. 1
  7867. FROM
  7868. Grp_EnterExitCost
  7869. WHERE
  7870. IsDel = 0
  7871. AND DiId = di.Id
  7872. ) THEN 1 ELSE 0 END AS [IsNull],
  7873. CASE WHEN EXISTS(
  7874. SELECT
  7875. TOP 1 *
  7876. FROM
  7877. Grp_EnterExitCost
  7878. WHERE
  7879. IsDel = 0
  7880. AND DiId = di.Id
  7881. AND CreateUserId = {0}
  7882. ORDER BY
  7883. CreateTime DESC
  7884. ) THEN 1 ELSE 0 END AS [IsEdit],
  7885. CASE WHEN EXISTS(
  7886. SELECT
  7887. TOP 1 *
  7888. FROM
  7889. Grp_EnterExitCost
  7890. WHERE
  7891. IsDel = 0
  7892. AND DiId = di.Id
  7893. AND CreateUserId = {0}
  7894. ORDER BY
  7895. CreateTime DESC
  7896. ) THEN 1 WHEN EXISTS(
  7897. SELECT
  7898. TOP 1 *
  7899. FROM
  7900. Grp_EnterExitCostPermission
  7901. WHERE
  7902. IsDel = 0
  7903. AND GroupId = di.Id
  7904. AND Permission = 1
  7905. AND UserId = {0}
  7906. ORDER BY
  7907. CreateTime DESC
  7908. ) THEN 1 ELSE 0 END AS [IsView]
  7909. FROM
  7910. Grp_DelegationInfo di
  7911. WHERE
  7912. di.Isdel = 0 ", dto.CurrUserId);
  7913. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7914. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7915. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7916. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7917. .OrderByDescending(x => x.Id)
  7918. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7919. return Ok(JsonView(true, "查询成功!", data, total));
  7920. }
  7921. /// <summary>
  7922. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7923. /// </summary>
  7924. /// <returns></returns>
  7925. [HttpPost]
  7926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7927. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7928. {
  7929. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7930. RefAsync<int> total = 0;
  7931. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7932. .Where(x => x.IsDel == 0 && x.STid == 66)
  7933. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7934. .Select(x => new
  7935. {
  7936. id = x.Id,
  7937. name = x.Name,
  7938. remark = x.Remark,
  7939. })
  7940. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7941. return Ok(JsonView(true, "查询成功!", data, total));
  7942. }
  7943. /// <summary>
  7944. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7945. /// </summary>
  7946. /// <returns></returns>
  7947. [HttpPost]
  7948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7949. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7950. {
  7951. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7952. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7953. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7954. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7955. var groupOtherRateData = groupRateData.TeamRates;
  7956. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7957. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7958. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7959. groupOtherRateData = groupOtherRateData
  7960. .Select(x => new TeamRateDescAddCurrencyIdView
  7961. {
  7962. CurrencyId = x.CurrencyId,
  7963. CurrencyName = x.CurrencyName,
  7964. CurrencyCode = x.CurrencyCode,
  7965. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7966. }).ToList();
  7967. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7968. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7969. }
  7970. /// <summary>
  7971. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7972. /// </summary>
  7973. /// <returns></returns>
  7974. [HttpPost]
  7975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7976. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7977. {
  7978. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7979. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7980. var tipsData = new List<int>() { 1, 2, 3 };
  7981. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7982. if (dto.TipsType == 1)
  7983. {
  7984. //默认币种显示
  7985. var _currencyInfos = _currencyInit;
  7986. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7987. List<dynamic> reteInfos = new List<dynamic>();
  7988. if (_currencyRate.Count > 0)
  7989. {
  7990. foreach (var item in _currencyInfos)
  7991. {
  7992. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7993. if (rateInfo != null)
  7994. {
  7995. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7996. decimal rate1 = item.Rate;
  7997. rate1 *= 1.03M;
  7998. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7999. reteInfos.Add(new
  8000. {
  8001. currCode = item.CurrencyCode,
  8002. currName = item.CurrencyName,
  8003. rate = rate2,
  8004. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  8005. });
  8006. }
  8007. }
  8008. }
  8009. return Ok(JsonView(true, "查询成功!", reteInfos));
  8010. }
  8011. else if (dto.TipsType == 2)
  8012. {
  8013. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  8014. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8015. }
  8016. else if (dto.TipsType == 3)
  8017. {
  8018. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8019. return Ok(JsonView(true, "查询成功!", airData.Data));
  8020. }
  8021. return Ok(JsonView(false));
  8022. }
  8023. /// <summary>
  8024. /// 团组模块 - 出入境国家费用标准-移动端 List
  8025. /// </summary>
  8026. /// <returns></returns>
  8027. [HttpPost]
  8028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8029. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8030. {
  8031. Stopwatch sw = new Stopwatch();
  8032. sw.Start();
  8033. RefAsync<int> total = 0;
  8034. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8035. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8036. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8037. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8038. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8039. .Select((ntf, sd, u) => new
  8040. {
  8041. Id = ntf.Id,
  8042. Area = $"{ntf.Country}-{ntf.City}",
  8043. Currency = ntf.Currency,
  8044. CurrencyCode = sd.Name,
  8045. CurrencyName = sd.Remark,
  8046. RoomCost = ntf.RoomCost,
  8047. FoodCost = ntf.FoodCost,
  8048. PublicCost = ntf.PublicCost,
  8049. LastUpdateUserId = ntf.LastUpdateUserId,
  8050. LastUpdateUserName = u.CnName,
  8051. LastUpdateTime = ntf.LastUpdateTime,
  8052. })
  8053. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8054. sw.Stop();
  8055. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8056. }
  8057. /// <summary>
  8058. /// 团组模块 - 出入境费用-移动端 - Info
  8059. /// </summary>
  8060. /// <returns></returns>
  8061. [HttpPost]
  8062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8063. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8064. {
  8065. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8066. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8067. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8068. return Ok(data);
  8069. }
  8070. /// <summary>
  8071. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8072. /// </summary>
  8073. /// <returns></returns>
  8074. [HttpPost]
  8075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8076. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8077. {
  8078. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8079. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8080. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8081. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8082. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8083. mobileInfo.DiId = dto.DiId;
  8084. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8085. if (eecInfo == null) return Ok(mobileInfo);
  8086. //验证查看权限
  8087. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8088. //if (!isView) return Ok(JsonView(false, msg));
  8089. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8090. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8091. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8092. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8093. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8094. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8095. {
  8096. SubId = dac.Id,
  8097. DiId = dac.DiId,
  8098. Type = dac.Type,
  8099. Days = dac.Days,
  8100. NationalTravelFeeId = dac.NationalTravelFeeId,
  8101. Arae = $"{ntf.Country}-{ntf.City}",
  8102. Cost = dac.Cost,
  8103. Currency = dac.Currency,
  8104. CurrencyName = sd.Name,
  8105. SubTotal = dac.SubTotal,
  8106. })
  8107. .ToList();
  8108. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8109. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8110. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8111. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8112. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8113. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8114. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8115. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8116. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8117. //其他款项
  8118. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8119. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8120. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8121. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8122. .OrderBy((dop, sd1, sd2) => dop.Index)
  8123. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8124. {
  8125. SubId = dop.Id,
  8126. DiId = dop.Diid,
  8127. Index = dop.Index,
  8128. SetDataId = dop.SetDataId,
  8129. SetDataName = sd1.Name,
  8130. Cost = dop.Cost,
  8131. Currency = dop.Currency,
  8132. CurrencyName = sd2.Remark,
  8133. SubTotal = dop.SubTotal,
  8134. Remark = dop.Remark,
  8135. })
  8136. .ToArray();
  8137. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8138. return Ok(mobileInfo);
  8139. }
  8140. /// <summary>
  8141. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8142. /// </summary>
  8143. /// <returns></returns>
  8144. [HttpPost]
  8145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8146. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8147. {
  8148. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8149. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8150. //验证查看权限
  8151. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8152. if (!isView) return Ok(JsonView(false, msg));
  8153. var userIds = Array.Empty<int>();
  8154. userIds = await _sqlSugar
  8155. .Queryable<Grp_EnterExitCostPermission>()
  8156. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8157. .Select(x => x.UserId)
  8158. .ToArrayAsync();
  8159. return Ok(userIds);
  8160. }
  8161. /// <summary>
  8162. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8163. /// </summary>
  8164. /// <returns></returns>
  8165. [HttpPost]
  8166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8167. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8168. {
  8169. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8170. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8171. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8172. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8173. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8174. //验证查看权限
  8175. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8176. //if (!isView) return Ok(JsonView(false, msg));
  8177. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8178. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8179. var subType = dto.SubType;
  8180. if (subType == 1) //1:境内费用
  8181. {
  8182. var oneData = new ChoiceOneMobileSubInfoView()
  8183. {
  8184. Id = eecInfo.Id,
  8185. ChoiceOne = eecInfo.ChoiceOne,
  8186. ChoiceOneTotalCost = eecInfo.InsidePay,
  8187. Visa = eecInfo.Visa,
  8188. VisaRemark = eecInfo.VisaRemark,
  8189. YiMiao = eecInfo.YiMiao,
  8190. HeSuan = eecInfo.HeSuan,
  8191. Service = eecInfo.Service,
  8192. Ticket = eecInfo.Ticket,
  8193. Safe = eecInfo.Safe,
  8194. FirstItemRemark = eecInfo.FirstItemRemark
  8195. };
  8196. return Ok(JsonView(oneData));
  8197. }
  8198. else if (subType == 2) //2:国际旅费
  8199. {
  8200. var twoData = new ChoiceTwoMobileSubInfoView()
  8201. {
  8202. Id = eecInfo.Id,
  8203. ChoiceTwoJJ = eecInfo.SumJJC,
  8204. OutsideJJPay = eecInfo.OutsideJJPay,
  8205. ChoiceTwoGW = eecInfo.SumGWC,
  8206. OutsideGWPay = eecInfo.OutsideGWPay,
  8207. ChoiceTwoTD = eecInfo.SumTDC,
  8208. OutsideTDPay = eecInfo.OutsideTDPay,
  8209. AirJJ = eecInfo.AirJJ,
  8210. AirGW = eecInfo.AirGW,
  8211. AirTD = eecInfo.AirTD,
  8212. CityTranffic = eecInfo.CityTranffic,
  8213. TwoItemRemark = eecInfo.TwoItemRemark
  8214. };
  8215. return Ok(JsonView(twoData));
  8216. }
  8217. else if (subType == 3) //3:住宿费
  8218. {
  8219. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8220. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8221. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8222. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8223. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8224. {
  8225. SubId = dac.Id,
  8226. DiId = dac.DiId,
  8227. Type = dac.Type,
  8228. Days = dac.Days,
  8229. NationalTravelFeeId = dac.NationalTravelFeeId,
  8230. Arae = $"{ntf.Country}-{ntf.City}",
  8231. Cost = dac.Cost,
  8232. Currency = dac.Currency,
  8233. CurrencyName = sd.Name,
  8234. SubTotal = dac.SubTotal,
  8235. })
  8236. .ToArray();
  8237. var data = new ChoiceMobileSubInfo3To6View()
  8238. {
  8239. ParentId = eecInfo.Id,
  8240. Choice = eecInfo.ChoiceThree,
  8241. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8242. Details = dayAndCostDatas
  8243. };
  8244. return Ok(JsonView(data));
  8245. }
  8246. else if (subType == 4) //4:伙食费
  8247. {
  8248. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8249. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8250. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8251. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8252. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8253. {
  8254. SubId = dac.Id,
  8255. DiId = dac.DiId,
  8256. Type = dac.Type,
  8257. Days = dac.Days,
  8258. NationalTravelFeeId = dac.NationalTravelFeeId,
  8259. Arae = $"{ntf.Country}-{ntf.City}",
  8260. Cost = dac.Cost,
  8261. Currency = dac.Currency,
  8262. CurrencyName = sd.Name,
  8263. SubTotal = dac.SubTotal,
  8264. })
  8265. .ToArray();
  8266. var data = new ChoiceMobileSubInfo3To6View()
  8267. {
  8268. ParentId = eecInfo.Id,
  8269. Choice = eecInfo.ChoiceFour,
  8270. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8271. Details = dayAndCostDatas
  8272. };
  8273. return Ok(JsonView(data));
  8274. }
  8275. else if (subType == 5) //5:公杂费
  8276. {
  8277. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8278. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8279. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8280. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8281. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8282. {
  8283. SubId = dac.Id,
  8284. DiId = dac.DiId,
  8285. Type = dac.Type,
  8286. Days = dac.Days,
  8287. NationalTravelFeeId = dac.NationalTravelFeeId,
  8288. Arae = $"{ntf.Country}-{ntf.City}",
  8289. Cost = dac.Cost,
  8290. Currency = dac.Currency,
  8291. CurrencyName = sd.Name,
  8292. SubTotal = dac.SubTotal,
  8293. })
  8294. .ToArray();
  8295. var data = new ChoiceMobileSubInfo3To6View()
  8296. {
  8297. ParentId = eecInfo.Id,
  8298. Choice = eecInfo.ChoiceFive,
  8299. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8300. Details = dayAndCostDatas
  8301. };
  8302. return Ok(JsonView(data));
  8303. }
  8304. else if (subType == 6) //6:培训费
  8305. {
  8306. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8307. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8308. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8309. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8310. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8311. {
  8312. SubId = dac.Id,
  8313. DiId = dac.DiId,
  8314. Type = dac.Type,
  8315. Days = dac.Days,
  8316. NationalTravelFeeId = dac.NationalTravelFeeId,
  8317. Arae = $"{ntf.Country}-{ntf.City}",
  8318. Cost = dac.Cost,
  8319. Currency = dac.Currency,
  8320. CurrencyName = sd.Name,
  8321. SubTotal = dac.SubTotal,
  8322. })
  8323. .ToArray();
  8324. var data = new ChoiceMobileSubInfo3To6View()
  8325. {
  8326. ParentId = eecInfo.Id,
  8327. Choice = eecInfo.ChoiceSix,
  8328. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8329. Details = dayAndCostDatas
  8330. };
  8331. return Ok(JsonView(data));
  8332. }
  8333. else if (subType == 7) //7:其他
  8334. {
  8335. //其他款项
  8336. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8337. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8338. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8339. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8340. .OrderBy((dop, sd1, sd2) => dop.Index)
  8341. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8342. {
  8343. SubId = dop.Id,
  8344. DiId = dop.Diid,
  8345. Index = dop.Index,
  8346. SetDataId = dop.SetDataId,
  8347. SetDataName = sd1.Name,
  8348. Cost = dop.Cost,
  8349. Currency = dop.Currency,
  8350. CurrencyName = sd2.Name,
  8351. SubTotal = dop.SubTotal,
  8352. Remark = dop.Remark,
  8353. })
  8354. .ToArray();
  8355. var data = new ChoiceSevenMobileSubInfoView()
  8356. {
  8357. ParentId = eecInfo.Id,
  8358. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8359. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8360. Details = otherData
  8361. };
  8362. return Ok(JsonView(data));
  8363. }
  8364. return Ok(JsonView(false));
  8365. }
  8366. #region op
  8367. /// <summary>
  8368. /// 移动端更新费用消息通知
  8369. /// </summary>
  8370. /// <param name="diid"></param>
  8371. /// <param name="id"></param>
  8372. /// <param name="currUserId"></param>
  8373. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8374. {
  8375. try
  8376. {
  8377. ////生成默认文件pdf并且通知人员
  8378. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8379. //{
  8380. // DiId = diid,
  8381. // ExportType = 1,
  8382. // SubTypeId = 1005
  8383. //}, "pdf");
  8384. ////发送通知
  8385. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8386. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8387. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8388. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8389. ////汇率信息记录
  8390. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8391. }
  8392. catch (Exception ex)
  8393. {
  8394. //记录日志
  8395. throw;
  8396. }
  8397. }
  8398. /// <summary>
  8399. /// 验证出入境费用数据是否存在
  8400. /// 不存在添加
  8401. /// </summary>
  8402. /// <param name="diId"></param>
  8403. /// <param name="currUserId"></param>
  8404. /// <returns></returns>
  8405. /// <exception cref="CustomException"></exception>
  8406. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8407. {
  8408. var parentId = 0;
  8409. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8410. if (info != null)
  8411. {
  8412. parentId = info.Id;
  8413. }
  8414. else
  8415. {
  8416. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8417. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8418. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8419. parentId = addId;
  8420. }
  8421. return parentId;
  8422. }
  8423. /// <summary>
  8424. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8425. /// </summary>
  8426. /// <returns></returns>
  8427. [HttpPost]
  8428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8429. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8430. {
  8431. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8432. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8433. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8434. //验证编辑权限
  8435. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8436. //if (!isEdit) return Ok(JsonView(false, msg));
  8437. var permissions = new List<Grp_EnterExitCostPermission>();
  8438. foreach (var userId in dto.UserIds)
  8439. {
  8440. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8441. }
  8442. if (permissions.Any())
  8443. {
  8444. _sqlSugar.BeginTran();
  8445. try
  8446. {
  8447. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8448. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8449. if (result < 1)
  8450. {
  8451. _sqlSugar.RollbackTran();
  8452. return Ok(JsonView(false));
  8453. }
  8454. }
  8455. catch (Exception ex)
  8456. {
  8457. _sqlSugar.RollbackTran();
  8458. return Ok(JsonView(false, ex.Message));
  8459. }
  8460. _sqlSugar.CommitTran();
  8461. return Ok(JsonView(true));
  8462. }
  8463. return Ok(JsonView(false));
  8464. }
  8465. /// <summary>
  8466. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8467. /// </summary>
  8468. /// <returns></returns>
  8469. [HttpPost]
  8470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8471. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8472. {
  8473. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8474. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8475. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8476. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8477. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8478. int id = dto.Id;
  8479. if (id <= 0) //add
  8480. {
  8481. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8482. if (add < 1) return Ok(JsonView(false));
  8483. id = add;
  8484. }
  8485. else //update
  8486. {
  8487. ////验证编辑权限
  8488. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8489. //if (!isEdit) return Ok(JsonView(false, msg));
  8490. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8491. if (upd < 1) return Ok(JsonView(false));
  8492. }
  8493. #region 汇率变更时更改币种相关费用
  8494. var opDayCosts = new List<Grp_DayAndCost>();
  8495. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8496. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8497. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8498. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8499. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8500. .Select((dac, sd) => new
  8501. {
  8502. dac.Id,
  8503. dac.DiId,
  8504. CurrencyCode = sd.Name,
  8505. dac.Cost
  8506. })
  8507. .ToList();
  8508. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8509. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8510. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8511. .Select((dop, sd) => new
  8512. {
  8513. dop.Id,
  8514. dop.Diid,
  8515. CurrencyCode = sd.Name,
  8516. dop.Cost
  8517. })
  8518. .ToList();
  8519. if (dayCosts.Count > 0)
  8520. {
  8521. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8522. foreach (var dc in new_dayCosts)
  8523. {
  8524. var thisCurrency = dc.Key.ToUpper();
  8525. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8526. if (thisRate == 0.00M) continue;
  8527. foreach (var dcSub in dc)
  8528. {
  8529. opDayCosts.Add(new Grp_DayAndCost()
  8530. {
  8531. Id = dcSub.Id,
  8532. DiId = dcSub.DiId,
  8533. Cost = dcSub.Cost,
  8534. SubTotal = dcSub.Cost * thisRate,
  8535. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8536. });
  8537. }
  8538. }
  8539. if (opDayCosts.Count > 0)
  8540. {
  8541. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8542. }
  8543. }
  8544. if (dayOtherCosts.Count > 0)
  8545. {
  8546. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8547. foreach (var dc in new_dayOtherCosts)
  8548. {
  8549. var thisCurrency = dc.Key.ToUpper();
  8550. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8551. if (thisRate == 0.00M) continue;
  8552. foreach (var dcSub in dc)
  8553. {
  8554. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8555. {
  8556. Id = dcSub.Id,
  8557. Diid = dcSub.Diid,
  8558. Cost = dcSub.Cost,
  8559. SubTotal = dcSub.Cost * thisRate,
  8560. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8561. });
  8562. }
  8563. }
  8564. if (opDayOtherCosts.Count > 0)
  8565. {
  8566. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8567. }
  8568. }
  8569. #endregion
  8570. //消息通知
  8571. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8572. //汇率信息记录
  8573. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8574. return Ok(JsonView(new { parentId = id }));
  8575. }
  8576. /// <summary>
  8577. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8578. /// </summary>
  8579. /// <returns></returns>
  8580. [HttpPost]
  8581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8582. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8583. {
  8584. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8585. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8586. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8587. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8588. int id = dto.Id;
  8589. if (id <= 0) //add
  8590. {
  8591. checkboxInfo.CreateUserId = dto.CurrUserId;
  8592. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8593. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8594. if (add < 1) return Ok(JsonView(false));
  8595. }
  8596. else //update
  8597. {
  8598. ////验证编辑权限
  8599. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8600. //if (!isEdit) return Ok(JsonView(false, msg));
  8601. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8602. .UpdateColumns(x => new
  8603. {
  8604. x.ChoiceOne,
  8605. x.ChoiceTwo,
  8606. x.SumJJC,
  8607. x.SumGWC,
  8608. x.SumTDC,
  8609. x.ChoiceThree,
  8610. x.ChoiceFour,
  8611. x.ChoiceFive,
  8612. x.ChoiceSix,
  8613. x.OtherExpenses_Checked
  8614. })
  8615. .Where(x => x.Id == id)
  8616. .ExecuteCommandAsync();
  8617. if (upd < 1) return Ok(JsonView(false));
  8618. }
  8619. return Ok(JsonView(new { parentId = id }));
  8620. }
  8621. /// <summary>
  8622. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8623. /// </summary>
  8624. /// <returns></returns>
  8625. [HttpPost]
  8626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8627. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8628. {
  8629. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8630. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8631. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8632. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8633. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8634. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8635. var checkboxInfo = new Grp_EnterExitCost()
  8636. {
  8637. Id = id,
  8638. DiId = diId,
  8639. CreateUserId = currUserId
  8640. };
  8641. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8642. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8643. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8644. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8645. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8646. if (id <= 0) //add
  8647. {
  8648. checkboxInfo.CreateUserId = dto.CurrUserId;
  8649. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8650. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8651. if (add < 1) return Ok(JsonView(false));
  8652. }
  8653. else //update
  8654. {
  8655. ////验证编辑权限
  8656. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8657. //if (!isEdit) return Ok(JsonView(false, msg));
  8658. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8659. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8660. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8661. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8662. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8663. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8664. .Where(x => x.Id == id)
  8665. .ExecuteCommandAsync();
  8666. if (upd < 1) return Ok(JsonView(false));
  8667. }
  8668. return Ok(JsonView(new { parentId = id }));
  8669. }
  8670. /// <summary>
  8671. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8672. /// </summary>
  8673. /// <returns></returns>
  8674. [HttpPost]
  8675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8676. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8677. {
  8678. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8679. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8680. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8681. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8682. info.FirstItemRemark = dto.FirstItemRemark;
  8683. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8684. int id = dto.Id;
  8685. if (id <= 0) //add
  8686. {
  8687. info.CreateUserId = dto.CurrUserId;
  8688. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8689. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8690. if (add < 1) return Ok(JsonView(false));
  8691. id = add;
  8692. }
  8693. else //update
  8694. {
  8695. ////验证编辑权限
  8696. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8697. //if (!isEdit) return Ok(JsonView(false, msg));
  8698. var upd = await _sqlSugar.Updateable(info)
  8699. .UpdateColumns(x => new
  8700. {
  8701. x.ChoiceOne,
  8702. x.InsidePay,
  8703. x.VisaRemark,
  8704. x.Visa,
  8705. x.Service,
  8706. x.Safe,
  8707. x.Ticket,
  8708. x.HeSuan,
  8709. x.YiMiao,
  8710. x.FirstItemRemark
  8711. })
  8712. .Where(x => x.Id == id)
  8713. .ExecuteCommandAsync();
  8714. if (upd < 1) return Ok(JsonView(false));
  8715. }
  8716. //消息通知
  8717. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8718. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8719. }
  8720. /// <summary>
  8721. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8722. /// </summary>
  8723. /// <returns></returns>
  8724. [HttpPost]
  8725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8726. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8727. {
  8728. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8729. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8730. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8731. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8732. info.OutsideJJPay = dto.OutsideJJPay;
  8733. info.OutsideGWPay = dto.OutsideGWPay;
  8734. info.OutsideTDPay = dto.OutsideTDPay;
  8735. info.AirJJ = dto.AirJJ;
  8736. info.AirGW = dto.AirGW;
  8737. info.AirTD = dto.AirTD;
  8738. info.CityTranffic = dto.CityTranffic;
  8739. info.TwoItemRemark = dto.TwoItemRemark;
  8740. info.SumJJC = dto.ChoiceTwoJJ;
  8741. info.SumGWC = dto.ChoiceTwoGW;
  8742. info.SumTDC = dto.ChoiceTwoTD;
  8743. int id = dto.Id;
  8744. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8745. if (id <= 0) //add
  8746. {
  8747. info.CreateUserId = dto.CurrUserId;
  8748. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8749. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8750. if (addId <= 0) return Ok(JsonView(false));
  8751. id = addId;
  8752. }
  8753. else //update
  8754. {
  8755. ////验证编辑权限
  8756. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8757. //if (!isEdit) return Ok(JsonView(false, msg));
  8758. var upd = await _sqlSugar.Updateable(info)
  8759. .UpdateColumns(x => new
  8760. {
  8761. x.SumJJC,
  8762. x.OutsideJJPay,
  8763. x.SumGWC,
  8764. x.OutsideGWPay,
  8765. x.SumTDC,
  8766. x.OutsideTDPay,
  8767. x.AirJJ,
  8768. x.AirGW,
  8769. x.AirTD,
  8770. x.CityTranffic,
  8771. x.TwoItemRemark
  8772. })
  8773. .Where(x => x.Id == id)
  8774. .ExecuteCommandAsync();
  8775. if (upd < 1) return Ok(JsonView(false));
  8776. }
  8777. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8778. gwcItemTotal = info.AirGW + info.CityTranffic;
  8779. tdcItemTotal = info.AirTD + info.CityTranffic;
  8780. //消息通知
  8781. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8782. return Ok(JsonView(new
  8783. {
  8784. parentId = id,
  8785. choiceTwoJJ = dto.ChoiceTwoJJ,
  8786. jjcItemTotal = jjcItemTotal,
  8787. choiceTwoGW = dto.ChoiceTwoGW,
  8788. gwcItemTotal = gwcItemTotal,
  8789. choiceTwoTD = dto.ChoiceTwoTD,
  8790. tdcItemTotal = tdcItemTotal
  8791. }));
  8792. }
  8793. /// <summary>
  8794. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8795. /// </summary>
  8796. /// <returns></returns>
  8797. [HttpPost]
  8798. [ApiExplorerSettings(IgnoreApi = true)]
  8799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8800. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8801. {
  8802. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8803. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8804. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8805. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8806. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8807. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8808. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8809. var infos = infos1.Select(x => new Grp_DayAndCost
  8810. {
  8811. Id = x.Id,
  8812. DiId = dto.DiId,
  8813. Type = dto.FeeType,
  8814. Days = x.Days,
  8815. NationalTravelFeeId = x.NationalTravelFeeId,
  8816. Cost = x.Cost,
  8817. Currency = x.Currency,
  8818. SubTotal = x.SubTotal,
  8819. CreateUserId = dto.CurrUserId
  8820. })
  8821. .ToList();
  8822. var adds = infos.Where(x => x.Id <= 0).ToList();
  8823. var upds = infos.Where(x => x.Id > 0).ToList();
  8824. if (adds.Count > 0)
  8825. {
  8826. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8827. if (add < 1) return Ok(JsonView(false));
  8828. }
  8829. if (upds.Count > 0)
  8830. {
  8831. var upd = await _sqlSugar.Updateable(adds)
  8832. .UpdateColumns(x => new
  8833. {
  8834. x.Days,
  8835. x.NationalTravelFeeId,
  8836. x.Cost,
  8837. x.Currency,
  8838. x.SubTotal
  8839. })
  8840. .WhereColumns(x => new { x.Id })
  8841. .ExecuteCommandAsync();
  8842. if (upd < 1) return Ok(JsonView(false));
  8843. }
  8844. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8845. //消息通知
  8846. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8847. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8848. return Ok(JsonView(new { itemTotal = itemTotal }));
  8849. }
  8850. /// <summary>
  8851. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8852. /// </summary>
  8853. /// <returns></returns>
  8854. [HttpPost]
  8855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8856. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8857. {
  8858. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8859. int subId = dto.SubId, feeType = dto.FeeType;
  8860. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8861. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8862. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8863. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8864. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8865. subInfo.Id = subId;
  8866. subInfo.DiId = dto.DiId;
  8867. if (feeType == 3) subInfo.Type = 1;
  8868. else if (feeType == 4) subInfo.Type = 2;
  8869. else if (feeType == 5) subInfo.Type = 3;
  8870. else if (feeType == 6) subInfo.Type = 4;
  8871. subInfo.CreateUserId = dto.CurrUserId;
  8872. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8873. if (parentId < 1) return Ok(JsonView(false));
  8874. //子表op
  8875. if (subId < 1)
  8876. {
  8877. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8878. if (subAdd < 1) return Ok(JsonView(false));
  8879. }
  8880. else
  8881. {
  8882. ////验证编辑权限
  8883. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8884. //if (!isEdit) return Ok(JsonView(false, msg));
  8885. var subUpd = await _sqlSugar.Updateable(subInfo)
  8886. .UpdateColumns(x => new
  8887. {
  8888. x.Days,
  8889. x.NationalTravelFeeId,
  8890. x.Cost,
  8891. x.Currency,
  8892. x.SubTotal
  8893. })
  8894. .WhereColumns(x => new { x.Id })
  8895. .ExecuteCommandAsync();
  8896. if (subUpd < 1) return Ok(JsonView(false));
  8897. }
  8898. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8899. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8900. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8901. }
  8902. /// <summary>
  8903. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8904. /// </summary>
  8905. /// <returns></returns>
  8906. [HttpPost]
  8907. [ApiExplorerSettings(IgnoreApi = true)]
  8908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8909. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8910. {
  8911. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8912. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8913. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8914. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8915. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8916. {
  8917. Id = x.Id,
  8918. Diid = dto.DiId,
  8919. SetDataId = x.SetDataId,
  8920. Index = x.Index,
  8921. Cost = x.Cost,
  8922. Currency = x.Currency,
  8923. SubTotal = x.SubTotal,
  8924. CreateUserId = dto.CurrUserId,
  8925. Remark = x.Remark
  8926. }).ToList();
  8927. var adds = infos.Where(x => x.Id <= 0).ToList();
  8928. var upds = infos.Where(x => x.Id > 0).ToList();
  8929. if (adds.Count > 0)
  8930. {
  8931. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8932. if (add < 1) return Ok(JsonView(false));
  8933. }
  8934. if (upds.Count > 0)
  8935. {
  8936. var upd = await _sqlSugar.Updateable(adds)
  8937. .UpdateColumns(x => new
  8938. {
  8939. x.Index,
  8940. x.SetDataId,
  8941. x.Cost,
  8942. x.Currency,
  8943. x.SubTotal,
  8944. x.Remark
  8945. })
  8946. .WhereColumns(x => new { x.Id })
  8947. .ExecuteCommandAsync();
  8948. if (upd < 1) return Ok(JsonView(false));
  8949. }
  8950. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8951. //消息通知
  8952. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8953. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8954. return Ok(JsonView(new { itemTotal = itemTotal }));
  8955. }
  8956. /// <summary>
  8957. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8958. /// </summary>
  8959. /// <returns></returns>
  8960. [HttpPost]
  8961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8962. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8963. {
  8964. int subId = dto.SubId;
  8965. int diId = dto.Diid;
  8966. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8967. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8968. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8969. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8970. subInfo.Id = subId;
  8971. subInfo.Diid = dto.Diid;
  8972. subInfo.CreateUserId = dto.CurrUserId;
  8973. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8974. if (parentId < 1) return Ok(JsonView(false));
  8975. #region 子表op
  8976. if (subId < 1)//add
  8977. {
  8978. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8979. if (subAdd < 1) return Ok(JsonView(false));
  8980. }
  8981. else //upd
  8982. {
  8983. ////验证编辑权限
  8984. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8985. //if (!isEdit) return Ok(JsonView(false, msg));
  8986. var subUpd = await _sqlSugar.Updateable(subInfo)
  8987. .UpdateColumns(x => new
  8988. {
  8989. x.Index,
  8990. x.SetDataId,
  8991. x.Cost,
  8992. x.Currency,
  8993. x.SubTotal,
  8994. x.Remark
  8995. })
  8996. .WhereColumns(x => new { x.Id })
  8997. .ExecuteCommandAsync();
  8998. if (subUpd < 1) return Ok(JsonView(false));
  8999. }
  9000. #endregion
  9001. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9002. //消息通知
  9003. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9004. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9005. }
  9006. /// <summary>
  9007. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9008. /// </summary>
  9009. /// <returns></returns>
  9010. [HttpPost]
  9011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9012. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9013. {
  9014. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9015. if (data.Code != 0)
  9016. {
  9017. return Ok(JsonView(false, data.Msg));
  9018. }
  9019. return Ok(JsonView(true, "操作成功!", data.Data));
  9020. }
  9021. /// <summary>
  9022. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9023. /// </summary>
  9024. /// <param name="dto"></param>
  9025. /// <returns></returns>
  9026. [HttpPost]
  9027. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9028. {
  9029. var data = new Grp_DayOtherPrice()
  9030. {
  9031. Id = dto.Id,
  9032. IsDel = 1,
  9033. DeleteUserId = dto.DeleteUserId,
  9034. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9035. };
  9036. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9037. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9038. return Ok(JsonView(false, "删除失败!"));
  9039. }
  9040. #endregion
  9041. #endregion
  9042. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9043. /// <summary>
  9044. /// 出入境费用-草稿 移动端
  9045. /// 获取币种基础数据(含逻辑处理)
  9046. /// </summary>
  9047. /// <returns></returns>
  9048. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9049. {
  9050. //默认币种显示
  9051. var _currencyInfos = _currencyInit;
  9052. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9053. if (_currencyRate.Count > 0)
  9054. {
  9055. foreach (var item in _currencyInfos)
  9056. {
  9057. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9058. if (rateInfo != null)
  9059. {
  9060. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  9061. rate1 *= 1.035M;
  9062. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9063. }
  9064. }
  9065. }
  9066. return _currencyInfos;
  9067. }
  9068. /// <summary>
  9069. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9070. /// </summary>
  9071. /// <returns></returns>
  9072. [HttpPost]
  9073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9074. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9075. {
  9076. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9077. //SetDataInfoView
  9078. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9079. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9080. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9081. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9082. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9083. //默认币种显示
  9084. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9085. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9086. return Ok(JsonView(true, "查询成功!", new
  9087. {
  9088. WordTypeData = _WordTypeData,
  9089. ExcelTypeData = _ExcelTypeData,
  9090. CurrencyInit = _currencyInfos,
  9091. viewPermissionData = viewPermissionData
  9092. }));
  9093. }
  9094. /// <summary>
  9095. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9096. /// </summary>
  9097. /// <returns></returns>
  9098. [HttpPost]
  9099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9100. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9101. {
  9102. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9103. RefAsync<int> total = 0;
  9104. int diId = 0;
  9105. var status = int.TryParse(dto.GroupName, out diId);
  9106. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9107. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9108. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9109. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9110. .Select(x => new
  9111. {
  9112. Id = x.Id,
  9113. GroupName = x.TeamName
  9114. })
  9115. .OrderByDescending(x => x.Id)
  9116. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9117. return Ok(JsonView(true, "查询成功!", data, total));
  9118. }
  9119. /// <summary>
  9120. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9121. /// </summary>
  9122. /// <returns></returns>
  9123. [HttpPost]
  9124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9125. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9126. {
  9127. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9128. RefAsync<int> total = 0;
  9129. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9130. .Where(x => x.IsDel == 0 && x.STid == 66)
  9131. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9132. .Select(x => new
  9133. {
  9134. id = x.Id,
  9135. name = x.Name,
  9136. remark = x.Remark,
  9137. })
  9138. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9139. return Ok(JsonView(true, "查询成功!", data, total));
  9140. }
  9141. /// <summary>
  9142. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9143. /// </summary>
  9144. /// <returns></returns>
  9145. [HttpPost]
  9146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9147. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9148. {
  9149. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9150. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9151. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9152. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9153. var groupOtherRateData = groupRateData.TeamRates;
  9154. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9155. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9156. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9157. groupOtherRateData = groupOtherRateData
  9158. .Select(x => new TeamRateDescAddCurrencyIdView
  9159. {
  9160. CurrencyId = x.CurrencyId,
  9161. CurrencyName = x.CurrencyName,
  9162. CurrencyCode = x.CurrencyCode,
  9163. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9164. }).ToList();
  9165. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9166. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9167. }
  9168. /// <summary>
  9169. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9170. /// </summary>
  9171. /// <returns></returns>
  9172. [HttpPost]
  9173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9174. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9175. {
  9176. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9177. var tipsData = new List<int>() { 1, 2, 3 };
  9178. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9179. if (dto.TipsType == 1)
  9180. {
  9181. //默认币种显示
  9182. var _currencyInfos = _currencyInit;
  9183. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9184. List<dynamic> reteInfos = new List<dynamic>();
  9185. if (_currencyRate.Count > 0)
  9186. {
  9187. foreach (var item in _currencyInfos)
  9188. {
  9189. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9190. if (rateInfo != null)
  9191. {
  9192. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9193. decimal rate1 = item.Rate;
  9194. rate1 *= 1.03M;
  9195. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9196. reteInfos.Add(new
  9197. {
  9198. currCode = item.CurrencyCode,
  9199. currName = item.CurrencyName,
  9200. rate = rate2,
  9201. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9202. });
  9203. }
  9204. }
  9205. }
  9206. return Ok(JsonView(true, "查询成功!", reteInfos));
  9207. }
  9208. else if (dto.TipsType == 2)
  9209. {
  9210. }
  9211. else if (dto.TipsType == 3)
  9212. {
  9213. }
  9214. return Ok(JsonView(false));
  9215. }
  9216. /// <summary>
  9217. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9218. /// </summary>
  9219. /// <returns></returns>
  9220. [HttpPost]
  9221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9222. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9223. {
  9224. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9225. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9226. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9227. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9228. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9229. if (eecInfo == null) return Ok(mobileInfo);
  9230. //验证查看权限
  9231. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9232. if (!isView) return Ok(JsonView(false, msg));
  9233. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9234. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9235. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9236. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9237. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9238. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9239. {
  9240. ParentId = dac.ParentId,
  9241. SubId = dac.Id,
  9242. Type = dac.Type,
  9243. Days = dac.Days,
  9244. NationalTravelFeeId = dac.NationalTravelFeeId,
  9245. Arae = $"{ntf.Country}-{ntf.City}",
  9246. Cost = dac.Cost,
  9247. Currency = dac.Currency,
  9248. CurrencyName = sd.Name,
  9249. SubTotal = dac.SubTotal,
  9250. })
  9251. .ToList();
  9252. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9253. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9254. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9255. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9256. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9257. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9258. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9259. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9260. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9261. //其他款项
  9262. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9263. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9264. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9265. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9266. .OrderBy((dop, sd1, sd2) => dop.Index)
  9267. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9268. {
  9269. ParentId = dop.ParentId,
  9270. SubId = dop.Id,
  9271. Index = dop.Index,
  9272. SetDataId = dop.SetDataId,
  9273. SetDataName = sd1.Name,
  9274. Cost = dop.Cost,
  9275. Currency = dop.Currency,
  9276. CurrencyName = sd2.Remark,
  9277. SubTotal = dop.SubTotal,
  9278. Remark = dop.Remark,
  9279. })
  9280. .ToArray();
  9281. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9282. return Ok(mobileInfo);
  9283. }
  9284. /// <summary>
  9285. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9286. /// </summary>
  9287. /// <returns></returns>
  9288. [HttpPost]
  9289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9290. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9291. {
  9292. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9293. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9294. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9295. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9296. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9297. //验证查看权限
  9298. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9299. if (!isView) return Ok(JsonView(false, msg));
  9300. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9301. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9302. var subType = dto.SubType;
  9303. if (subType == 1) //1:境内费用
  9304. {
  9305. var oneData = new ChoiceOneMobileSubInfoView()
  9306. {
  9307. Id = eecInfo.Id,
  9308. ChoiceOne = eecInfo.ChoiceOne,
  9309. ChoiceOneTotalCost = eecInfo.InsidePay,
  9310. Visa = eecInfo.Visa,
  9311. VisaRemark = eecInfo.VisaRemark,
  9312. YiMiao = eecInfo.YiMiao,
  9313. HeSuan = eecInfo.HeSuan,
  9314. Service = eecInfo.Service,
  9315. Ticket = eecInfo.Ticket,
  9316. Safe = eecInfo.Safe,
  9317. FirstItemRemark = eecInfo.FirstItemRemark
  9318. };
  9319. return Ok(JsonView(oneData));
  9320. }
  9321. else if (subType == 2) //2:国际旅费
  9322. {
  9323. var twoData = new ChoiceTwoMobileSubInfoView()
  9324. {
  9325. Id = eecInfo.Id,
  9326. ChoiceTwoJJ = eecInfo.SumJJC,
  9327. OutsideJJPay = eecInfo.OutsideJJPay,
  9328. ChoiceTwoGW = eecInfo.SumGWC,
  9329. OutsideGWPay = eecInfo.OutsideGWPay,
  9330. ChoiceTwoTD = eecInfo.SumTDC,
  9331. OutsideTDPay = eecInfo.OutsideTDPay,
  9332. AirJJ = eecInfo.AirJJ,
  9333. AirGW = eecInfo.AirGW,
  9334. AirTD = eecInfo.AirTD,
  9335. CityTranffic = eecInfo.CityTranffic,
  9336. TwoItemRemark = eecInfo.TwoItemRemark
  9337. };
  9338. return Ok(JsonView(twoData));
  9339. }
  9340. else if (subType == 3) //3:住宿费
  9341. {
  9342. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9343. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9344. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9345. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9346. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9347. {
  9348. ParentId = dac.ParentId,
  9349. SubId = dac.Id,
  9350. Type = dac.Type,
  9351. Days = dac.Days,
  9352. NationalTravelFeeId = dac.NationalTravelFeeId,
  9353. Arae = $"{ntf.Country}-{ntf.City}",
  9354. Cost = dac.Cost,
  9355. Currency = dac.Currency,
  9356. CurrencyName = sd.Name,
  9357. SubTotal = dac.SubTotal,
  9358. })
  9359. .ToArray();
  9360. var data = new ChoiceDraftMobileSubInfo3To6View()
  9361. {
  9362. ParentId = eecInfo.Id,
  9363. Choice = eecInfo.ChoiceThree,
  9364. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9365. Details = dayAndCostDatas
  9366. };
  9367. return Ok(JsonView(data));
  9368. }
  9369. else if (subType == 4) //4:伙食费
  9370. {
  9371. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9372. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9373. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9374. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9375. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9376. {
  9377. ParentId = dac.ParentId,
  9378. SubId = dac.Id,
  9379. Type = dac.Type,
  9380. Days = dac.Days,
  9381. NationalTravelFeeId = dac.NationalTravelFeeId,
  9382. Arae = $"{ntf.Country}-{ntf.City}",
  9383. Cost = dac.Cost,
  9384. Currency = dac.Currency,
  9385. CurrencyName = sd.Name,
  9386. SubTotal = dac.SubTotal,
  9387. })
  9388. .ToArray();
  9389. var data = new ChoiceDraftMobileSubInfo3To6View()
  9390. {
  9391. ParentId = eecInfo.Id,
  9392. Choice = eecInfo.ChoiceFour,
  9393. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9394. Details = dayAndCostDatas
  9395. };
  9396. return Ok(JsonView(data));
  9397. }
  9398. else if (subType == 5) //5:公杂费
  9399. {
  9400. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9401. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9402. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9403. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9404. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9405. {
  9406. ParentId = dac.ParentId,
  9407. SubId = dac.Id,
  9408. Type = dac.Type,
  9409. Days = dac.Days,
  9410. NationalTravelFeeId = dac.NationalTravelFeeId,
  9411. Arae = $"{ntf.Country}-{ntf.City}",
  9412. Cost = dac.Cost,
  9413. Currency = dac.Currency,
  9414. CurrencyName = sd.Name,
  9415. SubTotal = dac.SubTotal,
  9416. })
  9417. .ToArray();
  9418. var data = new ChoiceDraftMobileSubInfo3To6View()
  9419. {
  9420. ParentId = eecInfo.Id,
  9421. Choice = eecInfo.ChoiceFive,
  9422. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9423. Details = dayAndCostDatas
  9424. };
  9425. return Ok(JsonView(data));
  9426. }
  9427. else if (subType == 6) //6:培训费
  9428. {
  9429. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9430. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9431. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9432. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9433. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9434. {
  9435. ParentId = dac.ParentId,
  9436. SubId = dac.Id,
  9437. Type = dac.Type,
  9438. Days = dac.Days,
  9439. NationalTravelFeeId = dac.NationalTravelFeeId,
  9440. Arae = $"{ntf.Country}-{ntf.City}",
  9441. Cost = dac.Cost,
  9442. Currency = dac.Currency,
  9443. CurrencyName = sd.Name,
  9444. SubTotal = dac.SubTotal,
  9445. })
  9446. .ToArray();
  9447. var data = new ChoiceDraftMobileSubInfo3To6View()
  9448. {
  9449. ParentId = eecInfo.Id,
  9450. Choice = eecInfo.ChoiceSix,
  9451. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9452. Details = dayAndCostDatas
  9453. };
  9454. return Ok(JsonView(data));
  9455. }
  9456. else if (subType == 7) //7:其他
  9457. {
  9458. //其他款项
  9459. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9460. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9461. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9462. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9463. .OrderBy((dop, sd1, sd2) => dop.Index)
  9464. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9465. {
  9466. ParentId = dop.ParentId,
  9467. SubId = dop.Id,
  9468. Index = dop.Index,
  9469. SetDataId = dop.SetDataId,
  9470. SetDataName = sd1.Name,
  9471. Cost = dop.Cost,
  9472. Currency = dop.Currency,
  9473. CurrencyName = sd2.Name,
  9474. SubTotal = dop.SubTotal,
  9475. Remark = dop.Remark,
  9476. })
  9477. .ToArray();
  9478. var data = new ChoiceSevenDraftMobileSubInfoView()
  9479. {
  9480. ParentId = eecInfo.Id,
  9481. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9482. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9483. Details = otherData
  9484. };
  9485. return Ok(JsonView(data));
  9486. }
  9487. return Ok(JsonView(false));
  9488. }
  9489. #region op
  9490. /// <summary>
  9491. /// 移动端更新费用消息通知
  9492. /// </summary>
  9493. /// <param name="draftId"></param>
  9494. /// <param name="id"></param>
  9495. /// <param name="currUserId"></param>
  9496. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9497. {
  9498. try
  9499. {
  9500. ////生成默认文件pdf并且通知人员
  9501. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9502. //{
  9503. // DiId = draftId,
  9504. // ExportType = 1,
  9505. // SubTypeId = 1005
  9506. //}, "pdf");
  9507. ////发送通知
  9508. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9509. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9510. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9511. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9512. ////汇率信息记录
  9513. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9514. }
  9515. catch (Exception ex)
  9516. {
  9517. //记录日志
  9518. throw;
  9519. }
  9520. }
  9521. /// <summary>
  9522. /// 验证出入境费用数据是否存在
  9523. /// 不存在添加
  9524. /// </summary>
  9525. /// <param name="draftId"></param>
  9526. /// <param name="currUserId"></param>
  9527. /// <returns></returns>
  9528. /// <exception cref="CustomException"></exception>
  9529. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9530. {
  9531. var parentId = 0;
  9532. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9533. if (info != null) parentId = info.Id;
  9534. else
  9535. {
  9536. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9537. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9538. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9539. parentId = addId;
  9540. }
  9541. return parentId;
  9542. }
  9543. /// <summary>
  9544. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9545. /// </summary>
  9546. /// <returns></returns>
  9547. [HttpPost]
  9548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9549. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9550. {
  9551. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9552. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9553. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9554. //验证编辑权限
  9555. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9556. if (!isEdit) return Ok(JsonView(false, msg));
  9557. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9558. foreach (var userId in dto.UserIds)
  9559. {
  9560. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9561. }
  9562. if (permissions.Any())
  9563. {
  9564. _sqlSugar.BeginTran();
  9565. try
  9566. {
  9567. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9568. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9569. if (result < 1)
  9570. {
  9571. _sqlSugar.RollbackTran();
  9572. return Ok(JsonView(false));
  9573. }
  9574. }
  9575. catch (Exception ex)
  9576. {
  9577. _sqlSugar.RollbackTran();
  9578. return Ok(JsonView(false, ex.Message));
  9579. }
  9580. _sqlSugar.CommitTran();
  9581. return Ok(JsonView(true));
  9582. }
  9583. return Ok(JsonView(false));
  9584. }
  9585. /// <summary>
  9586. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9587. /// </summary>
  9588. /// <returns></returns>
  9589. [HttpPost]
  9590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9591. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9592. {
  9593. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9594. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9595. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9596. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9597. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9598. int id = dto.DraftId;
  9599. if (id <= 0) //add
  9600. {
  9601. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9602. if (add < 1) return Ok(JsonView(false));
  9603. id = add;
  9604. }
  9605. else //update
  9606. {
  9607. //验证编辑权限
  9608. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9609. if (!isEdit) return Ok(JsonView(false, msg));
  9610. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9611. if (upd < 1) return Ok(JsonView(false));
  9612. }
  9613. #region 汇率变更时更改币种相关费用
  9614. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9615. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9616. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9617. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9618. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9619. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9620. .Select((dac, sd) => new
  9621. {
  9622. dac.Id,
  9623. dac.ParentId,
  9624. CurrencyCode = sd.Name,
  9625. dac.Cost
  9626. })
  9627. .ToList();
  9628. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9629. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9630. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9631. .Select((dop, sd) => new
  9632. {
  9633. dop.Id,
  9634. dop.ParentId,
  9635. CurrencyCode = sd.Name,
  9636. dop.Cost
  9637. })
  9638. .ToList();
  9639. if (dayCosts.Count > 0)
  9640. {
  9641. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9642. foreach (var dc in new_dayCosts)
  9643. {
  9644. var thisCurrency = dc.Key.ToUpper();
  9645. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9646. if (thisRate == 0.00M) continue;
  9647. foreach (var dcSub in dc)
  9648. {
  9649. opDayCosts.Add(new Grp_DayAndCostDraft()
  9650. {
  9651. Id = dcSub.Id,
  9652. ParentId = dcSub.ParentId,
  9653. Cost = dcSub.Cost,
  9654. SubTotal = dcSub.Cost * thisRate,
  9655. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9656. });
  9657. }
  9658. }
  9659. if (opDayCosts.Count > 0)
  9660. {
  9661. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9662. }
  9663. }
  9664. if (dayOtherCosts.Count > 0)
  9665. {
  9666. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9667. foreach (var dc in new_dayOtherCosts)
  9668. {
  9669. var thisCurrency = dc.Key.ToUpper();
  9670. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9671. if (thisRate == 0.00M) continue;
  9672. foreach (var dcSub in dc)
  9673. {
  9674. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9675. {
  9676. Id = dcSub.Id,
  9677. ParentId = dcSub.ParentId,
  9678. Cost = dcSub.Cost,
  9679. SubTotal = dcSub.Cost * thisRate,
  9680. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9681. });
  9682. }
  9683. }
  9684. if (opDayOtherCosts.Count > 0)
  9685. {
  9686. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9687. }
  9688. }
  9689. #endregion
  9690. ////消息通知
  9691. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9692. ////汇率信息记录
  9693. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9694. return Ok(JsonView(new { parentId = id }));
  9695. }
  9696. /// <summary>
  9697. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9698. /// </summary>
  9699. /// <returns></returns>
  9700. [HttpPost]
  9701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9702. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9703. {
  9704. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9705. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9706. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9707. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9708. int id = dto.DraftId;
  9709. if (id <= 0) //add
  9710. {
  9711. checkboxInfo.CreateUserId = dto.CurrUserId;
  9712. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9713. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9714. if (add < 1) return Ok(JsonView(false));
  9715. }
  9716. else //update
  9717. {
  9718. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9719. .UpdateColumns(x => new
  9720. {
  9721. x.ChoiceOne,
  9722. x.ChoiceTwo,
  9723. x.SumJJC,
  9724. x.SumGWC,
  9725. x.SumTDC,
  9726. x.ChoiceThree,
  9727. x.ChoiceFour,
  9728. x.ChoiceFive,
  9729. x.ChoiceSix,
  9730. x.OtherExpenses_Checked
  9731. })
  9732. .Where(x => x.Id == id)
  9733. .ExecuteCommandAsync();
  9734. if (upd < 1) return Ok(JsonView(false));
  9735. }
  9736. return Ok(JsonView(new { parentId = id }));
  9737. }
  9738. /// <summary>
  9739. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9740. /// </summary>
  9741. /// <returns></returns>
  9742. [HttpPost]
  9743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9744. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9745. {
  9746. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9747. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9748. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9749. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9750. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9751. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9752. var checkboxInfo = new Grp_EnterExitCostDraft()
  9753. {
  9754. Id = draftId,
  9755. CreateUserId = currUserId
  9756. };
  9757. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9758. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9759. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9760. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9761. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9762. if (draftId <= 0) //add
  9763. {
  9764. checkboxInfo.CreateUserId = dto.CurrUserId;
  9765. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9766. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9767. if (add < 1) return Ok(JsonView(false));
  9768. }
  9769. else //update
  9770. {
  9771. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9772. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9773. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9774. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9775. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9776. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9777. .Where(x => x.Id == draftId)
  9778. .ExecuteCommandAsync();
  9779. if (upd < 1) return Ok(JsonView(false));
  9780. }
  9781. return Ok(JsonView(new { parentId = draftId }));
  9782. }
  9783. /// <summary>
  9784. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9785. /// </summary>
  9786. /// <returns></returns>
  9787. [HttpPost]
  9788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9789. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9790. {
  9791. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9792. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9793. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9794. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9795. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9796. info.FirstItemRemark = dto.FirstItemRemark;
  9797. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9798. if (id <= 0) //add
  9799. {
  9800. info.CreateUserId = dto.CurrUserId;
  9801. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9802. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9803. if (add < 1) return Ok(JsonView(false));
  9804. id = add;
  9805. }
  9806. else //update
  9807. {
  9808. var upd = await _sqlSugar.Updateable(info)
  9809. .UpdateColumns(x => new
  9810. {
  9811. x.ChoiceOne,
  9812. x.InsidePay,
  9813. x.VisaRemark,
  9814. x.Visa,
  9815. x.Service,
  9816. x.Safe,
  9817. x.Ticket,
  9818. x.HeSuan,
  9819. x.YiMiao,
  9820. x.FirstItemRemark
  9821. })
  9822. .Where(x => x.Id == id)
  9823. .ExecuteCommandAsync();
  9824. if (upd < 1) return Ok(JsonView(false));
  9825. }
  9826. ////消息通知
  9827. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9828. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9829. }
  9830. /// <summary>
  9831. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9832. /// </summary>
  9833. /// <returns></returns>
  9834. [HttpPost]
  9835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9836. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9837. {
  9838. int id = dto.DraftId;
  9839. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9840. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9841. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9842. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9843. info.OutsideJJPay = dto.OutsideJJPay;
  9844. info.OutsideGWPay = dto.OutsideGWPay;
  9845. info.OutsideTDPay = dto.OutsideTDPay;
  9846. info.AirJJ = dto.AirJJ;
  9847. info.AirGW = dto.AirGW;
  9848. info.AirTD = dto.AirTD;
  9849. info.CityTranffic = dto.CityTranffic;
  9850. info.TwoItemRemark = dto.TwoItemRemark;
  9851. info.SumJJC = dto.ChoiceTwoJJ;
  9852. info.SumGWC = dto.ChoiceTwoGW;
  9853. info.SumTDC = dto.ChoiceTwoTD;
  9854. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9855. if (id <= 0) //add
  9856. {
  9857. info.CreateUserId = dto.CurrUserId;
  9858. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9859. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9860. if (addId <= 0) return Ok(JsonView(false));
  9861. id = addId;
  9862. }
  9863. else //update
  9864. {
  9865. var upd = await _sqlSugar.Updateable(info)
  9866. .UpdateColumns(x => new
  9867. {
  9868. x.SumJJC,
  9869. x.OutsideJJPay,
  9870. x.SumGWC,
  9871. x.OutsideGWPay,
  9872. x.SumTDC,
  9873. x.OutsideTDPay,
  9874. x.AirJJ,
  9875. x.AirGW,
  9876. x.AirTD,
  9877. x.CityTranffic,
  9878. x.TwoItemRemark
  9879. })
  9880. .Where(x => x.Id == id)
  9881. .ExecuteCommandAsync();
  9882. if (upd < 1) return Ok(JsonView(false));
  9883. }
  9884. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9885. gwcItemTotal = info.AirGW + info.CityTranffic;
  9886. tdcItemTotal = info.AirTD + info.CityTranffic;
  9887. ////消息通知
  9888. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9889. return Ok(JsonView(new
  9890. {
  9891. parentId = id,
  9892. choiceTwoJJ = dto.ChoiceTwoJJ,
  9893. jjcItemTotal = jjcItemTotal,
  9894. choiceTwoGW = dto.ChoiceTwoGW,
  9895. gwcItemTotal = gwcItemTotal,
  9896. choiceTwoTD = dto.ChoiceTwoTD,
  9897. tdcItemTotal = tdcItemTotal
  9898. }));
  9899. }
  9900. /// <summary>
  9901. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9902. /// </summary>
  9903. /// <returns></returns>
  9904. [HttpPost]
  9905. [ApiExplorerSettings(IgnoreApi = true)]
  9906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9907. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9908. {
  9909. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9910. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9911. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9912. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9913. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9914. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9915. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9916. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9917. {
  9918. Id = x.Id,
  9919. ParentId = dto.DraftId,
  9920. Type = dto.FeeType,
  9921. Days = x.Days,
  9922. NationalTravelFeeId = x.NationalTravelFeeId,
  9923. Cost = x.Cost,
  9924. Currency = x.Currency,
  9925. SubTotal = x.SubTotal,
  9926. CreateUserId = dto.CurrUserId
  9927. })
  9928. .ToList();
  9929. var adds = infos.Where(x => x.Id <= 0).ToList();
  9930. var upds = infos.Where(x => x.Id > 0).ToList();
  9931. if (adds.Count > 0)
  9932. {
  9933. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9934. if (add < 1) return Ok(JsonView(false));
  9935. }
  9936. if (upds.Count > 0)
  9937. {
  9938. var upd = await _sqlSugar.Updateable(adds)
  9939. .UpdateColumns(x => new
  9940. {
  9941. x.Days,
  9942. x.NationalTravelFeeId,
  9943. x.Cost,
  9944. x.Currency,
  9945. x.SubTotal
  9946. })
  9947. .WhereColumns(x => new { x.Id })
  9948. .ExecuteCommandAsync();
  9949. if (upd < 1) return Ok(JsonView(false));
  9950. }
  9951. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9952. ////消息通知
  9953. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9954. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9955. return Ok(JsonView(new { itemTotal = itemTotal }));
  9956. }
  9957. /// <summary>
  9958. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9959. /// </summary>
  9960. /// <returns></returns>
  9961. [HttpPost]
  9962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9963. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9964. {
  9965. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9966. int subId = dto.SubId, feeType = dto.FeeType;
  9967. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9968. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9969. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9970. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9971. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9972. subInfo.Id = subId;
  9973. subInfo.ParentId = dto.DraftId;
  9974. if (feeType == 3) subInfo.Type = 1;
  9975. else if (feeType == 4) subInfo.Type = 2;
  9976. else if (feeType == 5) subInfo.Type = 3;
  9977. else if (feeType == 6) subInfo.Type = 4;
  9978. subInfo.CreateUserId = dto.CurrUserId;
  9979. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9980. if (parentId < 1) return Ok(JsonView(false));
  9981. //子表op
  9982. if (subId < 1)
  9983. {
  9984. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9985. if (subAdd < 1) return Ok(JsonView(false));
  9986. }
  9987. else
  9988. {
  9989. var subUpd = await _sqlSugar.Updateable(subInfo)
  9990. .UpdateColumns(x => new
  9991. {
  9992. x.Days,
  9993. x.NationalTravelFeeId,
  9994. x.Cost,
  9995. x.Currency,
  9996. x.SubTotal
  9997. })
  9998. .WhereColumns(x => new { x.Id })
  9999. .ExecuteCommandAsync();
  10000. if (subUpd < 1) return Ok(JsonView(false));
  10001. }
  10002. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10003. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10004. }
  10005. /// <summary>
  10006. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10007. /// </summary>
  10008. /// <returns></returns>
  10009. [HttpPost]
  10010. [ApiExplorerSettings(IgnoreApi = true)]
  10011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10012. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10013. {
  10014. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10015. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10016. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10017. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10018. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10019. {
  10020. Id = x.Id,
  10021. ParentId = dto.DraftId,
  10022. SetDataId = x.SetDataId,
  10023. Index = x.Index,
  10024. Cost = x.Cost,
  10025. Currency = x.Currency,
  10026. SubTotal = x.SubTotal,
  10027. CreateUserId = dto.CurrUserId,
  10028. Remark = x.Remark
  10029. }).ToList();
  10030. var adds = infos.Where(x => x.Id <= 0).ToList();
  10031. var upds = infos.Where(x => x.Id > 0).ToList();
  10032. if (adds.Count > 0)
  10033. {
  10034. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10035. if (add < 1) return Ok(JsonView(false));
  10036. }
  10037. if (upds.Count > 0)
  10038. {
  10039. var upd = await _sqlSugar.Updateable(adds)
  10040. .UpdateColumns(x => new
  10041. {
  10042. x.Index,
  10043. x.SetDataId,
  10044. x.Cost,
  10045. x.Currency,
  10046. x.SubTotal,
  10047. x.Remark
  10048. })
  10049. .WhereColumns(x => new { x.Id })
  10050. .ExecuteCommandAsync();
  10051. if (upd < 1) return Ok(JsonView(false));
  10052. }
  10053. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10054. //消息通知
  10055. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10056. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10057. return Ok(JsonView(new { itemTotal = itemTotal }));
  10058. }
  10059. /// <summary>
  10060. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10061. /// </summary>
  10062. /// <returns></returns>
  10063. [HttpPost]
  10064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10065. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10066. {
  10067. int subId = dto.SubId, id = dto.DarftId;
  10068. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10069. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10070. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10071. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10072. subInfo.Id = subId;
  10073. subInfo.ParentId = dto.DarftId;
  10074. subInfo.CreateUserId = dto.CurrUserId;
  10075. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10076. if (parentId < 1) return Ok(JsonView(false));
  10077. #region 子表op
  10078. if (subId < 1)//add
  10079. {
  10080. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10081. if (subAdd < 1) return Ok(JsonView(false));
  10082. }
  10083. else //upd
  10084. {
  10085. var subUpd = await _sqlSugar.Updateable(subInfo)
  10086. .UpdateColumns(x => new
  10087. {
  10088. x.Index,
  10089. x.SetDataId,
  10090. x.Cost,
  10091. x.Currency,
  10092. x.SubTotal,
  10093. x.Remark
  10094. })
  10095. .WhereColumns(x => new { x.Id })
  10096. .ExecuteCommandAsync();
  10097. if (subUpd < 1) return Ok(JsonView(false));
  10098. }
  10099. #endregion
  10100. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10101. ////消息通知
  10102. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10103. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10104. }
  10105. /// <summary>
  10106. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10107. /// </summary>
  10108. /// <returns></returns>
  10109. [HttpPost]
  10110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10111. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10112. {
  10113. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10114. if (data.Code != 0)
  10115. {
  10116. return Ok(JsonView(false, data.Msg));
  10117. }
  10118. return Ok(JsonView(true, "操作成功!", data.Data));
  10119. }
  10120. /// <summary>
  10121. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10122. /// </summary>
  10123. /// <param name="dto"></param>
  10124. /// <returns></returns>
  10125. [HttpPost]
  10126. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10127. {
  10128. var data = new Grp_DayOtherPriceDraft()
  10129. {
  10130. Id = dto.Id,
  10131. IsDel = 1,
  10132. DeleteUserId = dto.DeleteUserId,
  10133. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10134. };
  10135. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10136. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10137. return Ok(JsonView(false, "删除失败!"));
  10138. }
  10139. #endregion
  10140. #endregion
  10141. #region 签证费用录入
  10142. /// <summary>
  10143. /// 根据diid查询签证费用列表
  10144. /// </summary>
  10145. /// <param name="dto"></param>
  10146. /// <returns></returns>
  10147. [HttpPost]
  10148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10149. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10150. {
  10151. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10152. if (groupData.Code != 0)
  10153. {
  10154. return Ok(JsonView(false, groupData.Msg));
  10155. }
  10156. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10157. }
  10158. /// <summary>
  10159. /// 根据签证费用Id查询单条数据及c表数据
  10160. /// </summary>
  10161. /// <param name="dto"></param>
  10162. /// <returns></returns>
  10163. [HttpPost]
  10164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10165. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10166. {
  10167. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10168. if (groupData.Code != 0)
  10169. {
  10170. return Ok(JsonView(false, groupData.Msg));
  10171. }
  10172. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10173. }
  10174. /// <summary>
  10175. /// 签证费用删除
  10176. /// </summary>
  10177. /// <param name="dto"></param>
  10178. /// <returns></returns>
  10179. [HttpPost]
  10180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10181. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10182. {
  10183. _sqlSugar.BeginTran();
  10184. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10185. if (!res)
  10186. {
  10187. _sqlSugar.RollbackTran();
  10188. return Ok(JsonView(false, "删除失败"));
  10189. }
  10190. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10191. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10192. .SetColumns(a => new Grp_CreditCardPayment()
  10193. {
  10194. IsDel = 1,
  10195. DeleteUserId = dto.DeleteUserId,
  10196. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10197. })
  10198. .ExecuteCommand();
  10199. if (resSub < 1)
  10200. {
  10201. _sqlSugar.RollbackTran();
  10202. return Ok(JsonView(false, "删除失败"));
  10203. }
  10204. _sqlSugar.CommitTran();
  10205. return Ok(JsonView(true, "删除成功!"));
  10206. }
  10207. /// <summary>
  10208. /// 签证费用录入下拉框初始化
  10209. /// </summary>
  10210. /// <returns></returns>
  10211. [HttpPost]
  10212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10213. public async Task<IActionResult> VisaPriceAddSelect()
  10214. {
  10215. //支付方式
  10216. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10217. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10218. //币种
  10219. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10220. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10221. //乘客类型
  10222. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10223. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10224. //卡类型
  10225. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10226. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10227. //代办费类型
  10228. var agencyFeeTypeData = new List<dynamic>() {
  10229. new { id = 0 , Text = "未选择" },
  10230. new { id = 1 , Text = "小公务" },
  10231. new { id = 2 , Text = "大公务" },
  10232. };
  10233. //签证费用标准国家Data
  10234. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10235. var data = new
  10236. {
  10237. Payment = _Payment,
  10238. CurrencyList = _CurrencyList,
  10239. PassengerType = _PassengerType,
  10240. BankCard = _BankCard,
  10241. AgencyFeeType = agencyFeeTypeData,
  10242. CountryFeeData = visaCountryFeeData
  10243. };
  10244. return Ok(JsonView(true, "查询成功!", data));
  10245. }
  10246. /// <summary>
  10247. /// 签证费用录入操作(Status:1.新增,2.修改)
  10248. /// </summary>
  10249. /// <param name="dto"></param>
  10250. /// <returns></returns>
  10251. [HttpPost]
  10252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10253. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10254. {
  10255. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10256. if (groupData.Code != 0)
  10257. {
  10258. return Ok(JsonView(false, groupData.Msg));
  10259. }
  10260. #region 应用推送
  10261. try
  10262. {
  10263. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10264. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10265. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10266. //2024-10-21 新增LZ UID
  10267. var userIds = new List<int>() { 21 };
  10268. string title = $"系统通知";
  10269. string content = "";
  10270. var diId = dto.DiId;
  10271. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10272. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10273. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10274. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10275. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10276. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10277. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10278. }
  10279. catch (Exception ex)
  10280. {
  10281. }
  10282. #endregion
  10283. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10284. }
  10285. #endregion
  10286. #region 签证提成录入
  10287. /// <summary>
  10288. /// 签证提成录入
  10289. /// 基础数据
  10290. /// </summary>
  10291. /// <returns></returns>
  10292. [HttpGet]
  10293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10294. public async Task<IActionResult> VisaCommissionInit()
  10295. {
  10296. return Ok(await _visaCommissionRep.Init());
  10297. }
  10298. /// <summary>
  10299. /// 签证提成录入
  10300. /// Item
  10301. /// </summary>
  10302. /// <param name="_dto"></param>
  10303. /// <returns></returns>
  10304. [HttpPost]
  10305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10306. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10307. {
  10308. var validator = new VisaCommissionItemDtoValidator();
  10309. var validatorRes = await validator.ValidateAsync(_dto);
  10310. if (!validatorRes.IsValid)
  10311. {
  10312. StringBuilder sb = new StringBuilder();
  10313. foreach (var item in validatorRes.Errors)
  10314. {
  10315. sb.AppendLine(item.ErrorMessage);
  10316. }
  10317. return Ok(JsonView(false, sb.ToString()));
  10318. }
  10319. return Ok(await _visaCommissionRep.Item(_dto));
  10320. }
  10321. /// <summary>
  10322. /// 签证提成录入
  10323. /// Save
  10324. /// </summary>
  10325. /// <param name="_dto"></param>
  10326. /// <returns></returns>
  10327. [HttpPost]
  10328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10329. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10330. {
  10331. //参数验证
  10332. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10333. foreach (var item in _dto.Items)
  10334. {
  10335. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10336. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10337. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10338. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10339. }
  10340. return Ok(await _visaCommissionRep.Save(_dto));
  10341. }
  10342. /// <summary>
  10343. /// 签证提成录入
  10344. /// Create
  10345. /// </summary>
  10346. /// <param name="_dto"></param>
  10347. /// <returns></returns>
  10348. [HttpPost]
  10349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10350. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10351. {
  10352. var validator = new VisaCommissionCreateDtoValidator();
  10353. var validatorRes = await validator.ValidateAsync(_dto);
  10354. if (!validatorRes.IsValid)
  10355. {
  10356. StringBuilder sb = new StringBuilder();
  10357. foreach (var item in validatorRes.Errors)
  10358. {
  10359. sb.AppendLine(item.ErrorMessage);
  10360. }
  10361. return Ok(JsonView(false, sb.ToString()));
  10362. }
  10363. return Ok(await _visaCommissionRep.Create(_dto));
  10364. }
  10365. /// <summary>
  10366. /// 签证提成录入
  10367. /// Put(编辑)
  10368. /// </summary>
  10369. /// <param name="id"></param>
  10370. /// <param name="_dto"></param>
  10371. /// <returns></returns>
  10372. [HttpPut]
  10373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10374. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10375. {
  10376. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10377. var validator = new VisaCommissionCreateDtoValidator();
  10378. var validatorRes = await validator.ValidateAsync(_dto);
  10379. if (!validatorRes.IsValid)
  10380. {
  10381. StringBuilder sb = new StringBuilder();
  10382. foreach (var item in validatorRes.Errors)
  10383. {
  10384. sb.AppendLine(item.ErrorMessage);
  10385. }
  10386. return Ok(JsonView(false, sb.ToString()));
  10387. }
  10388. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10389. }
  10390. /// <summary>
  10391. /// 签证提成录入
  10392. /// Del
  10393. /// </summary>
  10394. /// <param name="id"></param>
  10395. /// <param name="currUserId"></param>
  10396. /// <returns></returns>
  10397. [HttpPost]
  10398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10399. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10400. {
  10401. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10402. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10403. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10404. }
  10405. #endregion
  10406. #region op费用录入
  10407. /// <summary>
  10408. /// 根据diid查询op费用列表
  10409. /// </summary>
  10410. /// <param name="dto"></param>
  10411. /// <returns></returns>
  10412. [HttpPost]
  10413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10414. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10415. {
  10416. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10417. if (groupData.Code != 0)
  10418. {
  10419. return Ok(JsonView(false, groupData.Msg));
  10420. }
  10421. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10422. }
  10423. /// <summary>
  10424. /// 根据op费用Id查询单条数据及c表数据
  10425. /// </summary>
  10426. /// <param name="dto"></param>
  10427. /// <returns></returns>
  10428. [HttpPost]
  10429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10430. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10431. {
  10432. try
  10433. {
  10434. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10435. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10436. var data = new
  10437. {
  10438. CarTouristGuideGround = _groupData,
  10439. CreditCardPayment = _creditCardPayment
  10440. };
  10441. return Ok(JsonView(true, "查询成功!", data));
  10442. }
  10443. catch (Exception ex)
  10444. {
  10445. return Ok(JsonView(false, "程序错误!"));
  10446. }
  10447. }
  10448. /// <summary>
  10449. /// op费用删除
  10450. /// </summary>
  10451. /// <param name="dto"></param>
  10452. /// <returns></returns>
  10453. [HttpPost]
  10454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10455. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10456. {
  10457. try
  10458. {
  10459. _sqlSugar.BeginTran();
  10460. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10461. if (!res)
  10462. {
  10463. return Ok(JsonView(false, "删除失败"));
  10464. }
  10465. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10466. {
  10467. IsDel = 1,
  10468. DeleteUserId = dto.DeleteUserId,
  10469. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10470. }).ExecuteCommandAsync();
  10471. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10472. {
  10473. IsDel = 1,
  10474. DeleteUserId = dto.DeleteUserId,
  10475. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10476. }).ExecuteCommandAsync();
  10477. #region 删除超支相关数据
  10478. //删除导入的超支数据
  10479. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10480. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10481. {
  10482. IsDel = 1,
  10483. DeleteUserId = dto.DeleteUserId,
  10484. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10485. }).ExecuteCommand();
  10486. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10487. {
  10488. IsDel = 1,
  10489. DeleteUserId = dto.DeleteUserId,
  10490. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10491. }).ExecuteCommand();
  10492. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10493. {
  10494. IsDel = 1,
  10495. DeleteUserId = dto.DeleteUserId,
  10496. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10497. }).ExecuteCommand();
  10498. #endregion
  10499. _sqlSugar.CommitTran();
  10500. return Ok(JsonView(true, "删除成功!"));
  10501. }
  10502. catch (Exception ex)
  10503. {
  10504. _sqlSugar.RollbackTran();
  10505. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10506. }
  10507. }
  10508. /// <summary>
  10509. /// op费用录入操作(Status:1.新增,2.修改)
  10510. /// </summary>
  10511. /// <param name="dto"></param>
  10512. /// <returns></returns>
  10513. [HttpPost]
  10514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10515. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10516. {
  10517. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10518. if (groupData.Code != 0)
  10519. {
  10520. return Ok(JsonView(false, groupData.Msg));
  10521. }
  10522. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10523. }
  10524. /// <summary>
  10525. /// 填写费用详细页面初始化绑定
  10526. /// </summary>
  10527. /// <param name="dto"></param>
  10528. /// <returns></returns>
  10529. [HttpPost]
  10530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10531. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10532. {
  10533. try
  10534. {
  10535. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10536. if (groupData.Code != 0)
  10537. {
  10538. return Ok(JsonView(false, groupData.Msg));
  10539. }
  10540. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10541. }
  10542. catch (Exception ex)
  10543. {
  10544. return Ok(JsonView(false, ex.Message));
  10545. }
  10546. }
  10547. /// <summary>
  10548. /// 根据op费用Id查询详细数据
  10549. /// </summary>
  10550. /// <param name="dto"></param>
  10551. /// <returns></returns>
  10552. [HttpPost]
  10553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10554. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10555. {
  10556. try
  10557. {
  10558. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10559. if (groupData.Code != 0)
  10560. {
  10561. return Ok(JsonView(false, groupData.Msg));
  10562. }
  10563. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10564. }
  10565. catch (Exception ex)
  10566. {
  10567. return Ok(JsonView(false, ex.Message));
  10568. }
  10569. }
  10570. /// <summary>
  10571. /// OP费用录入填写详情
  10572. /// </summary>
  10573. /// <param name="dto"></param>
  10574. /// <returns></returns>
  10575. [HttpPost]
  10576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10577. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10578. {
  10579. try
  10580. {
  10581. #region 参数校验
  10582. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10583. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10584. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10585. #endregion
  10586. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10587. if (groupData.Code != 0)
  10588. {
  10589. return Ok(JsonView(false, groupData.Msg));
  10590. }
  10591. //自动审核
  10592. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10593. #region 应用推送
  10594. try
  10595. {
  10596. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10597. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10598. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10599. //2024-10-21 新增LZ UID
  10600. var userIds = new List<int>() { 21 };
  10601. string title = $"系统通知";
  10602. var diId = dto.DiId;
  10603. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10604. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10605. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  10606. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10607. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10608. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10609. }
  10610. catch (Exception ex)
  10611. {
  10612. }
  10613. #endregion
  10614. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10615. }
  10616. catch (Exception ex)
  10617. {
  10618. return Ok(JsonView(false, ex.Message));
  10619. }
  10620. }
  10621. /// <summary>
  10622. /// 获取三公详细所有城市
  10623. /// </summary>
  10624. /// <returns></returns>
  10625. [HttpGet]
  10626. public IActionResult OpCarCityResult()
  10627. {
  10628. var jw = JsonView(false);
  10629. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10630. {
  10631. x.Id,
  10632. x.Country,
  10633. x.City,
  10634. }).ToList();
  10635. if (data.Count > 0)
  10636. {
  10637. jw = JsonView(true, "获取成功!", data);
  10638. }
  10639. else
  10640. {
  10641. jw.Msg = "城市数据为空!";
  10642. jw.Data = new string[0];
  10643. }
  10644. return Ok(jw);
  10645. }
  10646. /// <summary>
  10647. /// 导出地接费用明细
  10648. /// </summary>
  10649. /// <param name="dto"></param>
  10650. /// <returns></returns>
  10651. [HttpPost]
  10652. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10653. {
  10654. var jw = JsonView(false);
  10655. if (dto.Diid < 1)
  10656. {
  10657. jw.Msg = "请输入正确的diid!";
  10658. return Ok(jw);
  10659. }
  10660. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10661. if (group == null)
  10662. {
  10663. jw.Msg = "未找到团组信息!";
  10664. return Ok(jw);
  10665. }
  10666. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10667. if (localGuideArr.Count == 0)
  10668. {
  10669. jw.Msg = "该团组暂无地接信息!";
  10670. return Ok(jw);
  10671. }
  10672. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10673. var overspendSoure = new Dictionary<int, int>
  10674. {
  10675. { 91, 982 }, //车
  10676. { 92 , 1059} ,//导游
  10677. { 994 , 1073}, //翻译
  10678. { 988 , 1074 }, //早餐
  10679. { 93 , 1075 }, //午餐
  10680. { 989 , 1076 }, //晚餐
  10681. };
  10682. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10683. foreach (var groupArr in localGroup)
  10684. {
  10685. var keyValue = groupArr.Key;
  10686. if (int.TryParse(keyValue, out int cityid))
  10687. {
  10688. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10689. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10690. }
  10691. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10692. foreach (var item in groupArr)
  10693. {
  10694. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10695. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10696. new Grp_CarTouristGuideGroundReservationsContentExtend
  10697. {
  10698. Count = a.Count,
  10699. CreateTime = a.CreateTime,
  10700. CreateUserId = a.CreateUserId,
  10701. CTGGRId = a.CTGGRId,
  10702. Currency = a.Currency,
  10703. DatePrice = a.DatePrice,
  10704. DeleteTime = a.DeleteTime,
  10705. DeleteUserId = a.DeleteUserId,
  10706. DiId = a.DiId,
  10707. Id = a.Id,
  10708. IsDel = a.IsDel,
  10709. Price = a.Price,
  10710. PriceContent = a.PriceContent,
  10711. Remark = a.Remark,
  10712. SId = a.SId,
  10713. SidName = b.Name,
  10714. Units = a.Units,
  10715. }
  10716. ).ToList();
  10717. if (content.Count > 0)
  10718. {
  10719. contentArr.Add(content);
  10720. }
  10721. }
  10722. //open excel
  10723. //set excel
  10724. //save excel
  10725. try
  10726. {
  10727. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10728. IWorkbook workbook;
  10729. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10730. {
  10731. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10732. }
  10733. else
  10734. {
  10735. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10736. }
  10737. ISheet sheet = workbook.GetSheetAt(0);
  10738. var rowStartIndex = 2;
  10739. var clounmCount = 10;
  10740. var initStyleRow = sheet.GetRow(2);
  10741. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10742. //var overspendArrDetail =
  10743. var existsId = new List<CarCompare>();
  10744. var lastElem = arr.Last();
  10745. var thisSid = -1;
  10746. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10747. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10748. {
  10749. Name = "未知币种!",
  10750. Remark = "未知币种!",
  10751. };
  10752. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10753. Action cloneRowFn = () =>
  10754. {
  10755. rowStartIndex++;
  10756. var cloneRow = sheet.CreateRow(rowStartIndex);
  10757. // 复制样式
  10758. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10759. {
  10760. ICell sourceCell = initStyleRow.GetCell(i);
  10761. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10762. // 确保单元格存在样式
  10763. if (sourceCell.CellStyle != null)
  10764. {
  10765. targetCell.CellStyle = sourceCell.CellStyle;
  10766. }
  10767. }
  10768. };
  10769. var mergeRow = () =>
  10770. {
  10771. for (int i = 2; i < sheet.LastRowNum; i++)
  10772. {
  10773. var row = sheet.GetRow(i);
  10774. var cellFirst = row.GetCell(0);
  10775. var thisIndex = i + 1;
  10776. while (thisIndex < sheet.LastRowNum)
  10777. {
  10778. var nextRow = sheet.GetRow(thisIndex);
  10779. var nextCellFirst = nextRow.GetCell(0);
  10780. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10781. {
  10782. thisIndex++;
  10783. }
  10784. else
  10785. {
  10786. break;
  10787. }
  10788. }
  10789. thisIndex--;
  10790. if (thisIndex != i)
  10791. {
  10792. //合并row
  10793. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10794. i, // 起始行索引(0-based)
  10795. thisIndex, // 结束行索引(0-based)
  10796. 0, // 起始列索引(0-based)
  10797. 0 // 结束列索引(0-based)
  10798. );
  10799. sheet.AddMergedRegion(cellRangeAddress);
  10800. i = thisIndex;
  10801. }
  10802. }
  10803. };
  10804. var chaoshiNumber = 0;
  10805. var totalNumber = 0.00M;
  10806. string lastStr = "";
  10807. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10808. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10809. {
  10810. b.IsAuditGM,
  10811. x.Id,
  10812. x.Area,
  10813. b.PayPercentage,
  10814. b.PayMoney,
  10815. }).ToList();
  10816. string yesPayment = "", noPayment = "";
  10817. foreach (var item in queryCarArrByCityAndDiid)
  10818. {
  10819. if (item.IsAuditGM == 1)
  10820. {
  10821. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10822. }
  10823. else
  10824. {
  10825. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10826. }
  10827. }
  10828. lastStr = yesPayment + noPayment;
  10829. foreach (var item in arr)
  10830. {
  10831. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10832. {
  10833. if (thisSid != item.SId)
  10834. {
  10835. if (thisSid == -1)
  10836. {
  10837. thisSid = item.SId;
  10838. }
  10839. else
  10840. {
  10841. //合并小计行
  10842. //创建合并区域的实例
  10843. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10844. rowStartIndex, // 起始行索引(0-based)
  10845. rowStartIndex, // 结束行索引(0-based)
  10846. 0, // 起始列索引(0-based)
  10847. 3 // 结束列索引(0-based)
  10848. );
  10849. sheet.AddMergedRegion(cellRangeAddress);
  10850. var CellStyle = workbook.CreateCellStyle();
  10851. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10852. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10853. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10854. for (int i = 0; i <= clounmCount; i++)
  10855. {
  10856. if (i > 6)
  10857. {
  10858. var CellStyle1 = workbook.CreateCellStyle();
  10859. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10860. IFont Font = workbook.CreateFont(); // 创建字体
  10861. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10862. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10863. CellStyle1.SetFont(Font);
  10864. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10865. }
  10866. else
  10867. {
  10868. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10869. }
  10870. }
  10871. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10872. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10873. //超时合计
  10874. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10875. //超时数
  10876. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10877. //超时合计费用
  10878. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10879. thisSid = item.SId;
  10880. cloneRowFn();
  10881. chaoshiNumber = 0;
  10882. totalNumber = 0;
  10883. }
  10884. }
  10885. IRow row = sheet.GetRow(rowStartIndex);
  10886. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10887. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10888. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10889. if (isOpenOverspendSoure)
  10890. {
  10891. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10892. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10893. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10894. }
  10895. for (int i = 0; i <= clounmCount; i++)
  10896. {
  10897. var cell = row.GetCell(i);
  10898. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10899. if (cell == null)
  10900. {
  10901. cell = row.CreateCell(i);
  10902. }
  10903. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10904. fontRed.CloneStyleFrom(cell.CellStyle);
  10905. IFont Font = workbook.CreateFont(); // 创建字体
  10906. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10907. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10908. fontRed.SetFont(Font);
  10909. byte[] rgb = new byte[3] { 255, 242, 204 };
  10910. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10911. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10912. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10913. if (workbook is XSSFWorkbook)
  10914. {
  10915. BackgroundColor255_242_204.FillForegroundColor = 0;
  10916. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10917. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10918. }
  10919. else
  10920. {
  10921. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10922. }
  10923. if (i == 1 || i > 6)
  10924. {
  10925. if (i > 6)
  10926. {
  10927. fontRed.FillForegroundColor = 0;
  10928. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10929. fontRed.FillPattern = FillPattern.SolidForeground;
  10930. }
  10931. cell.CellStyle = fontRed;
  10932. }
  10933. if (i > 2 && i < 7)
  10934. {
  10935. cell.CellStyle = BackgroundColor255_242_204;
  10936. }
  10937. cell.SetCellValue(setCellValue); //写入单元格
  10938. }
  10939. if (overspendSoure.ContainsKey(thisSid))
  10940. {
  10941. var overspendId = overspendSoure[thisSid];
  10942. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10943. }
  10944. cloneRowFn();
  10945. existsId.Add(new CarCompare
  10946. {
  10947. DataPrice = item.DatePrice.ObjToDate(),
  10948. Sid = item.SId
  10949. });
  10950. }
  10951. if (item.Equals(lastElem))
  10952. {
  10953. //合并小计行
  10954. //创建合并区域的实例
  10955. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10956. rowStartIndex, // 起始行索引(0-based)
  10957. rowStartIndex, // 结束行索引(0-based)
  10958. 0, // 起始列索引(0-based)
  10959. 3 // 结束列索引(0-based)
  10960. );
  10961. sheet.AddMergedRegion(cellRangeAddress);
  10962. var CellStyle = workbook.CreateCellStyle();
  10963. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10964. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10965. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10966. for (int i = 0; i <= clounmCount; i++)
  10967. {
  10968. if (i > 6)
  10969. {
  10970. var CellStyle1 = workbook.CreateCellStyle();
  10971. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10972. IFont Font = workbook.CreateFont(); // 创建字体
  10973. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10974. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10975. CellStyle1.SetFont(Font);
  10976. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10977. }
  10978. else
  10979. {
  10980. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10981. }
  10982. }
  10983. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10984. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10985. //超时合计
  10986. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10987. //超时数
  10988. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10989. //超时合计费用
  10990. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10991. cloneRowFn();
  10992. // 创建合并区域的实例
  10993. cellRangeAddress = new CellRangeAddress(
  10994. rowStartIndex, // 起始行索引(0-based)
  10995. rowStartIndex, // 结束行索引(0-based)
  10996. 0, // 起始列索引(0-based)
  10997. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10998. );
  10999. // 添加合并区域
  11000. sheet.AddMergedRegion(cellRangeAddress);
  11001. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11002. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11003. }
  11004. }
  11005. mergeRow();
  11006. // 保存修改后的Excel文件到新文件
  11007. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11008. // new FileStream(newFilePath, FileMode.CreateNew)
  11009. using (var stream = new MemoryStream())
  11010. {
  11011. workbook.Write(stream, true);
  11012. stream.Flush();
  11013. stream.Seek(0, SeekOrigin.Begin);
  11014. MemoryStream memoryStream = new MemoryStream();
  11015. stream.CopyTo(memoryStream);
  11016. memoryStream.Seek(0, SeekOrigin.Begin);
  11017. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11018. }
  11019. workbook.Close();
  11020. workbook.Dispose();
  11021. }
  11022. catch (Exception ex)
  11023. {
  11024. jw.Msg = "出现异常!" + ex.Message;
  11025. return Ok(jw);
  11026. }
  11027. }
  11028. if (Zips.Count > 0)
  11029. {
  11030. IOOperatorHelper io = new IOOperatorHelper();
  11031. var byts = io.ConvertZipStream(Zips);
  11032. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11033. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11034. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11035. }
  11036. else
  11037. {
  11038. jw.Msg = "暂无生成文件!";
  11039. }
  11040. return Ok(jw);
  11041. }
  11042. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11043. {
  11044. string outStr = string.Empty;
  11045. switch (i)
  11046. {
  11047. case 0:
  11048. outStr = arr[0].SidName;
  11049. break;
  11050. case 1:
  11051. outStr = arr[0].DataPriceStr;
  11052. break;
  11053. case 2:
  11054. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11055. break;
  11056. case 4:
  11057. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11058. break;
  11059. case 7:
  11060. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11061. {
  11062. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11063. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11064. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11065. }
  11066. break;
  11067. case 8:
  11068. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11069. {
  11070. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11071. }
  11072. break;
  11073. case 9:
  11074. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11075. {
  11076. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11077. }
  11078. break;
  11079. case 10:
  11080. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11081. {
  11082. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11083. }
  11084. break;
  11085. }
  11086. return outStr;
  11087. }
  11088. #region OP行程单
  11089. /// <summary>
  11090. /// OP行程单初始化
  11091. /// </summary>
  11092. /// <param name="dto"></param>
  11093. /// <returns></returns>
  11094. [HttpPost]
  11095. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11096. {
  11097. var jw = JsonView(false);
  11098. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11099. var group = groupList.First();
  11100. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11101. if (group == null)
  11102. {
  11103. jw.Msg = "暂无团组!";
  11104. return Ok(jw);
  11105. }
  11106. group = groupList.Find(x => x.Id == diid);
  11107. if (group == null)
  11108. {
  11109. jw.Msg = "请输入正确的团组ID!";
  11110. return Ok(jw);
  11111. }
  11112. string city = string.Empty;
  11113. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11114. if (blackCode.Count > 0)
  11115. {
  11116. var black = blackCode.First();
  11117. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11118. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11119. if (blackSp.Length > 0)
  11120. {
  11121. try
  11122. {
  11123. var cityArrCode = new List<string>(20);
  11124. foreach (var item in blackSp)
  11125. {
  11126. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11127. var IndexSelect = itemSp[2];
  11128. var cityArrCodeLength = cityArrCode.Count - 1;
  11129. var startCity = IndexSelect.Substring(0, 3);
  11130. if (cityArrCodeLength > 0)
  11131. {
  11132. var arrEndCity = cityArrCode[cityArrCodeLength];
  11133. if (arrEndCity != startCity)
  11134. {
  11135. cityArrCode.Add(startCity.ToUpper());
  11136. }
  11137. }
  11138. else
  11139. {
  11140. cityArrCode.Add(startCity.ToUpper());
  11141. }
  11142. var endCity = IndexSelect.Substring(3, 3);
  11143. cityArrCode.Add(endCity.ToUpper());
  11144. }
  11145. var cityThree = string.Empty;
  11146. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11147. cityThree = cityThree.TrimEnd(',');
  11148. if (string.IsNullOrWhiteSpace(cityThree))
  11149. {
  11150. throw new
  11151. Exception("error");
  11152. }
  11153. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11154. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11155. foreach (var item in cityArrCode)
  11156. {
  11157. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11158. if (find != null)
  11159. {
  11160. city += find.City + "/";
  11161. }
  11162. else
  11163. {
  11164. city += item + "三字码未收入/";
  11165. }
  11166. }
  11167. city = city.TrimEnd('/');
  11168. }
  11169. catch (Exception e)
  11170. {
  11171. city = "黑屏代码格式不正确!";
  11172. }
  11173. }
  11174. }
  11175. else
  11176. {
  11177. city = "未录入黑屏代码";
  11178. }
  11179. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11180. {
  11181. Date = x.Date,
  11182. Days = x.Days,
  11183. Diffgroup = x.Diffgroup,
  11184. Diid = x.Diid,
  11185. Traffic_First = x.Traffic_First,
  11186. Traffic_Second = x.Traffic_Second,
  11187. Trip = x.Trip,
  11188. WeekDay = x.WeekDay,
  11189. Id = x.Id
  11190. }).ToList();
  11191. jw.Data = new
  11192. {
  11193. groupList = groupList.Select(x => new
  11194. {
  11195. x.Id,
  11196. x.TeamName,
  11197. x.TourCode
  11198. }).ToList(),
  11199. groupInfo = new
  11200. {
  11201. group.VisitDays,
  11202. group.TourCode,
  11203. group.VisitPNumber,
  11204. group.TeamName,
  11205. city
  11206. },
  11207. OpTravelList
  11208. };
  11209. jw.Code = 200;
  11210. jw.Msg = "操作成功!";
  11211. return Ok(jw);
  11212. }
  11213. /// <summary>
  11214. /// 删除团组行程单
  11215. /// </summary>
  11216. /// <returns></returns>
  11217. [HttpPost]
  11218. public IActionResult DelTravel(DelOpTravelDto dto)
  11219. {
  11220. var jw = JsonView(false);
  11221. if (dto.UserId <= 0 || dto.Diid <= 0)
  11222. {
  11223. jw.Msg = "请输入正确的参数!";
  11224. return Ok(jw);
  11225. }
  11226. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11227. .SetColumns(x => new Grp_TravelList
  11228. {
  11229. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11230. DeleteUserId = dto.UserId,
  11231. IsDel = 1,
  11232. }).ExecuteCommand();
  11233. jw = JsonView(true);
  11234. return Ok(jw);
  11235. }
  11236. /// <summary>
  11237. /// 行程单保存
  11238. /// </summary>
  11239. /// <returns></returns>
  11240. [HttpPost]
  11241. public IActionResult TravelSave(TravelSaveDto dto)
  11242. {
  11243. var jw = JsonView(false);
  11244. if (dto.Arr.Count > 0)
  11245. {
  11246. try
  11247. {
  11248. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11249. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11250. .ToList();
  11251. _sqlSugar.BeginTran();
  11252. foreach (var item in dto.Arr)
  11253. {
  11254. if (item.Id == 0)
  11255. {
  11256. throw new Exception("请传入正确的Id");
  11257. }
  11258. //比较上一次的差异
  11259. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11260. if (findTravel != null)
  11261. {
  11262. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11263. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11264. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11265. }
  11266. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11267. .SetColumns(x => new Grp_TravelList
  11268. {
  11269. Trip = item.Trip
  11270. }).ExecuteCommand();
  11271. }
  11272. _sqlSugar.CommitTran();
  11273. jw = JsonView(true);
  11274. }
  11275. catch (Exception ex)
  11276. {
  11277. _sqlSugar.RollbackTran();
  11278. jw.Msg = "程序异常!" + ex.Message;
  11279. }
  11280. }
  11281. else
  11282. {
  11283. jw.Msg = "请传入正确的参数!";
  11284. }
  11285. return Ok(jw);
  11286. }
  11287. private string CheckStr(string original, string changed)
  11288. {
  11289. // 创建diff_match_patch对象
  11290. var dmp = new diff_match_patch();
  11291. // 计算差异
  11292. List<Diff> diffs = dmp.diff_main(original, changed);
  11293. // 清理和合并差异
  11294. dmp.diff_cleanupSemantic(diffs);
  11295. // 使用StringBuilder构建最终的字符串
  11296. StringBuilder finalString = new StringBuilder();
  11297. // 输出差异结果,并构建变动后的字符串
  11298. foreach (Diff diff in diffs)
  11299. {
  11300. switch (diff.operation)
  11301. {
  11302. case Operation.EQUAL:
  11303. // 相等的部分,直接添加到最终字符串
  11304. finalString.Append(diff.text);
  11305. break;
  11306. case Operation.INSERT:
  11307. // 插入的部分,添加标记并添加到最终字符串
  11308. finalString.Append("[++]" + diff.text + "[++]");
  11309. break;
  11310. case Operation.DELETE:
  11311. // 删除的部分,不添加到最终字符串
  11312. //finalString.Append("[++]" + diff.text + "[++]");
  11313. break;
  11314. }
  11315. }
  11316. // 输出变动后的字符串
  11317. return finalString.ToString();
  11318. }
  11319. private class tagContent
  11320. {
  11321. public DateTime Date { get; set; }
  11322. public string StartTag { get; set; }
  11323. public string EndTag { get; set; }
  11324. public string Content { get; set; }
  11325. public static int tagLength { get { return 3; } }
  11326. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11327. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11328. public bool IsFinally { get; set; }
  11329. }
  11330. private List<string> ExtractContentBetweenTags(string input, string tag)
  11331. {
  11332. List<string> results = new List<string>();
  11333. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11334. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11335. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11336. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11337. string[] strValueArr = new string[1];
  11338. foreach (System.Text.RegularExpressions.Match match in matches)
  11339. {
  11340. var strValue = match.Groups[1].Value;
  11341. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11342. }
  11343. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11344. return results;
  11345. }
  11346. /// <summary>
  11347. /// 导出行程单
  11348. /// </summary>
  11349. /// <param name="dto"></param>
  11350. /// <returns></returns>
  11351. [HttpPost]
  11352. public IActionResult ExportTravel(ExportTravelDto dto)
  11353. {
  11354. var jw = JsonView(false);
  11355. jw.Data = "";
  11356. int diid = 0;
  11357. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11358. if (Find == null)
  11359. {
  11360. jw.Msg = "请选择正确的团组!";
  11361. return Ok(jw);
  11362. }
  11363. else
  11364. {
  11365. diid = Find.Id;
  11366. }
  11367. //数据源
  11368. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11369. DataTable dtBlack = null;
  11370. try
  11371. {
  11372. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11373. }
  11374. catch (Exception)
  11375. {
  11376. jw.Msg = "机票黑屏代码有误!";
  11377. return Ok(jw);
  11378. }
  11379. string CityStr = string.Empty;
  11380. if (dtBlack.Rows.Count == 0)
  11381. {
  11382. jw.Msg = "机票黑屏代码有误!";
  11383. return Ok(jw);
  11384. }
  11385. else
  11386. {
  11387. foreach (DataRow row in dtBlack.Rows)
  11388. {
  11389. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11390. {
  11391. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11392. return Ok(jw);
  11393. }
  11394. }
  11395. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11396. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11397. }
  11398. // 指定的文字
  11399. var targetTextDic = new Dictionary<string, List<string>>();
  11400. //创建数据源Table
  11401. DataTable dtSource = new DataTable();
  11402. dtSource.Columns.Add("Days", typeof(string));
  11403. dtSource.Columns.Add("Date", typeof(string));
  11404. dtSource.Columns.Add("Week", typeof(string));
  11405. dtSource.Columns.Add("Traffic", typeof(string));
  11406. dtSource.Columns.Add("Trip", typeof(string));
  11407. //获取数据,放到datatable
  11408. foreach (var item in _travelList)
  11409. {
  11410. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11411. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11412. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11413. .Replace("[++]", string.Empty);
  11414. DataRow dr = dtSource.NewRow();
  11415. dr["Days"] = item.Days;
  11416. dr["Date"] = item.Date;
  11417. dr["Week"] = item.WeekDay;
  11418. dr["Traffic"] = item.Traffic_First
  11419. + "\r\n"
  11420. + item.Traffic_Second;
  11421. dr["Trip"] = item.Trip;
  11422. dtSource.Rows.Add(dr);
  11423. }
  11424. Dictionary<string, string> dic = new Dictionary<string, string>();
  11425. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11426. dic.Add("City", CityStr);
  11427. dic.Add("Days", Find.VisitDays.ToString());
  11428. dic.Add("DeleCode", Find.TourCode);
  11429. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11430. //模板路径
  11431. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11432. //载入模板
  11433. Document doc = null;
  11434. DocumentBuilder builder = null;
  11435. try
  11436. {
  11437. //载入模板
  11438. doc = new Document(tempPath);
  11439. builder = new DocumentBuilder(doc);
  11440. }
  11441. catch (Exception)
  11442. {
  11443. jw.Msg = "模板位置不存在!";
  11444. return Ok(jw);
  11445. }
  11446. foreach (var key in dic.Keys)
  11447. {
  11448. Bookmark bookmark = doc.Range.Bookmarks[key];
  11449. if (bookmark != null)
  11450. {
  11451. builder.MoveToBookmark(key);
  11452. builder.Write(dic[key]);
  11453. }
  11454. }
  11455. //获取word里所有表格
  11456. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11457. //获取所填表格的序数
  11458. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11459. try
  11460. {
  11461. //循环赋值
  11462. for (int i = 0; i < dtSource.Rows.Count; i++)
  11463. {
  11464. builder.MoveToCell(0, i + 1, 0, 0);
  11465. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11466. builder.MoveToCell(0, i + 1, 1, 0);
  11467. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11468. builder.MoveToCell(0, i + 1, 2, 0);
  11469. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11470. var trip = dtSource.Rows[i]["Trip"].ToString();
  11471. builder.MoveToCell(0, i + 1, 3, 0);
  11472. builder.Write(trip);
  11473. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11474. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11475. // 获取特定索引的段落
  11476. Paragraph paragraph = (Paragraph)paragraphs[0];
  11477. Run run = paragraph.Runs[0];
  11478. Aspose.Words.Font font = run.Font;
  11479. font.Name = "黑体";
  11480. //设置双休红色
  11481. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11482. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11483. paragraph = (Paragraph)paragraphs[1];
  11484. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11485. {
  11486. run = paragraph.Runs[0];
  11487. font = run.Font;
  11488. font.Color = Color.Red;
  11489. }
  11490. }
  11491. }
  11492. catch (Exception ex)
  11493. {
  11494. }
  11495. //删除多余行
  11496. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11497. {
  11498. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11499. }
  11500. var targetTextList = new List<string>();
  11501. // 遍历文档中的表格
  11502. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11503. {
  11504. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11505. {
  11506. var cellIndex = 0;
  11507. foreach (Cell cell in row.Cells)
  11508. {
  11509. if (cellIndex == 1 && row.Cells.Count == 4)
  11510. {
  11511. foreach (var target in targetTextDic.Keys)
  11512. {
  11513. if (cell.GetText().Contains(target))
  11514. {
  11515. targetTextList = targetTextDic[target];
  11516. break;
  11517. }
  11518. }
  11519. }
  11520. // 遍历单元格中的所有段落
  11521. foreach (Paragraph paragraph in cell.Paragraphs)
  11522. {
  11523. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11524. List<Run> runs = new List<Run>();
  11525. foreach (Run run in paragraph.Runs)
  11526. {
  11527. runs.Add(run);
  11528. }
  11529. foreach (Run run in runs)
  11530. {
  11531. foreach (var targetText in targetTextList)
  11532. {
  11533. // 检查文字是否包含指定文字
  11534. if (run.Text.Contains(targetText))
  11535. {
  11536. // 将包含的部分设置为红色
  11537. HighlightText(run, targetText, Color.Red);
  11538. }
  11539. }
  11540. }
  11541. }
  11542. cellIndex++;
  11543. }
  11544. }
  11545. }
  11546. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11547. if (!Directory.Exists(savePath))
  11548. {
  11549. try
  11550. {
  11551. Directory.CreateDirectory(savePath);
  11552. }
  11553. catch
  11554. {
  11555. }
  11556. }
  11557. string path = savePath + Find.TeamName + "出访日程";
  11558. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11559. try
  11560. {
  11561. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11562. string postfix = ".docx";
  11563. if (dto.IsPDF == 1)
  11564. {
  11565. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11566. postfix = ".pdf";
  11567. }
  11568. doc.Save(path + postfix, saveFormat);
  11569. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11570. }
  11571. catch (Exception)
  11572. {
  11573. jw = JsonView(false);
  11574. }
  11575. return Ok(jw);
  11576. }
  11577. /// <summary>
  11578. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11579. /// </summary>
  11580. /// <param name="num"></param>
  11581. /// <returns></returns>
  11582. string GetNum(string num)
  11583. {
  11584. string str = "";
  11585. switch (num)
  11586. {
  11587. case "1":
  11588. str = "一";
  11589. break;
  11590. case "2":
  11591. str = "二";
  11592. break;
  11593. case "3":
  11594. str = "三";
  11595. break;
  11596. case "4":
  11597. str = "四";
  11598. break;
  11599. case "5":
  11600. str = "五";
  11601. break;
  11602. case "6":
  11603. str = "六";
  11604. break;
  11605. case "7":
  11606. str = "七";
  11607. break;
  11608. case "8":
  11609. str = "八";
  11610. break;
  11611. case "9":
  11612. str = "九";
  11613. break;
  11614. case "10":
  11615. str = "十";
  11616. break;
  11617. case "11":
  11618. str = "十一";
  11619. break;
  11620. case "12":
  11621. str = "十二";
  11622. break;
  11623. case "一":
  11624. str = "1";
  11625. break;
  11626. case "二":
  11627. str = "2";
  11628. break;
  11629. case "三":
  11630. str = "3";
  11631. break;
  11632. case "四":
  11633. str = "4";
  11634. break;
  11635. case "五":
  11636. str = "5";
  11637. break;
  11638. case "六":
  11639. str = "6";
  11640. break;
  11641. case "七":
  11642. str = "7";
  11643. break;
  11644. case "八":
  11645. str = "8";
  11646. break;
  11647. case "九":
  11648. str = "9";
  11649. break;
  11650. case "十":
  11651. str = "10";
  11652. break;
  11653. case "十一":
  11654. str = "11";
  11655. break;
  11656. case "十二":
  11657. str = "12";
  11658. break;
  11659. }
  11660. return str;
  11661. }
  11662. // 高亮包含指定文字的部分
  11663. void HighlightText(Run run, string targetText, Color color)
  11664. {
  11665. string text = run.Text;
  11666. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11667. if (startIndex >= 0)
  11668. {
  11669. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11670. // 前部分
  11671. if (startIndex > 0)
  11672. {
  11673. Run beforeRun = (Run)run.Clone(true);
  11674. beforeRun.Text = text.Substring(0, startIndex);
  11675. parentParagraph.InsertBefore(beforeRun, run);
  11676. }
  11677. // 匹配部分
  11678. Run matchRun = (Run)run.Clone(true);
  11679. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11680. matchRun.Font.Color = color;
  11681. parentParagraph.InsertBefore(matchRun, run);
  11682. // 后部分
  11683. if (startIndex + targetText.Length < text.Length)
  11684. {
  11685. Run afterRun = (Run)run.Clone(true);
  11686. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11687. parentParagraph.InsertBefore(afterRun, run);
  11688. }
  11689. // 删除原始Run
  11690. run.Remove();
  11691. }
  11692. }
  11693. #endregion
  11694. #endregion
  11695. #region 团组成本
  11696. /// <summary>
  11697. /// 团组成本数据初始化
  11698. /// </summary>
  11699. /// <param name="dto"></param>
  11700. /// <returns></returns>
  11701. [HttpPost]
  11702. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11703. {
  11704. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11705. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11706. WHEN COUNT(*) >= 0 THEN 'True'
  11707. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11708. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11709. ").ToList(); //团组列表
  11710. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11711. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11712. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11713. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11714. if (groupinfoValue != null)
  11715. {
  11716. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11717. var spArr = new string[1] { countryArr };
  11718. if (countryArr.Contains("|"))
  11719. {
  11720. spArr = countryArr.Split("|");
  11721. }
  11722. else if (countryArr.Contains("、"))
  11723. {
  11724. spArr = countryArr.Split("、");
  11725. }
  11726. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11727. {
  11728. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11729. if (dbQueryCountry != null)
  11730. {
  11731. visaCountryInfoArr.Add(dbQueryCountry);
  11732. }
  11733. }
  11734. }
  11735. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11736. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11737. var create = _GroupCostRepository.
  11738. CreateGroupCostByBlackCode(dto.Diid);
  11739. if (groupCost.Count == 0 && create.Code == 0)
  11740. {
  11741. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11742. }
  11743. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11744. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11745. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11746. groupCostMap = groupCostMap.Select(x =>
  11747. {
  11748. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11749. {
  11750. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11751. }
  11752. return x;
  11753. }).ToList();
  11754. //GroupCostParameter.Add(new
  11755. // Grp_GroupCostParameter());
  11756. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11757. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11758. return Ok(JsonView(new
  11759. {
  11760. groupList,
  11761. groupInfo,
  11762. groupChecks,
  11763. groupCost = groupCostMap,
  11764. hotelNumber,
  11765. GroupCostParameter = GroupCostParameterMap,
  11766. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11767. {
  11768. x.VisaCountry,
  11769. x.VisaPrice,
  11770. x.Id,
  11771. }).ToList(),
  11772. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11773. blackCodeIsTrue = create.Code == 0 ? true : false,
  11774. hotelIsTrue = hotelIsTrue,
  11775. }));
  11776. }
  11777. /// <summary>
  11778. /// 团组成本信息保存
  11779. /// </summary>
  11780. /// <param name="dto"></param>
  11781. /// <returns></returns>
  11782. [HttpPost]
  11783. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11784. {
  11785. if (dto.Diid <= 0 || dto.Userid <= 0)
  11786. {
  11787. return Ok(JsonView(false));
  11788. }
  11789. JsonView jw = null;
  11790. bool isTrue = false;
  11791. #region 复制团组成本
  11792. //if (dto.Diid == 2581)
  11793. //{
  11794. // dto.Diid = 2599;
  11795. // dto.CheckBoxs.ForEach(x =>
  11796. // {
  11797. // x.Diid = 2599;
  11798. // });
  11799. // dto.GroupCosts.ForEach(x =>
  11800. // {
  11801. // x.Diid = 2599;
  11802. // });
  11803. // dto.CostTypeHotelNumbers.ForEach(x =>
  11804. // {
  11805. // x.Diid = 2599;
  11806. // });
  11807. // dto.GroupCostParameters.ForEach(x =>
  11808. // {
  11809. // x.DiId = 2599;
  11810. // });
  11811. //}
  11812. #endregion
  11813. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11814. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11815. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11816. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11817. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11818. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11819. try
  11820. {
  11821. _sqlSugar.BeginTran();
  11822. isTrue = await _GroupCostRepository.
  11823. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11824. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11825. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11826. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11827. _sqlSugar.CommitTran();
  11828. jw = JsonView(true, "保存成功!", isTrue);
  11829. }
  11830. catch (Exception)
  11831. {
  11832. _sqlSugar.RollbackTran();
  11833. jw = JsonView(false);
  11834. }
  11835. return Ok(jw);
  11836. }
  11837. /// <summary>
  11838. /// 司兼导数据
  11839. /// </summary>
  11840. /// <param name="dto"></param>
  11841. /// <returns></returns>
  11842. [HttpPost]
  11843. public IActionResult GetCarGuides(CarGuidesDto dto)
  11844. {
  11845. JsonView jw = null;
  11846. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11847. jw = JsonView(true, "获取成功!", Data);
  11848. return Ok(jw);
  11849. }
  11850. /// <summary>
  11851. /// 导游数据
  11852. /// </summary>
  11853. /// <param name="dto"></param>
  11854. /// <returns></returns>
  11855. [HttpPost]
  11856. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11857. {
  11858. JsonView jw = null;
  11859. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11860. // 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
  11861. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11862. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11863. jw = JsonView(true, "获取成功!", Data);
  11864. return Ok(jw);
  11865. }
  11866. /// <summary>
  11867. /// 成本车数据
  11868. /// </summary>
  11869. /// <param name="dto"></param>
  11870. /// <returns></returns>
  11871. [HttpPost]
  11872. public IActionResult GetCarInfo(CarGuidesDto dto)
  11873. {
  11874. JsonView jw = null;
  11875. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11876. jw = JsonView(true, "获取成功!", Data);
  11877. return Ok(jw);
  11878. }
  11879. /// <summary>
  11880. /// 景点数据
  11881. /// </summary>
  11882. /// <param name="dto"></param>
  11883. /// <returns></returns>
  11884. [HttpPost]
  11885. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11886. {
  11887. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11888. return Ok(JsonView(true, "获取成功!", Data));
  11889. }
  11890. /// <summary>
  11891. /// 成本通知
  11892. /// </summary>
  11893. /// <param name="dto"></param>
  11894. /// <returns></returns>
  11895. [HttpPost]
  11896. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11897. {
  11898. if (dto.Diid < 0)
  11899. {
  11900. return Ok(JsonView(false));
  11901. }
  11902. JsonView jw = null;
  11903. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11904. if (GroupCostParameter != null)
  11905. {
  11906. int IsShare = 0;
  11907. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11908. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11909. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11910. string msg = string.Empty;
  11911. if (isTrue)
  11912. {
  11913. if (IsShare == 0)
  11914. {
  11915. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11916. }
  11917. else
  11918. {
  11919. #region 企微通知对应岗位用户
  11920. try
  11921. {
  11922. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11923. }
  11924. catch (Exception ex)
  11925. {
  11926. }
  11927. #endregion
  11928. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11929. }
  11930. jw = JsonView(isTrue, msg, new { IsShare });
  11931. }
  11932. else
  11933. {
  11934. msg = "修改失败!";
  11935. jw = JsonView(isTrue, msg);
  11936. }
  11937. }
  11938. else
  11939. {
  11940. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11941. }
  11942. return Ok(jw);
  11943. }
  11944. /// <summary>
  11945. /// 导出报价单
  11946. /// </summary>
  11947. /// <param name="dto"></param>
  11948. /// <returns></returns>
  11949. [HttpPost]
  11950. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11951. {
  11952. if (dto.Diid == 0)
  11953. {
  11954. return Ok(JsonView(false, "请传递团组id"));
  11955. }
  11956. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11957. if (deleInfo.Code != 0)
  11958. {
  11959. return Ok(JsonView(false, "团组信息查询失败!"));
  11960. }
  11961. var di = deleInfo.Data as DelegationInfoWebView;
  11962. if (di != null)
  11963. {
  11964. di.TeamName = di.TeamName.Replace("|", "、");
  11965. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11966. //文件名
  11967. string strFileName = di.TeamName + "-收款账单.doc";
  11968. //获取模板
  11969. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11970. //载入模板
  11971. Document doc = new Document(tmppath);
  11972. decimal TotalPrice = 0.00M;
  11973. string itemStr = string.Empty;
  11974. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11975. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11976. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11977. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11978. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11979. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11980. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11981. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11982. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11983. foreach (var cost in groupCostType)
  11984. {
  11985. var List = cost.ToList();
  11986. if (cost.Key == "A")
  11987. {
  11988. foreach (var ListItem in List)
  11989. {
  11990. if (ListItem.number > 0)
  11991. {
  11992. if (ListItem.code.Contains("TBR"))
  11993. {
  11994. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11995. }
  11996. else
  11997. {
  11998. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11999. }
  12000. TotalPrice += (ListItem.number * ListItem.price);
  12001. }
  12002. }
  12003. }
  12004. else
  12005. {
  12006. itemStr = itemStr.Insert(0, "A段\r\n");
  12007. itemStr += "B段\r\n";
  12008. foreach (var ListItem in List)
  12009. {
  12010. if (ListItem.number > 0)
  12011. {
  12012. if (ListItem.code.Contains("TBR"))
  12013. {
  12014. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12015. }
  12016. else
  12017. {
  12018. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12019. }
  12020. TotalPrice += (ListItem.number * ListItem.price);
  12021. }
  12022. }
  12023. }
  12024. }
  12025. #region 替换Word模板书签内容
  12026. Dictionary<string, string> marks = new Dictionary<string, string>();
  12027. marks.Add("To", di.ClientUnit);//付款方
  12028. marks.Add("ToTel", di.TellPhone);//付款方电话
  12029. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12030. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12031. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12032. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12033. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12034. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12035. marks.Add("PayItemContent", itemStr);//详细信息
  12036. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12037. #endregion
  12038. ////注
  12039. //if (doc.Range.Bookmarks["Attention"] != null)
  12040. //{
  12041. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12042. // mark.Text = frList[0].Attention;
  12043. //}
  12044. foreach (var item in marks.Keys)
  12045. {
  12046. if (doc.Range.Bookmarks[item] != null)
  12047. {
  12048. Bookmark mark = doc.Range.Bookmarks[item];
  12049. mark.Text = marks[item];
  12050. }
  12051. }
  12052. byte[] bytes = null;
  12053. using (MemoryStream stream = new MemoryStream())
  12054. {
  12055. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12056. bytes = stream.ToArray();
  12057. }
  12058. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12059. return Ok(JsonView(true, "", new
  12060. {
  12061. Data = bytes,
  12062. strFileName,
  12063. }));
  12064. }
  12065. else
  12066. {
  12067. return Ok(JsonView(false, "团组信息不存在!"));
  12068. }
  12069. }
  12070. /// <summary>
  12071. /// 导出团组成本
  12072. /// </summary>
  12073. /// <param name="dto"></param>
  12074. /// <returns></returns>
  12075. [HttpPost]
  12076. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12077. {
  12078. var jw = JsonView(false);
  12079. if (dto.Diid == 0)
  12080. {
  12081. return Ok(JsonView(false, "请传递团组id"));
  12082. }
  12083. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12084. if (deleInfo.Code != 0)
  12085. {
  12086. return Ok(JsonView(false, "团组信息查询失败!"));
  12087. }
  12088. var di = deleInfo.Data as DelegationInfoWebView;
  12089. if (di == null)
  12090. {
  12091. return Ok(JsonView(false, "团组信息查询失败!"));
  12092. }
  12093. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12094. WorkbookDesigner designer = new WorkbookDesigner();
  12095. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12096. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12097. for (int i = 0; i < List_GC.Count; i++)
  12098. {
  12099. GroupCost_Excel gc = new GroupCost_Excel();
  12100. gc.Id = List_GC[i].Id;
  12101. gc.Diid = List_GC[i].Diid.ToString();
  12102. gc.DAY = List_GC[i].DAY;
  12103. string week = "";
  12104. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12105. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12106. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12107. gc.ITIN = List_GC[i].ITIN;
  12108. gc.CarType = List_GC[i].CarType;
  12109. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12110. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12111. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12112. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12113. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12114. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12115. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12116. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12117. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12118. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12119. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12120. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12121. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12122. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12123. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12124. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12125. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12126. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12127. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12128. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12129. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12130. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12131. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12132. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12133. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12134. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12135. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12136. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12137. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12138. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12139. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12140. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12141. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12142. List_GC1.Add(gc);
  12143. }
  12144. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12145. dt.TableName = "TB";
  12146. //报表标题等不用dt的值
  12147. designer.SetDataSource("TeamName", dto.title.TeamName);
  12148. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12149. designer.SetDataSource("Tax", dto.title.Tax);
  12150. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12151. designer.SetDataSource("Currency", dto.title.Currency);
  12152. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12153. designer.SetDataSource("Rate", dto.title.Rate);
  12154. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12155. var Aparams = hotels.Find(x => x.Type == "Default");
  12156. if (Aparams == null)
  12157. {
  12158. return Ok(jw);
  12159. }
  12160. //酒店数量
  12161. var txtSGRNumber = Aparams.SGR.ToString();
  12162. var txtTBRNumber = Aparams.TBR.ToString();
  12163. var txtJSESNumber = Aparams.JSES.ToString();
  12164. var txtSUITENumbe = Aparams.SUITE.ToString();
  12165. if (dto.costType == "B")
  12166. {
  12167. Aparams = hotels.Find(x => x.Type == "A");
  12168. var Bparams = hotels.Find(x => x.Type == "B");
  12169. if (Aparams == null || Bparams == null)
  12170. {
  12171. return Ok(jw);
  12172. }
  12173. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12174. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12175. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12176. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12177. }
  12178. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12179. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12180. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12181. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12182. var ws = designer.Workbook.Worksheets[0];
  12183. int Row = List_GC.Count;
  12184. int startIndex = 11;
  12185. int HideRows = 0;
  12186. List<int> hideRowsList = new List<int>();
  12187. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12188. #region A段left数据
  12189. var left = dto.leftInfo.Find(x => x.Type == "A");
  12190. if (left == null)
  12191. {
  12192. return Ok(jw);
  12193. }
  12194. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12195. if (leftBindData != null)
  12196. {
  12197. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12198. designer.SetDataSource("VisaRS", leftBindData.rs);
  12199. designer.SetDataSource("VisaXS", leftBindData.xs);
  12200. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12201. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12202. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12203. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12204. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12205. }
  12206. else
  12207. {
  12208. hideRowsList.Add(Row + startIndex + HideRows);
  12209. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12210. }
  12211. HideRows += 2;
  12212. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12213. if (leftBindData != null)
  12214. {
  12215. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12216. designer.SetDataSource("BXRS", leftBindData.rs);
  12217. designer.SetDataSource("BXXS", leftBindData.xs);
  12218. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12219. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12220. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12221. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12222. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12223. }
  12224. else
  12225. {
  12226. hideRowsList.Add(Row + startIndex + HideRows);
  12227. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12228. }
  12229. HideRows += 2;
  12230. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12231. if (leftBindData != null)
  12232. {
  12233. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12234. designer.SetDataSource("HSRS", leftBindData.rs);
  12235. designer.SetDataSource("HSXS", leftBindData.xs);
  12236. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12237. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12238. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12239. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12240. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12241. }
  12242. else
  12243. {
  12244. hideRowsList.Add(Row + startIndex + HideRows);
  12245. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12246. }
  12247. HideRows += 2;
  12248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12249. if (leftBindData != null)
  12250. {
  12251. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12252. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12253. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12254. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12255. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12256. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12257. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12258. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12259. }
  12260. else
  12261. {
  12262. hideRowsList.Add(Row + startIndex + HideRows);
  12263. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12264. }
  12265. HideRows += 2;
  12266. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12267. if (leftBindData != null)
  12268. {
  12269. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12270. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12271. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12272. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12273. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12274. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12275. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12276. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12277. }
  12278. else
  12279. {
  12280. hideRowsList.Add(Row + startIndex + HideRows);
  12281. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12282. }
  12283. HideRows += 2;
  12284. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12285. if (leftBindData != null)
  12286. {
  12287. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12288. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12289. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12290. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12291. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12292. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12293. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12294. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12295. }
  12296. else
  12297. {
  12298. hideRowsList.Add(Row + startIndex + HideRows);
  12299. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12300. }
  12301. HideRows += 2;
  12302. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12303. if (leftBindData != null)
  12304. {
  12305. ////TBR
  12306. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12307. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12308. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12309. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12310. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12311. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12312. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12313. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12314. }
  12315. else
  12316. {
  12317. hideRowsList.Add(Row + startIndex + HideRows);
  12318. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12319. }
  12320. HideRows += 2;
  12321. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12322. if (leftBindData != null)
  12323. {
  12324. ////SGR
  12325. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12326. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12327. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12328. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12329. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12330. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12331. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12332. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12333. }
  12334. else
  12335. {
  12336. hideRowsList.Add(Row + startIndex + HideRows);
  12337. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12338. }
  12339. HideRows += 2;
  12340. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12341. if (leftBindData != null)
  12342. {
  12343. ////JS/ES
  12344. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12345. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12346. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12347. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12348. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12349. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12350. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12351. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12352. }
  12353. else
  12354. {
  12355. hideRowsList.Add(Row + startIndex + HideRows);
  12356. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12357. }
  12358. HideRows += 2;
  12359. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12360. if (leftBindData != null)
  12361. {
  12362. ////SUITE
  12363. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12364. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12365. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12366. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12367. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12368. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12369. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12370. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12371. }
  12372. else
  12373. {
  12374. hideRowsList.Add(Row + startIndex + HideRows);
  12375. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12376. }
  12377. HideRows += 2;
  12378. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12379. if (leftBindData != null)
  12380. {
  12381. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12382. designer.SetDataSource("DJRS", leftBindData.rs);
  12383. designer.SetDataSource("DJXS", leftBindData.xs);
  12384. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12385. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12386. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12387. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12388. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12389. }
  12390. else
  12391. {
  12392. hideRowsList.Add(Row + startIndex + HideRows);
  12393. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12394. }
  12395. HideRows += 2;
  12396. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12397. if (leftBindData != null)
  12398. {
  12399. designer.SetDataSource("HCPCB", leftBindData.cb);
  12400. designer.SetDataSource("HCPRS", leftBindData.rs);
  12401. designer.SetDataSource("HCPXS", leftBindData.xs);
  12402. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12403. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12404. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12405. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12406. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12407. }
  12408. else
  12409. {
  12410. hideRowsList.Add(Row + startIndex + HideRows);
  12411. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12412. }
  12413. HideRows += 2;
  12414. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12415. if (leftBindData != null)
  12416. {
  12417. designer.SetDataSource("CPCB", leftBindData.cb);
  12418. designer.SetDataSource("CPRS", leftBindData.rs);
  12419. designer.SetDataSource("CPXS", leftBindData.xs);
  12420. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12421. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12422. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12423. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12424. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12425. }
  12426. else
  12427. {
  12428. hideRowsList.Add(Row + startIndex + HideRows);
  12429. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12430. }
  12431. HideRows += 2;
  12432. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12433. if (leftBindData != null)
  12434. {
  12435. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12436. designer.SetDataSource("GWRS", leftBindData.rs);
  12437. designer.SetDataSource("GWXS", leftBindData.xs);
  12438. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12439. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12440. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12441. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12442. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12443. }
  12444. else
  12445. {
  12446. hideRowsList.Add(Row + startIndex + HideRows);
  12447. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12448. }
  12449. HideRows += 2;
  12450. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12451. if (leftBindData != null)
  12452. {
  12453. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12454. designer.SetDataSource("LYJRS", leftBindData.rs);
  12455. designer.SetDataSource("LYJXS", leftBindData.xs);
  12456. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12457. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12458. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12459. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12460. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12461. }
  12462. else
  12463. {
  12464. hideRowsList.Add(Row + startIndex + HideRows);
  12465. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12466. }
  12467. #endregion
  12468. #region A段Right信息
  12469. var right = dto.rightInfo.Find(x => x.Type == "A");
  12470. if (right == null)
  12471. {
  12472. return Ok(jw);
  12473. }
  12474. HideRows += 4;
  12475. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12476. if (rightBindData != null)
  12477. {
  12478. //经济舱 + 双人间 TBR
  12479. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12480. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12481. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12482. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12483. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12484. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12485. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12486. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12487. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12488. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12489. }
  12490. else
  12491. {
  12492. hideRowsList.Add(Row + startIndex + HideRows);
  12493. }
  12494. HideRows += 2;
  12495. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12496. if (rightBindData != null)
  12497. {
  12498. //经济舱 + 单人间 SGR
  12499. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12500. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12501. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12502. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12503. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12504. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12505. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12506. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12507. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12508. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12509. }
  12510. else
  12511. {
  12512. hideRowsList.Add(Row + startIndex + HideRows);
  12513. }
  12514. HideRows += 2;
  12515. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12516. if (rightBindData != null)
  12517. {
  12518. //公务舱 + 单人间 SGR
  12519. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12520. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12521. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12522. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12523. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12524. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12525. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12526. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12527. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12528. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12529. }
  12530. else
  12531. {
  12532. hideRowsList.Add(Row + startIndex + HideRows);
  12533. }
  12534. HideRows += 2;
  12535. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12536. if (rightBindData != null)
  12537. {
  12538. //公务舱 + 小套房 JSES
  12539. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12540. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12541. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12542. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12543. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12544. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12545. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12546. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12547. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12548. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12549. }
  12550. else
  12551. {
  12552. hideRowsList.Add(Row + startIndex + HideRows);
  12553. }
  12554. HideRows += 2;
  12555. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12556. if (rightBindData != null)
  12557. {
  12558. //公务舱 + 小套房 JSES
  12559. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12560. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12561. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12562. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12563. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12564. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12565. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12566. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12567. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12568. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12569. }
  12570. else
  12571. {
  12572. hideRowsList.Add(Row + startIndex + HideRows);
  12573. }
  12574. HideRows += 2;
  12575. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12576. if (rightBindData != null)
  12577. {
  12578. //经济舱 + 大套房
  12579. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12580. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12581. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12582. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12583. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12584. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12585. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12586. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12587. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12588. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12589. }
  12590. else
  12591. {
  12592. hideRowsList.Add(Row + startIndex + HideRows);
  12593. }
  12594. HideRows += 2;
  12595. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12596. if (rightBindData != null)
  12597. {
  12598. //头等舱 + 小套房 JSES
  12599. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12600. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12601. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12602. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12603. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12604. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12605. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12606. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12607. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12608. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12609. }
  12610. else
  12611. {
  12612. hideRowsList.Add(Row + startIndex + HideRows);
  12613. }
  12614. HideRows += 2;
  12615. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12616. if (rightBindData != null)
  12617. {
  12618. //头等舱 + 大套房
  12619. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12620. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12621. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12622. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12623. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12624. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12625. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12626. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12627. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12628. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12629. }
  12630. else
  12631. {
  12632. hideRowsList.Add(Row + startIndex + HideRows);
  12633. }
  12634. #endregion
  12635. #region B段标题清空
  12636. designer.SetDataSource("CostBDRCB", "");
  12637. designer.SetDataSource("CostBRS", "");
  12638. designer.SetDataSource("CostBXS", "");
  12639. designer.SetDataSource("CostBZCB", "");
  12640. designer.SetDataSource("CostBDRBJ", "");
  12641. designer.SetDataSource("CostBZBJ", "");
  12642. designer.SetDataSource("CostBDRLR", "");
  12643. designer.SetDataSource("CostBZLR", "");
  12644. designer.SetDataSource("CostBDRCBOM", "");
  12645. designer.SetDataSource("CostBRSOM", "");
  12646. designer.SetDataSource("CostBZCBOM", "");
  12647. designer.SetDataSource("CostBDRBJOM", "");
  12648. designer.SetDataSource("CostBZBJOM", "");
  12649. designer.SetDataSource("CostBDRLROM", "");
  12650. designer.SetDataSource("CostBZLROM", "");
  12651. #endregion
  12652. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12653. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12654. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12655. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12656. designer.SetDataSource("DJName", "地接(CNY)");
  12657. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12658. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12659. designer.SetDataSource("GWName", "公务(CNY)");
  12660. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12661. designer.SetDataSource("LYJName", "零用金(CNY)");
  12662. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12663. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12664. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12665. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12666. designer.SetDataSource("BXName", "保险(CNY)");
  12667. designer.SetDataSource("VisaName", "签证(CNY)");
  12668. #region B段基本数据
  12669. if (dto.costType == "B")
  12670. {
  12671. left = dto.leftInfo.Find(x => x.Type == "B");
  12672. if (left == null)
  12673. {
  12674. return Ok(jw);
  12675. }
  12676. #region B段left数据
  12677. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12678. if (leftBindData != null)
  12679. {
  12680. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12681. designer.SetDataSource("BHSRS", leftBindData.rs);
  12682. designer.SetDataSource("BHSXS", leftBindData.xs);
  12683. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12684. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12685. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12686. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12687. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12688. }
  12689. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12690. if (leftBindData != null)
  12691. {
  12692. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12693. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12694. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12695. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12696. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12697. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12698. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12699. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12700. }
  12701. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12702. if (leftBindData != null)
  12703. {
  12704. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12705. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12706. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12707. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12708. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12709. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12710. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12711. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12712. }
  12713. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12714. if (leftBindData != null)
  12715. {
  12716. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12717. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12718. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12719. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12720. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12721. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12722. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12723. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12724. }
  12725. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12726. if (leftBindData != null)
  12727. {
  12728. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12729. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12730. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12731. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12732. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12733. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12734. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12735. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12736. }
  12737. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12738. if (leftBindData != null)
  12739. {
  12740. designer.SetDataSource("BCPCB", leftBindData.cb);
  12741. designer.SetDataSource("BCPRS", leftBindData.rs);
  12742. designer.SetDataSource("BCPXS", leftBindData.xs);
  12743. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12744. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12745. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12746. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12747. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12748. }
  12749. //TBR
  12750. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12751. if (leftBindData != null)
  12752. {
  12753. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12754. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12755. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12756. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12757. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12758. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12759. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12760. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12761. }
  12762. //SGR
  12763. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12764. if (leftBindData != null)
  12765. {
  12766. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12767. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12768. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12769. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12770. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12771. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12772. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12773. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12774. }
  12775. //JS/ES
  12776. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12777. if (leftBindData != null)
  12778. {
  12779. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12780. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12781. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12782. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12783. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12784. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12785. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12786. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12787. }
  12788. //SUITE
  12789. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12790. if (leftBindData != null)
  12791. {
  12792. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12793. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12794. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12795. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12796. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12797. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12798. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12799. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12800. }
  12801. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12802. if (leftBindData != null)
  12803. {
  12804. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12805. designer.SetDataSource("BDJRS", leftBindData.rs);
  12806. designer.SetDataSource("BDJXS", leftBindData.xs);
  12807. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12808. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12809. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12811. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12812. }
  12813. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12814. if (leftBindData != null)
  12815. {
  12816. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12817. designer.SetDataSource("BGWRS", leftBindData.rs);
  12818. designer.SetDataSource("BGWXS", leftBindData.xs);
  12819. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12820. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12821. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12822. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12823. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12824. }
  12825. #region 优化方案
  12826. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12827. //excelBind.Add("零用金", new {
  12828. //cb="",
  12829. //rs="",
  12830. //xs ="",
  12831. //zcb = "",
  12832. //});
  12833. #endregion
  12834. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12835. if (leftBindData != null)
  12836. {
  12837. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12838. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12839. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12840. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12841. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12842. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12843. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12844. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12845. }
  12846. #endregion
  12847. #region B段Right信息
  12848. right = dto.rightInfo.Find(x => x.Type == "B");
  12849. if (right == null)
  12850. {
  12851. return Ok(jw);
  12852. }
  12853. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12854. if (rightBindData != null)
  12855. {
  12856. //经济舱 + 双人间 TBR
  12857. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12858. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12859. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12860. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12861. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12862. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12863. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12864. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12865. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12866. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12867. }
  12868. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12869. if (rightBindData != null)
  12870. {
  12871. //经济舱 + 单人间 SGR
  12872. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12873. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12874. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12875. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12876. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12877. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12878. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12879. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12880. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12881. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12882. }
  12883. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12884. if (rightBindData != null)
  12885. {
  12886. //公务舱 + 单人间 SGR
  12887. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12888. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12889. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12890. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12891. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12892. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12893. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12894. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12895. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12896. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12897. }
  12898. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12899. if (rightBindData != null)
  12900. {
  12901. //公务舱 + 小套房 JSES
  12902. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12903. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12904. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12905. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12906. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12907. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12908. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12909. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12910. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12911. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12912. }
  12913. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12914. if (rightBindData != null)
  12915. {
  12916. //公务舱 + 小套房 JSES
  12917. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12918. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12919. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12920. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12921. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12922. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12923. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12924. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12925. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12926. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12927. }
  12928. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12929. if (rightBindData != null)
  12930. {
  12931. //经济舱 + 大套房
  12932. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12933. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12934. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12935. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12936. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12937. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12938. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12939. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12940. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12941. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12942. }
  12943. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12944. if (rightBindData != null)
  12945. {
  12946. //头等舱 + 小套房 JSES
  12947. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12948. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12949. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12950. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12951. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12952. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12953. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12954. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12955. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12956. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12957. }
  12958. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12959. if (rightBindData != null)
  12960. {
  12961. //头等舱 + 大套房
  12962. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12963. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12964. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12965. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12966. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12967. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12968. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12969. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12970. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12971. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12972. }
  12973. #endregion
  12974. #region 标题
  12975. designer.SetDataSource("CostBDRCB", "单人成本");
  12976. designer.SetDataSource("CostBRS", "人数");
  12977. designer.SetDataSource("CostBXS", "系数");
  12978. designer.SetDataSource("CostBZCB", "总成本");
  12979. designer.SetDataSource("CostBDRBJ", "单人报价");
  12980. designer.SetDataSource("CostBZBJ", "总报价");
  12981. designer.SetDataSource("CostBDRLR", "单人利润");
  12982. designer.SetDataSource("CostBZLR", "总利润");
  12983. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12984. designer.SetDataSource("CostBRSOM", "人数");
  12985. designer.SetDataSource("CostBZCBOM", "总成本");
  12986. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12987. designer.SetDataSource("CostBZBJOM", "总报价");
  12988. designer.SetDataSource("CostBDRLROM", "单人利润");
  12989. designer.SetDataSource("CostBZLROM", "总利润");
  12990. #endregion
  12991. }
  12992. #endregion
  12993. designer.SetDataSource("TzZCB2", TzZCB2);
  12994. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12995. designer.SetDataSource("TzZLR2", TzZLR2);
  12996. string[] dataSourceKeys = new string[]
  12997. {
  12998. "VF",
  12999. "TGS",
  13000. "TGOF",
  13001. "TGM",
  13002. "TGA",
  13003. "TGTF",
  13004. "TGEF",
  13005. "CFM",
  13006. "CFOF",
  13007. "B",
  13008. "L",
  13009. "D",
  13010. "TBR",
  13011. "SGR",
  13012. "JSES",
  13013. "Suite",
  13014. "TV",
  13015. "1L",
  13016. "IF",
  13017. "EF",
  13018. "BRF",
  13019. "TE",
  13020. "TGT",
  13021. "DRVT",
  13022. "PC",
  13023. "TLF",
  13024. "ECT"
  13025. };
  13026. foreach (var item in dataSourceKeys)
  13027. {
  13028. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13029. if (find != null)
  13030. {
  13031. designer.SetDataSource(item, find.text);
  13032. }
  13033. else
  13034. {
  13035. designer.SetDataSource(item, 0);
  13036. }
  13037. }
  13038. designer.SetDataSource(dt);
  13039. //根据数据源处理生成报表内容
  13040. designer.Process();
  13041. designer.Workbook.Worksheets[0].Name = "清单";
  13042. Worksheet sheet = designer.Workbook.Worksheets[0];
  13043. foreach (var Rowindex in hideRowsList)
  13044. {
  13045. ws.Cells.HideRows(Rowindex, 2);
  13046. }
  13047. byte[] bytes = null;
  13048. string strFileName = di.TeamName + "-团组-成本.xls";
  13049. using (MemoryStream stream = new MemoryStream())
  13050. {
  13051. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13052. bytes = stream.ToArray();
  13053. }
  13054. return Ok(JsonView(true, "", new
  13055. {
  13056. Data = bytes,
  13057. strFileName,
  13058. }));
  13059. }
  13060. /// <summary>
  13061. /// 导出客户报表
  13062. /// </summary>
  13063. /// <returns></returns>
  13064. [HttpPost]
  13065. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13066. {
  13067. var jw = JsonView(false);
  13068. if (dto.Diid == 0)
  13069. {
  13070. return Ok(JsonView(false, "请传递团组id"));
  13071. }
  13072. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13073. if (deleInfo.Code != 0)
  13074. {
  13075. return Ok(JsonView(false, "团组信息查询失败!"));
  13076. }
  13077. var di = deleInfo.Data as DelegationInfoWebView;
  13078. if (di == null)
  13079. {
  13080. return Ok(JsonView(false, "团组信息查询失败!"));
  13081. }
  13082. //文件名
  13083. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13084. //获取模板
  13085. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13086. //载入模板
  13087. Document doc = new Document(tmppath);
  13088. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13089. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13090. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13091. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13092. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13093. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13094. if (AParameter == null)
  13095. {
  13096. return Ok(JsonView(false, "系数不存在!"));
  13097. }
  13098. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13099. , TzAirDesc, TzZCost;
  13100. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13101. = TzAirDesc = TzZCost = string.Empty;
  13102. TzNumber = AParameter.CostTypenumber.ToString();
  13103. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13104. CarGuides1 = dto.CarGuides1;
  13105. Meal = dto.Meal;
  13106. SubsidizedMeals = dto.SubsidizedMeals;
  13107. NightRepair = dto.NightRepair;
  13108. AttractionsTickets = dto.AttractionsTickets;
  13109. MiscellaneousFees = dto.MiscellaneousFees;
  13110. ATip = dto.ATip;
  13111. TzHotelDesc = "";
  13112. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13113. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13114. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13115. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13116. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13117. TzAirDesc = "";
  13118. TzZCost = dto.TzZCost;
  13119. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13120. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13121. var index = 1;
  13122. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13123. foreach (var item in TzHotelDescArr)
  13124. {
  13125. if (AinfoArr != null)
  13126. {
  13127. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13128. if (Ainfo != null)
  13129. {
  13130. if (int.Parse(Ainfo.rs) <= 0)
  13131. {
  13132. continue;
  13133. }
  13134. var hotelText = string.Empty;
  13135. switch (item)
  13136. {
  13137. case "SGR":
  13138. hotelText = "单人间";
  13139. break;
  13140. case "JSES":
  13141. hotelText = "小套房";
  13142. break;
  13143. case "SUITE":
  13144. hotelText = "套房";
  13145. break;
  13146. case "TBR":
  13147. hotelText = "双人间";
  13148. break;
  13149. }
  13150. if (item != "TBR")
  13151. {
  13152. 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";
  13153. }
  13154. else
  13155. {
  13156. 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";
  13157. }
  13158. index++;
  13159. }
  13160. }
  13161. }
  13162. index = 1;
  13163. foreach (var item in TzAirDescArr)
  13164. {
  13165. if (AinfoArr != null)
  13166. {
  13167. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13168. if (Ainfo != null)
  13169. {
  13170. if (int.Parse(Ainfo.rs) <= 0)
  13171. {
  13172. continue;
  13173. }
  13174. 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";
  13175. index++;
  13176. }
  13177. }
  13178. }
  13179. if (dto.costType == "B")
  13180. {
  13181. if (BParameter == null)
  13182. {
  13183. return Ok(JsonView(false, "B段系数不存在!"));
  13184. }
  13185. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13186. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13187. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13188. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13189. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13190. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13191. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13192. foreach (var item in TzHotelDescArr)
  13193. {
  13194. if (AinfoArr != null)
  13195. {
  13196. TzHotelDesc += "B段信息 \r\n";
  13197. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13198. if (Ainfo != null)
  13199. {
  13200. if (int.Parse(Ainfo.rs) <= 0)
  13201. {
  13202. continue;
  13203. }
  13204. var hotelText = string.Empty;
  13205. switch (item)
  13206. {
  13207. case "SGR":
  13208. hotelText = "单人间";
  13209. break;
  13210. case "JSES":
  13211. hotelText = "小套房";
  13212. break;
  13213. case "SUITE":
  13214. hotelText = "套房";
  13215. break;
  13216. case "TBR":
  13217. hotelText = "双人间";
  13218. break;
  13219. }
  13220. if (item != "TBR")
  13221. {
  13222. 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";
  13223. }
  13224. else
  13225. {
  13226. 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";
  13227. }
  13228. index++;
  13229. }
  13230. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13231. }
  13232. }
  13233. index = 1;
  13234. foreach (var item in TzAirDescArr)
  13235. {
  13236. if (AinfoArr != null)
  13237. {
  13238. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13239. if (Ainfo != null)
  13240. {
  13241. if (int.Parse(Ainfo.rs) <= 0)
  13242. {
  13243. continue;
  13244. }
  13245. 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";
  13246. index++;
  13247. }
  13248. }
  13249. }
  13250. }
  13251. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13252. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13253. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13254. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13255. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13256. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13257. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13258. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13259. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13260. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13261. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13262. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13263. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13264. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13265. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13266. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13267. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13268. DickeyValue.Add("TzZCost", TzZCost);
  13269. foreach (var key in DickeyValue.Keys)
  13270. {
  13271. if (doc.Range.Bookmarks[key] != null)
  13272. {
  13273. Bookmark mark = doc.Range.Bookmarks[key];
  13274. mark.Text = DickeyValue[key];
  13275. }
  13276. }
  13277. byte[] bytes = null;
  13278. string strFileName = di.TeamName + "-客户报价.doc";
  13279. using (MemoryStream stream = new MemoryStream())
  13280. {
  13281. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13282. bytes = stream.ToArray();
  13283. }
  13284. return Ok(JsonView(true, "", new
  13285. {
  13286. Data = bytes,
  13287. strFileName,
  13288. }));
  13289. }
  13290. /// <summary>
  13291. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13292. /// </summary>
  13293. /// <param name="dto"></param>
  13294. /// <returns></returns>
  13295. [HttpPost]
  13296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13297. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13298. {
  13299. try
  13300. {
  13301. #region 参数验证
  13302. if (dto.DiId < 0)
  13303. {
  13304. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13305. }
  13306. List<int> cTableIds = new List<int>() {
  13307. 76 ,//酒店预订
  13308. 77 ,//行程
  13309. 79 ,//车/导游地接
  13310. 80 ,//签证
  13311. 81 ,//邀请/公务活
  13312. 82 ,//团组客户保险
  13313. 85 ,//机票预订
  13314. 98 ,//其他款项
  13315. 285 ,//收款退还
  13316. 751 ,//酒店早餐
  13317. 1015 // 超支费用
  13318. };
  13319. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13320. {
  13321. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13322. }
  13323. #endregion
  13324. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13325. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13326. if (_GroupCostParameters.Count <= 0)
  13327. {
  13328. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13329. }
  13330. if (_GroupCostParameters[0].IsShare == 0)
  13331. {
  13332. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13333. }
  13334. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13335. //处理date为空问题
  13336. if (_GroupCosts.Count > 0)
  13337. {
  13338. for (int i = 0; i < _GroupCosts.Count; i++)
  13339. {
  13340. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13341. {
  13342. if (i > 0)
  13343. {
  13344. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13345. }
  13346. }
  13347. }
  13348. }
  13349. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13350. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13351. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13352. string currCode = "";
  13353. #region currCode 验证
  13354. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13355. if (isInt)
  13356. {
  13357. var currData = currDatas.Find(it => it.Id == intCurrency);
  13358. if (currData != null)
  13359. {
  13360. currCode = currData.Name;
  13361. }
  13362. }
  13363. else
  13364. {
  13365. currCode = _GroupCostParameters[0].Currency.Trim();
  13366. }
  13367. #endregion
  13368. //op,酒店单段模式存储
  13369. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13370. {
  13371. CurrencyCode = currCode,
  13372. Rate = _GroupCostParameters[0].Rate,
  13373. CostType = _GroupCostParameters[0].CostType,
  13374. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13375. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13376. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13377. };
  13378. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13379. if (_GroupCostParameters.Count == 2)
  13380. {
  13381. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13382. }
  13383. foreach (var item in _GroupCostParameters)
  13384. {
  13385. decimal _rate = 1;
  13386. decimal _rate1 = item.Rate;
  13387. decimal _scale = 1;
  13388. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13389. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13390. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13391. //if (userInfo != null)
  13392. //{
  13393. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13394. // {
  13395. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13396. // {
  13397. // _scale = 1.00M;
  13398. // }
  13399. // }
  13400. //}
  13401. #endregion
  13402. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13403. {
  13404. CurrencyCode = currCode,
  13405. Rate = _rate1,
  13406. CostType = item.CostType,
  13407. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13408. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13409. CostTypeNumber = item.CostTypenumber
  13410. };
  13411. if (_GroupCostParameters.Count > 1)
  13412. {
  13413. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13414. }
  13415. else
  13416. {
  13417. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13418. }
  13419. if (dto.CTable == 79)//
  13420. {
  13421. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13422. modulePromptInfo.TotalCost = item.DJCB;
  13423. }
  13424. List<string> costTypes = new List<string>() { "A", "B" };
  13425. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13426. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13427. if (_GroupCostsDuplicates.Count() == 1)
  13428. {
  13429. _GroupCostsTypeData = _GroupCosts;
  13430. }
  13431. else
  13432. {
  13433. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13434. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13435. }
  13436. /*
  13437. * 76 酒店预订
  13438. * 77 行程
  13439. * 79 车/导游地接
  13440. * 80 签证
  13441. * 81 邀请/公务活动
  13442. * 82 团组客户保险
  13443. * 85 机票预订
  13444. * 98 其他款项
  13445. * 285 收款退还
  13446. * 751 酒店早餐
  13447. * 1015 超支费用
  13448. */
  13449. switch (dto.CTable)
  13450. {
  13451. case 76: // 酒店预订
  13452. _ModuleSubPromptInfo.AddRange(
  13453. _GroupCostsTypeData.Select(it => new
  13454. {
  13455. it.DAY,
  13456. it.Date,
  13457. it.ACCON,
  13458. it.ITIN,
  13459. it.SGR,
  13460. it.TBR,
  13461. it.JS_ES,
  13462. it.Suite
  13463. })
  13464. );
  13465. break;
  13466. case 79: // 车/导游地接
  13467. _ModuleSubPromptInfo.AddRange(
  13468. _GroupCostsTypeData.Select(it => new
  13469. {
  13470. Date = it.Date, //日期
  13471. CarFee = it.CarCost * _rate * _scale, //车费用
  13472. CarType = it.CarType, //车型
  13473. DriverFee = it.CFS * _rate * _scale, //司机工资
  13474. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13475. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13476. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13477. GuideFee = it.TGS * _rate * _scale, //导游费用
  13478. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13479. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13480. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13481. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13482. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13483. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13484. Breakfast = it.B * _rate * _scale, //早餐费
  13485. Lunch = it.L * _rate * _scale, //午餐费
  13486. Dinner = it.D * _rate * _scale, //晚餐费
  13487. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13488. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13489. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13490. TicketFee = it.EF * _rate * _scale, //门票费
  13491. TicketRemark = it.EFR, //门票费描述
  13492. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13493. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13494. SpentCash = it.PC * _rate * _scale, //零用金
  13495. LeadersFee = it.TLF * _rate * _scale, //领队费
  13496. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13497. })
  13498. );
  13499. break;
  13500. case 85: // 机票
  13501. List<dynamic> datas = new List<dynamic>();
  13502. datas.Add(
  13503. new
  13504. {
  13505. AirType = "经济舱",
  13506. AirNum = item.JJCRS,
  13507. AirDRCB = item.JJCCB,
  13508. AirZCB = (item.JJCRS * item.JJCCB)
  13509. }
  13510. );
  13511. datas.Add(
  13512. new
  13513. {
  13514. AirType = "公务舱",
  13515. AirNum = item.GWCRS,
  13516. AirDRCB = item.GWCCB,
  13517. AirZCB = (item.GWCRS * item.GWCCB)
  13518. }
  13519. );
  13520. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13521. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13522. modulePromptInfo.Data = new
  13523. {
  13524. airFeeData = datas,
  13525. airInitData = initDatas
  13526. };
  13527. _ModulePromptInfos.Add(modulePromptInfo);
  13528. break;
  13529. default:
  13530. break;
  13531. }
  13532. }
  13533. if (dto.CTable != 85)
  13534. {
  13535. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13536. _ModulePromptInfos.Add(_ModulePromptInfo);
  13537. }
  13538. _view.ModulePromptInfos = _ModulePromptInfos;
  13539. return Ok(JsonView(true, "操作成功!", _view));
  13540. }
  13541. catch (Exception ex)
  13542. {
  13543. return Ok(JsonView(false, ex.Message));
  13544. }
  13545. }
  13546. /// <summary>
  13547. /// 根据黑屏代码重新生成行程
  13548. /// </summary>
  13549. /// <param name="dto"></param>
  13550. /// <returns></returns>
  13551. [HttpPost]
  13552. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13553. {
  13554. var jw = JsonView(false);
  13555. var Create = _GroupCostRepository.
  13556. CreateGroupCostByBlackCode(dto.Diid);
  13557. jw.Msg = Create.Msg;
  13558. if (Create.Code == 0)
  13559. {
  13560. jw.Code = 200;
  13561. jw.Data = new
  13562. {
  13563. groupCost = Create.Data,
  13564. blackCodeIsTrue = true
  13565. };
  13566. }
  13567. else
  13568. {
  13569. jw.Code = 400;
  13570. jw.Data = new
  13571. {
  13572. groupCost = Create.Data,
  13573. blackCodeIsTrue = false,
  13574. };
  13575. }
  13576. return Ok(jw);
  13577. }
  13578. /// <summary>
  13579. /// 成本获取OP历史车费用
  13580. /// </summary>
  13581. /// <param name="dto"></param>
  13582. /// <returns></returns>
  13583. [HttpPost]
  13584. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13585. {
  13586. var jw = JsonView(false);
  13587. try
  13588. {
  13589. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13590. //获取现有所有车的数据
  13591. if (!dto.Param.IsNullOrWhiteSpace())
  13592. {
  13593. string sql = $@"
  13594. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13595. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13596. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13597. 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
  13598. AND gctggr.ServiceEndTime is not NULL
  13599. ORDER by gctggrc.id DESC
  13600. ";
  13601. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13602. var numeberResult = await Task.Run(() =>
  13603. {
  13604. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13605. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13606. return numberArr;
  13607. });
  13608. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13609. foreach (var item in numeberResult)
  13610. {
  13611. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13612. {
  13613. Country = "数据异常!",
  13614. City = string.Empty,
  13615. };
  13616. item.Area = find.Country + " " + find.City;
  13617. }
  13618. dbResult.AddRange(numeberResult);
  13619. if (dto.Param.Contains("、"))
  13620. {
  13621. var sp = dto.Param.Split("、");
  13622. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13623. .Where(x =>
  13624. {
  13625. return System.Array.Exists(sp, e =>
  13626. {
  13627. bool where = false;
  13628. if (x.Area != null)
  13629. {
  13630. where = x.Area.Contains(e);
  13631. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13632. {
  13633. return false;
  13634. }
  13635. }
  13636. if (x.PriceName != null && !where)
  13637. {
  13638. where = x.PriceName.Contains(e);
  13639. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13640. {
  13641. return false;
  13642. }
  13643. }
  13644. return where;
  13645. });
  13646. }).ToList();
  13647. }
  13648. else
  13649. {
  13650. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13651. .Where(x =>
  13652. {
  13653. bool where = false;
  13654. if (x.Area != null)
  13655. {
  13656. where = x.Area.Contains(dto.Param);
  13657. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13658. {
  13659. return false;
  13660. }
  13661. }
  13662. if (x.PriceName != null && !where)
  13663. {
  13664. where = x.PriceName.Contains(dto.Param);
  13665. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13666. {
  13667. return false;
  13668. }
  13669. }
  13670. return where;
  13671. }
  13672. )
  13673. .ToList();
  13674. }
  13675. }
  13676. var view = dbResult.Select(x =>
  13677. {
  13678. decimal dp = 0.00M;
  13679. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13680. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13681. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13682. {
  13683. if (startB && endB)
  13684. {
  13685. var timesp = endD.Subtract(startD);
  13686. if ((timesp.Days + 1) != 0)
  13687. {
  13688. dp = x.Price / (timesp.Days + 1);
  13689. }
  13690. }
  13691. }
  13692. else
  13693. {
  13694. dp = x.Price;
  13695. }
  13696. return new
  13697. {
  13698. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13699. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13700. x.Area,
  13701. x.id,
  13702. price = x.Price.ToString("F2"),
  13703. x.PriceName,
  13704. x.PriceContent,
  13705. x.TeamName,
  13706. x.DatePrice,
  13707. dayPrice = dp.ToString("F2"),
  13708. };
  13709. }).OrderByDescending(x => x.id).ToList();
  13710. jw = JsonView(true, "获取成功!", view);
  13711. }
  13712. catch (Exception e)
  13713. {
  13714. jw = JsonView(false, e.Message);
  13715. }
  13716. return Ok(jw);
  13717. }
  13718. #endregion
  13719. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13720. /// <summary>
  13721. /// 酒店预订
  13722. /// 酒店费用列表 根据团组Id查询
  13723. /// </summary>
  13724. /// <param name="_dto"></param>
  13725. /// <returns></returns>
  13726. [HttpPost]
  13727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13728. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13729. {
  13730. #region 参数验证
  13731. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13732. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13733. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13734. #region 团组操作权限验证 76 酒店预定模块
  13735. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13736. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13737. #endregion
  13738. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13739. #region 页面操作权限验证
  13740. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13741. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13742. #endregion
  13743. #endregion
  13744. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13745. }
  13746. /// <summary>
  13747. /// 酒店预订
  13748. /// 基础数据
  13749. /// </summary>
  13750. /// <param name="_dto"></param>
  13751. /// <returns></returns>
  13752. [HttpPost]
  13753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13754. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13755. {
  13756. #region 参数验证
  13757. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13758. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13759. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13760. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13761. #region 页面操作权限验证
  13762. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13763. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13764. #endregion
  13765. #region 团组操作权限验证 76 酒店预定模块
  13766. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13767. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13768. #endregion
  13769. #endregion
  13770. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13771. }
  13772. /// <summary>
  13773. /// 酒店预订
  13774. /// 创建 入住卷号码
  13775. /// </summary>
  13776. /// <param name="_dto"></param>
  13777. /// <returns></returns>
  13778. [HttpPost]
  13779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13780. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13781. {
  13782. #region 参数验证
  13783. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13784. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13785. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13786. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13787. #region 页面操作权限验证
  13788. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13789. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13790. #endregion
  13791. #region 团组操作权限验证 76 酒店预定模块
  13792. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13793. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13794. #endregion
  13795. #endregion
  13796. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13797. if (data.Code != 0)
  13798. {
  13799. return Ok(JsonView(false, data.Msg));
  13800. }
  13801. return Ok(JsonView(true, data.Msg, data.Data));
  13802. }
  13803. /// <summary>
  13804. /// 酒店预订
  13805. /// 详情
  13806. /// </summary>
  13807. /// <param name="_dto"></param>
  13808. /// <returns></returns>
  13809. [HttpPost]
  13810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13811. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13812. {
  13813. #region 参数验证
  13814. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13815. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13816. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13817. #region 团组操作权限验证 76 酒店预定模块
  13818. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13819. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13820. #endregion
  13821. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13822. #region 页面操作权限验证
  13823. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13824. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13825. #endregion
  13826. #endregion
  13827. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13828. }
  13829. /// <summary>
  13830. /// 酒店预订
  13831. /// Add Or Edit
  13832. /// </summary>
  13833. /// <param name="_dto"></param>
  13834. /// <returns></returns>
  13835. [HttpPost]
  13836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13837. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13838. {
  13839. #region 参数验证
  13840. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13841. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13842. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13843. #region 团组操作权限验证 76 酒店预定模块
  13844. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13845. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13846. #endregion
  13847. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13848. #region 页面操作权限验证
  13849. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13850. if (_dto.Id == 0) // Add
  13851. {
  13852. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13853. }
  13854. else if (_dto.Id > 1) // Edit
  13855. {
  13856. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13857. }
  13858. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13859. #endregion
  13860. #endregion
  13861. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13862. if (_view.Code != 200)
  13863. {
  13864. return Ok(_view);
  13865. }
  13866. #region 成本无酒店价格数据进入超支
  13867. _sqlSugar.BeginTran();
  13868. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13869. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13870. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13871. for (int i = 0; i < groupCost.Count; i++)
  13872. {
  13873. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13874. {
  13875. groupCost[i].Date = groupCost[i - 1].Date;
  13876. }
  13877. }
  13878. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13879. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13880. List<Fin_GroupExtraCostDto_OP>();
  13881. if (start_Bool && end_Bool)
  13882. {
  13883. while (start_Time < end_Time)
  13884. {
  13885. foreach (var item in groupCost_Grp)
  13886. {
  13887. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13888. {
  13889. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13890. {
  13891. extraCostList.Add(new
  13892. Fin_GroupExtraCostDto_OP
  13893. {
  13894. Area = _dto.AreaId,
  13895. coefficient = 1.5M,
  13896. createUser = _dto.UserId,
  13897. currency = _dto.CardPriceCurrency,
  13898. diId = _dto.DiId,
  13899. ManagerConfirm = 0,
  13900. SupervisorConfirm = 0,
  13901. SYsupervisorConfirm = 0,
  13902. editType = 1,
  13903. PortType = 1,
  13904. price = _dto.CardPrice,
  13905. PriceCount = 1,
  13906. priceType = 1027,
  13907. priceDetailType = 1044,
  13908. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13909. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13910. });
  13911. }
  13912. }
  13913. }
  13914. start_Time = start_Time.AddDays(1);
  13915. }
  13916. }
  13917. if (extraCostList.Any())
  13918. {
  13919. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13920. }
  13921. _sqlSugar.CommitTran();
  13922. #endregion
  13923. #region 应用推送
  13924. try
  13925. {
  13926. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13927. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13928. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13929. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13930. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13931. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13932. var diId = _dto.DiId;
  13933. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13934. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13935. #region 操作记录
  13936. var opInfo = new Crm_TableOperationRecord()
  13937. {
  13938. TableName = "Grp_HotelReservations",
  13939. PortType = _dto.PortType,
  13940. DataId = hotelId,
  13941. CreateUserId = _dto.UserId
  13942. };
  13943. //var opStatus = OperationEnum.NoOperation;
  13944. if (_dto.Id < 1) //添加操作
  13945. {
  13946. opInfo.OperationItem = OperationEnum.Add;
  13947. }
  13948. else if (_dto.Id > 0)
  13949. {
  13950. opInfo.OperationItem = OperationEnum.Edit;
  13951. }
  13952. string opRemark = string.Empty;
  13953. if (ccpInfo != null)
  13954. {
  13955. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13956. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13957. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13958. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13959. }
  13960. opInfo.Remark = opRemark;
  13961. await _tableorRep.AddAsync(opInfo);
  13962. #endregion
  13963. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13964. //2024-10-21 新增LZ UID
  13965. var userIds = new List<int>() { 21 };
  13966. string title = $"费用审核";
  13967. string content = "";
  13968. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13969. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13970. try
  13971. {
  13972. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13973. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13974. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13975. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13976. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13977. }
  13978. catch (Exception ex)
  13979. {
  13980. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13981. }
  13982. }
  13983. catch (Exception ex)
  13984. {
  13985. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13986. }
  13987. try
  13988. {
  13989. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13990. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13991. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13992. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13993. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13994. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13995. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13996. //自动审核
  13997. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13998. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13999. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14000. //2024-10-21 新增LZ UID
  14001. var userIds = new List<int>() { 21 };
  14002. string title = $"系统通知";
  14003. var diId = _dto.DiId;
  14004. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14005. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14006. string content = "";
  14007. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14008. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14009. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14010. }
  14011. catch (Exception ex)
  14012. {
  14013. }
  14014. #endregion
  14015. return Ok(_view);
  14016. }
  14017. /// <summary>
  14018. /// 酒店自动审核测试
  14019. /// Add Or Edit
  14020. /// </summary>
  14021. /// <param name="diid"></param>
  14022. /// <param name="dataId"></param>
  14023. /// <returns></returns>
  14024. [HttpPost]
  14025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14026. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14027. {
  14028. #region 应用推送
  14029. try
  14030. {
  14031. //自动审核
  14032. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14033. }
  14034. catch (Exception ex)
  14035. {
  14036. return Ok(JsonView(false, "操作失败"));
  14037. }
  14038. #endregion
  14039. return Ok(JsonView(false, "操作成功"));
  14040. }
  14041. /// <summary>
  14042. /// 酒店预订
  14043. /// Del
  14044. /// </summary>
  14045. /// <param name="_dto"></param>
  14046. /// <returns></returns>
  14047. [HttpPost]
  14048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14049. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14050. {
  14051. #region 参数验证
  14052. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14053. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14054. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14055. #region 团组操作权限验证 76 酒店预定模块
  14056. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14057. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14058. #endregion
  14059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14060. #region 页面操作权限验证
  14061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14062. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14063. #endregion
  14064. #endregion
  14065. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14066. #region 操作记录
  14067. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14068. {
  14069. TableName = "Grp_HotelReservations",
  14070. PortType = _dto.PortType,
  14071. OperationItem = OperationEnum.Del,
  14072. DataId = _dto.Id,
  14073. CreateUserId = _dto.UserId
  14074. });
  14075. #endregion
  14076. return Ok(data);
  14077. }
  14078. /// <summary>
  14079. /// 酒店预订
  14080. /// 生成VOUCHER
  14081. /// 2024.05.06 之前版本
  14082. /// </summary>
  14083. /// <param name="_dto"></param>
  14084. /// <returns></returns>
  14085. [HttpPost]
  14086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14087. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14088. {
  14089. try
  14090. {
  14091. #region 参数验证
  14092. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14093. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14094. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14095. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14096. #region 团组操作权限验证 76 酒店预定模块
  14097. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14098. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14099. #endregion
  14100. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14101. #region 页面操作权限验证
  14102. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14103. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14104. #endregion
  14105. #endregion
  14106. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14107. //判断数据是否完整
  14108. if (hr != null)
  14109. {
  14110. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14111. {
  14112. string strFileName = "HotelStatement/";
  14113. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14114. if (dele != null)
  14115. strFileName += dele.TourCode;
  14116. //载入模板
  14117. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14118. Document doc = new Document(sss);
  14119. DocumentBuilder builder = new DocumentBuilder(doc);
  14120. #region 替换Word模板书签内容
  14121. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14122. //入住卷预定号码
  14123. if (doc.Range.Bookmarks["VNO"] != null)
  14124. {
  14125. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14126. mark.Text = hr.CheckNumber;
  14127. }
  14128. //酒店时间
  14129. if (doc.Range.Bookmarks["Date"] != null)
  14130. {
  14131. Bookmark mark = doc.Range.Bookmarks["Date"];
  14132. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14133. }
  14134. //团号
  14135. if (doc.Range.Bookmarks["TNo"] != null)
  14136. {
  14137. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14138. mark.Text = dele.TourCode;
  14139. }
  14140. //预定号码
  14141. if (doc.Range.Bookmarks["BookingId"] != null)
  14142. {
  14143. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14144. mark.Text = hr.ReservationsNo;
  14145. }
  14146. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14147. {
  14148. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14149. mark.Text = hr.DetermineNo;
  14150. }
  14151. //酒店城市
  14152. if (doc.Range.Bookmarks["City"] != null)
  14153. {
  14154. Bookmark mark = doc.Range.Bookmarks["City"];
  14155. mark.Text = hr.City;
  14156. }
  14157. //酒店名称
  14158. if (doc.Range.Bookmarks["HName"] != null)
  14159. {
  14160. Bookmark mark = doc.Range.Bookmarks["HName"];
  14161. mark.Text = hr.HotelName;
  14162. }
  14163. //酒店地址
  14164. if (doc.Range.Bookmarks["Address"] != null)
  14165. {
  14166. Bookmark mark = doc.Range.Bookmarks["Address"];
  14167. mark.Text = hr.HotelAddress;
  14168. }
  14169. //酒店电话
  14170. if (doc.Range.Bookmarks["Tel"] != null)
  14171. {
  14172. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14173. mark.Text = hr.HotelTel;
  14174. }
  14175. //酒店传真
  14176. if (doc.Range.Bookmarks["Fax"] != null)
  14177. {
  14178. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14179. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14180. {
  14181. mark.Text = hr.HotelFax;
  14182. }
  14183. }
  14184. //入住时间
  14185. if (doc.Range.Bookmarks["CIn"] != null)
  14186. {
  14187. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14188. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14189. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14190. }
  14191. //退房时间
  14192. if (doc.Range.Bookmarks["COut"] != null)
  14193. {
  14194. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14195. Bookmark mark = doc.Range.Bookmarks["COut"];
  14196. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14197. }
  14198. //客户名称
  14199. if (doc.Range.Bookmarks["GName"] != null)
  14200. {
  14201. string guestName = "";
  14202. string[] clients = new string[] { };
  14203. if (hr.GuestName.Contains(","))
  14204. {
  14205. clients = hr.GuestName.Split(",");
  14206. }
  14207. else
  14208. {
  14209. clients = new string[] { hr.GuestName };
  14210. }
  14211. List<int> clientIds_int = new List<int>();
  14212. if (clients.Length > 0)
  14213. {
  14214. foreach (var item in clients)
  14215. {
  14216. if (item.IsNumeric())
  14217. {
  14218. clientIds_int.Add(int.Parse(item));
  14219. }
  14220. }
  14221. }
  14222. if (clientIds_int.Count > 0)
  14223. {
  14224. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14225. foreach (var client in _clientDatas)
  14226. {
  14227. //男
  14228. if (client.Sex == 0) guestName += $"Mr.";
  14229. //女
  14230. else if (client.Sex == 1) guestName += $"Ms.";
  14231. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14232. {
  14233. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14234. }
  14235. //guestName += $"{client.Pinyin},";
  14236. }
  14237. if (guestName.Length > 0)
  14238. {
  14239. guestName = guestName.Substring(0, guestName.Length - 1);
  14240. }
  14241. }
  14242. else
  14243. {
  14244. guestName = hr.GuestName;
  14245. }
  14246. Bookmark mark = doc.Range.Bookmarks["GName"];
  14247. mark.Text = guestName;
  14248. }
  14249. //房间介绍
  14250. if (doc.Range.Bookmarks["ROOM"] != null)
  14251. {
  14252. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14253. mark.Text = hr.RoomExplanation;
  14254. }
  14255. //报价描述
  14256. if (doc.Range.Bookmarks["NOTE"] != null)
  14257. {
  14258. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14259. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14260. if (ss != null)
  14261. mark.Text = ss.Name;
  14262. }
  14263. //入住时间
  14264. if (doc.Range.Bookmarks["CheckIn"] != null)
  14265. {
  14266. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14267. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14268. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14269. }
  14270. //退房时间
  14271. if (doc.Range.Bookmarks["CheckOut"] != null)
  14272. {
  14273. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14274. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14275. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14276. }
  14277. //日期
  14278. if (doc.Range.Bookmarks["DT"] != null)
  14279. {
  14280. Bookmark mark = doc.Range.Bookmarks["DT"];
  14281. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14282. }
  14283. //名称
  14284. if (doc.Range.Bookmarks["VName"] != null)
  14285. {
  14286. Bookmark mark = doc.Range.Bookmarks["VName"];
  14287. mark.Text = hr.HotelName;
  14288. }
  14289. //号码
  14290. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14291. {
  14292. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14293. mark.Text = hr.CheckNumber;
  14294. }
  14295. #endregion
  14296. strFileName += "VOUCHER.doc";
  14297. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14298. doc.Save(fileDir);
  14299. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14300. return Ok(JsonView(true, "操作成功!", Url));
  14301. }
  14302. else
  14303. {
  14304. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14305. }
  14306. }
  14307. else
  14308. {
  14309. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14310. }
  14311. }
  14312. catch (Exception ex)
  14313. {
  14314. return Ok(JsonView(false, ex.Message));
  14315. }
  14316. }
  14317. /// <summary>
  14318. /// 酒店预订
  14319. /// 生成VOUCHER
  14320. /// 2024.05.06 之后版本
  14321. /// </summary>
  14322. /// <param name="_dto"></param>
  14323. /// <returns></returns>
  14324. [HttpPost]
  14325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14326. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14327. {
  14328. #region 参数验证
  14329. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14330. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14331. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14332. #region 团组操作权限验证 76 酒店预定模块
  14333. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14334. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14335. #endregion
  14336. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14337. #region 页面操作权限验证
  14338. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14339. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14340. #endregion
  14341. #endregion
  14342. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14343. //判断数据是否完整
  14344. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14345. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14346. string strFileName = "HotelStatement/";
  14347. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14348. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14349. #region 数据处理
  14350. List<int> guestIds = new List<int>();
  14351. //int index = 0;
  14352. foreach (var item in hrDtas)
  14353. {
  14354. if (item.GuestName.Contains(","))
  14355. {
  14356. string[] guestIdArr = item.GuestName.Split(',');
  14357. foreach (var guestIdStr in guestIdArr)
  14358. {
  14359. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14360. if (guestBool)
  14361. {
  14362. guestIds.Add(guestId);
  14363. }
  14364. }
  14365. }
  14366. else guestNames += item.GuestName;
  14367. var voucherInfo = new HotelVoucherInfoView()
  14368. {
  14369. HotelName = item.HotelName,
  14370. CheckInDate = item.CheckInDate,
  14371. CheckOutDate = item.CheckOutDate,
  14372. ConfirmationNumber = item.DetermineNo.Trim(),
  14373. RoomType = item.RoomExplanation
  14374. };
  14375. vouchers.Add(voucherInfo);
  14376. }
  14377. if (guestIds.Count > 0)
  14378. {
  14379. guestIds = guestIds.Distinct().ToList();
  14380. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14381. if (guestDatas.Count > 0)
  14382. {
  14383. guestNames = "";
  14384. foreach (var guest in guestDatas)
  14385. {
  14386. string guestName = "";
  14387. if (guest.Sex == 0) guestName += @"MR.";
  14388. else if (guest.Sex == 1) guestName += @"MS.";
  14389. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14390. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14391. guestNames += @$"{guestName.Trim()}、";
  14392. }
  14393. if (guestNames.Length > 0)
  14394. {
  14395. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14396. }
  14397. }
  14398. }
  14399. #endregion
  14400. //载入模板
  14401. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14402. Document doc = new Document(sss);
  14403. DocumentBuilder builder = new DocumentBuilder(doc);
  14404. if (doc.Range.Bookmarks["GuestName"] != null)
  14405. {
  14406. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14407. mark.Text = guestNames;
  14408. }
  14409. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14410. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14411. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14412. for (int i = 1; i <= vouchers.Count; i++)
  14413. {
  14414. HotelVoucherInfoView hviv = vouchers[i - 1];
  14415. builder.MoveToCell(0, i, 0, 0);
  14416. builder.Write(hviv.HotelName);
  14417. builder.MoveToCell(0, i, 1, 0);
  14418. builder.Write(hviv.CheckInDate);
  14419. builder.MoveToCell(0, i, 2, 0);
  14420. builder.Write(hviv.CheckOutDate);
  14421. builder.MoveToCell(0, i, 3, 0);
  14422. builder.Write(hviv.RoomType);
  14423. builder.MoveToCell(0, i, 4, 0);
  14424. builder.Write(hviv.ConfirmationNumber);
  14425. }
  14426. //删除多余行
  14427. int currRowIndex = vouchers.Count + 1;
  14428. int delRows = 21 - currRowIndex;
  14429. if (delRows > 0)
  14430. {
  14431. for (int i = 0; i < delRows; i++)
  14432. {
  14433. table.Rows.RemoveAt(currRowIndex);
  14434. //cultivateRowIndex++;
  14435. }
  14436. }
  14437. strFileName += "VOUCHER.docx";
  14438. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14439. doc.Save(fileDir);
  14440. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14441. return Ok(JsonView(true, "操作成功!", Url));
  14442. }
  14443. /// <summary>
  14444. /// 酒店预订
  14445. /// 生成VOUCHER 批量生成
  14446. /// New
  14447. /// </summary>
  14448. /// <param name="_dto"></param>
  14449. /// <returns></returns>
  14450. [HttpPost]
  14451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14452. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14453. {
  14454. #region 参数验证
  14455. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14456. if (_dto.PageId < 1) _dto.PageId = 28;
  14457. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14458. #region 团组操作权限验证 76 酒店预定模块
  14459. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14460. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14461. #endregion
  14462. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14463. #region 页面操作权限验证
  14464. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14465. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14466. #endregion
  14467. #endregion
  14468. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14469. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14470. .OrderBy(x => x.CheckInDate)
  14471. .ToListAsync();
  14472. //判断数据是否完整
  14473. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14474. string strFileName = "HotelStatement/";
  14475. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14476. if (dele != null)
  14477. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14478. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14479. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14480. .Where(it => it.IsDel == 0)
  14481. .ToListAsync();
  14482. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14483. for (int i = 0; i < hrDtas.Count; i++)
  14484. {
  14485. string guestNames = string.Empty;
  14486. List<int> guestIds = new List<int>();
  14487. var item = hrDtas[i];
  14488. //处理客户姓名
  14489. if (item.GuestName.Contains(","))
  14490. {
  14491. string[] guestIdArr = item.GuestName.Split(',');
  14492. foreach (var guestIdStr in guestIdArr)
  14493. if (int.TryParse(guestIdStr, out int guestId))
  14494. guestIds.Add(guestId);
  14495. }
  14496. else
  14497. {
  14498. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14499. if (guestIdBool)
  14500. {
  14501. guestIds.Add(guestId);
  14502. }
  14503. //NaN
  14504. if (item.GuestName.Contains("NaN"))
  14505. {
  14506. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14507. }
  14508. }
  14509. if (guestIds.Count > 0)
  14510. {
  14511. guestIds = guestIds.Distinct().ToList();
  14512. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14513. if (guestDatas1.Count > 0)
  14514. {
  14515. guestNames = "";
  14516. foreach (var guest in guestDatas1)
  14517. {
  14518. string guestName = "";
  14519. if (guest.Sex == 0) guestName += @"MR.";
  14520. else if (guest.Sex == 1) guestName += @"MS.";
  14521. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14522. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14523. guestNames += @$"{guestName.Trim()}、";
  14524. }
  14525. if (guestNames.Length > 0)
  14526. {
  14527. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14528. }
  14529. }
  14530. }
  14531. //if (!string.IsNullOrEmpty(guestNames))
  14532. //{
  14533. hrDtas[i].GuestName = guestNames;
  14534. //}
  14535. }
  14536. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14537. Document doc = new Document();
  14538. DocumentBuilder builder = new DocumentBuilder(doc);
  14539. try
  14540. {
  14541. builder.MoveToDocumentStart();
  14542. foreach (var item in hrDtas)
  14543. {
  14544. //标题
  14545. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14546. builder.ParagraphFormat.LineSpacing = 1;
  14547. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14548. builder.ParagraphFormat.Style.Font.Size = 9;
  14549. builder.ParagraphFormat.Style.Font.Bold = true;
  14550. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14551. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14552. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14553. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14554. builder.ParagraphFormat.LineSpacing = 1;
  14555. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14556. builder.ParagraphFormat.Style.Font.Size = 9;
  14557. builder.ParagraphFormat.Style.Font.Bold = true;
  14558. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14559. builder.StartTable();
  14560. // 设置边框颜色
  14561. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14562. //设置边框样式
  14563. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14564. //表格
  14565. #region 第一行
  14566. builder.InsertCell();
  14567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14568. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14569. //builder.CellFormat.AllowAutoFit = false;
  14570. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14571. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14572. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14573. builder.CellFormat.WrapText = true; //自动换行
  14574. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14575. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14576. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14577. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14578. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14579. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14580. builder.Write("TOUR NO:");
  14581. builder.InsertCell();
  14582. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14583. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14584. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14585. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14586. builder.ParagraphFormat.Style.Font.Bold = false;
  14587. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14588. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14589. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14590. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14591. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14592. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14593. builder.Write($"{dele?.TourCode ?? "-"}");
  14594. builder.InsertCell();
  14595. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14596. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14597. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14598. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14599. builder.ParagraphFormat.Style.Font.Bold = false;
  14600. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14601. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14602. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14603. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14604. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14605. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14606. builder.Write($"CITY:");
  14607. builder.InsertCell();
  14608. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14609. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14610. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14611. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14612. builder.ParagraphFormat.Style.Font.Bold = false;
  14613. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14614. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14615. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14616. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14617. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14618. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14619. builder.Write($"{item.City}");
  14620. builder.EndRow();
  14621. #endregion
  14622. #region 第二行
  14623. builder.InsertCell();
  14624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14625. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14626. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14627. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14628. builder.ParagraphFormat.Style.Font.Bold = false;
  14629. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14630. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14631. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14632. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14633. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14634. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14635. builder.Write("CONFIRMATION NO:");
  14636. builder.InsertCell();
  14637. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14638. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14639. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14640. builder.ParagraphFormat.Style.Font.Bold = false;
  14641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14643. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14644. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14645. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14646. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14647. builder.CellFormat.VerticalMerge = CellMerge.None;
  14648. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14649. builder.Write($"{item.DetermineNo}");
  14650. builder.InsertCell();
  14651. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14652. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14653. builder.InsertCell();
  14654. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14655. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14656. builder.EndRow();
  14657. #endregion
  14658. #region 第三行
  14659. builder.InsertCell();
  14660. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14661. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14662. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14663. builder.ParagraphFormat.Style.Font.Bold = false;
  14664. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14665. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14666. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14667. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14668. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14669. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14670. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14671. builder.Write($"HOTEL NAME:");
  14672. builder.InsertCell();
  14673. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14674. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14675. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14676. builder.ParagraphFormat.Style.Font.Bold = false;
  14677. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14678. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14679. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14680. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14681. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14682. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14683. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14684. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14685. builder.Write($"{item.HotelName}");
  14686. builder.InsertCell();
  14687. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14688. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14689. builder.InsertCell();
  14690. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14691. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14692. builder.EndRow();
  14693. #endregion
  14694. #region 第四行
  14695. builder.InsertCell();
  14696. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14697. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14698. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14699. builder.ParagraphFormat.Style.Font.Bold = false;
  14700. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14701. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14702. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14703. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14704. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14705. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14706. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14707. builder.Write($"HOTEL ADDRESS:");
  14708. builder.InsertCell();
  14709. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14710. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14711. builder.ParagraphFormat.Style.Font.Size = 8;
  14712. builder.ParagraphFormat.Style.Font.Bold = false;
  14713. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14714. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14715. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14716. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14717. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14718. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14719. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14720. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14721. builder.Write($"{item.HotelAddress}");
  14722. builder.InsertCell();
  14723. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14724. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14725. builder.InsertCell();
  14726. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14727. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14728. builder.EndRow();
  14729. #endregion
  14730. #region 第五行
  14731. builder.InsertCell();
  14732. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14733. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14734. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14735. builder.ParagraphFormat.Style.Font.Bold = false;
  14736. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14737. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14738. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14739. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14740. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14741. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14742. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14743. builder.Write("TEL:");
  14744. builder.InsertCell();
  14745. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14746. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14747. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14748. builder.ParagraphFormat.Style.Font.Bold = false;
  14749. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14750. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14751. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14752. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14753. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14754. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14755. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14756. builder.Write($"{item.HotelTel}");
  14757. builder.InsertCell();
  14758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14759. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14760. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14761. builder.ParagraphFormat.Style.Font.Bold = false;
  14762. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14763. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14764. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14765. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14766. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14767. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14768. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14769. builder.Write($"FAX:");
  14770. builder.InsertCell();
  14771. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14772. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14773. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14774. builder.ParagraphFormat.Style.Font.Bold = false;
  14775. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14776. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14777. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14778. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14779. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14780. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14781. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14782. builder.Write($"{item.HotelFax}");
  14783. builder.EndRow();
  14784. #endregion
  14785. #region 第六行
  14786. builder.InsertCell();
  14787. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14788. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14789. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14790. builder.ParagraphFormat.Style.Font.Bold = false;
  14791. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14792. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14793. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14794. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14795. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14796. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14797. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14798. builder.Write("CHECK IN:");
  14799. builder.InsertCell();
  14800. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14801. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14802. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14803. builder.ParagraphFormat.Style.Font.Bold = false;
  14804. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14805. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14806. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14807. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14808. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14809. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14810. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14811. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14812. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14813. builder.Write($"{checkInStr}");
  14814. builder.InsertCell();
  14815. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14816. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14817. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14818. builder.ParagraphFormat.Style.Font.Bold = false;
  14819. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14820. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14821. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14822. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14823. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14824. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14825. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14826. builder.Write($"CHECK OUT:");
  14827. builder.InsertCell();
  14828. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14829. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14830. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14831. builder.ParagraphFormat.Style.Font.Bold = false;
  14832. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14833. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14834. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14835. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14836. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14837. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14838. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14839. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14840. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14841. builder.Write($"{checkOutStr}");
  14842. builder.EndRow();
  14843. #endregion
  14844. #region 第七行
  14845. builder.InsertCell();
  14846. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14847. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14848. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14849. builder.ParagraphFormat.Style.Font.Bold = false;
  14850. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14851. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14852. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14853. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14854. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14855. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14856. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14857. builder.Write($"GUEST NAME:");
  14858. builder.InsertCell();
  14859. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14860. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14861. builder.ParagraphFormat.Style.Font.Size = 8;
  14862. builder.ParagraphFormat.Style.Font.Bold = false;
  14863. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14864. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14865. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14866. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14867. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14868. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14869. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14870. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14871. builder.Write($"{item.GuestName}");
  14872. builder.InsertCell();
  14873. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14874. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14875. builder.InsertCell();
  14876. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14877. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14878. builder.EndRow();
  14879. #endregion
  14880. #region 第八行
  14881. builder.InsertCell();
  14882. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14883. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14884. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14885. builder.ParagraphFormat.Style.Font.Bold = false;
  14886. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14887. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14888. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14889. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14890. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14891. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14892. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14893. builder.Write($"ROOM TYPE:");
  14894. builder.InsertCell();
  14895. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14896. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14897. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14898. builder.ParagraphFormat.Style.Font.Bold = false;
  14899. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14900. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14901. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14902. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14903. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14904. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14905. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14906. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14907. builder.Write($"{item.RoomExplanation}");
  14908. builder.InsertCell();
  14909. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14910. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14911. builder.InsertCell();
  14912. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14913. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14914. builder.EndRow();
  14915. #endregion
  14916. #region 第九行
  14917. builder.InsertCell();
  14918. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14919. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14920. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14921. builder.ParagraphFormat.Style.Font.Bold = false;
  14922. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14923. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14924. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14925. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14926. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14927. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14928. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14929. builder.Write($"NOTE:");
  14930. builder.InsertCell();
  14931. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14932. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14933. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14934. builder.ParagraphFormat.Style.Font.Bold = false;
  14935. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14936. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14937. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14938. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14939. 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.");
  14940. builder.InsertCell();
  14941. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14942. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14943. builder.InsertCell();
  14944. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14945. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14946. builder.EndRow();
  14947. #endregion
  14948. builder.EndTable();
  14949. //换行
  14950. builder.Writeln("");
  14951. builder.Writeln("");
  14952. }
  14953. #region 获取文档中的所有表格 设置文字自适应
  14954. // 获取文档中的所有表格。
  14955. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14956. {
  14957. // 遍历表格中的所有行。
  14958. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14959. {
  14960. foreach (Cell cell in row.Cells)
  14961. {
  14962. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14963. cellFormat.Width = 0;
  14964. }
  14965. }
  14966. }
  14967. #endregion
  14968. #region 设置页眉
  14969. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14970. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14971. if (System.IO.File.Exists(voucherHeaderPath))
  14972. {
  14973. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14974. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14975. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14976. Shape shape = builder.InsertImage(imageBytes);
  14977. // 调整图片位置
  14978. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14979. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14980. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14981. shape.Left = 0; // 将图片距离页面左边缘的距离
  14982. shape.Width = 81; // 设置图片宽度
  14983. shape.Height = 36; // 设置图片高度
  14984. }
  14985. //靠右
  14986. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14987. //// 设置页脚上下边距
  14988. //builder.PageSetup.HeaderDistance = 42;
  14989. // 添加页眉线
  14990. Aspose.Words.Border borderHeader = null;
  14991. try
  14992. {
  14993. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14994. }
  14995. catch (Exception e)
  14996. {
  14997. // TODO Auto-generated catch block
  14998. //e.printStackTrace();
  14999. }
  15000. borderHeader.Shadow = true;
  15001. borderHeader.DistanceFromText = 2;
  15002. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15003. #endregion
  15004. }
  15005. catch (Exception ex)
  15006. {
  15007. }
  15008. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15009. doc.Save(fileDir);
  15010. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15011. return Ok(JsonView(true, "操作成功!", Url));
  15012. }
  15013. /// <summary>
  15014. /// 酒店预订
  15015. /// 生成 预定成本 Excel
  15016. /// </summary>
  15017. /// <param name="_dto"></param>
  15018. /// <returns></returns>
  15019. [HttpPost]
  15020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15021. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15022. {
  15023. #region 参数验证
  15024. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15025. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15026. if (!vadalitorRes.IsValid)
  15027. {
  15028. var errors = new StringBuilder();
  15029. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15030. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15031. }
  15032. #region 团组操作权限验证 76 酒店预定模块
  15033. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15034. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15035. #endregion
  15036. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15037. #region 页面操作权限验证
  15038. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15039. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15040. #endregion
  15041. #endregion
  15042. decimal _rate = 1.00M;
  15043. string _currency = string.Empty;
  15044. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15045. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15046. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15047. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15048. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15049. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15050. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15051. if (_GroupCostParameter == null)
  15052. {
  15053. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15054. bool isIntType = int.TryParse(_currency, out int currId);
  15055. if (isIntType)
  15056. {
  15057. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15058. }
  15059. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15060. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15061. if (currInfo == null)
  15062. {
  15063. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15064. }
  15065. else _rate = currInfo.Rate;
  15066. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15067. {
  15068. _rate = _GroupCostParameter.Rate;
  15069. }
  15070. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15071. //string strFileName = "HotelStatement/";
  15072. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15073. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15074. var rateDatas = new List<dynamic>();
  15075. #region 数据处理
  15076. foreach (var item in hrDtas)
  15077. {
  15078. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15079. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15080. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15081. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15082. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15083. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15084. {
  15085. continue;
  15086. }
  15087. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15088. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15089. string singleRoomFeeStr = string.Empty,
  15090. doubleRoomFeeStr = string.Empty,
  15091. suiteRoomFeeStr = string.Empty,
  15092. otherRoomFeeStr = string.Empty,
  15093. payMoneyStr = string.Empty,
  15094. cardPriceStr = string.Empty;
  15095. if (roomCurr.Equals("CNY"))
  15096. {
  15097. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15098. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15099. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15100. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15101. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15102. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15103. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15104. }
  15105. else
  15106. {
  15107. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15108. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15109. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15110. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15111. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15112. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15113. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15114. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15115. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15116. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15117. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15118. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15119. if (ccpPaymentCurrency.Equals("CNY"))
  15120. {
  15121. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15122. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15123. }
  15124. else
  15125. {
  15126. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15127. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15128. }
  15129. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15130. if (hotelcardPriceCurrency.Equals("CNY"))
  15131. {
  15132. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15133. }
  15134. else
  15135. {
  15136. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15137. }
  15138. }
  15139. string breakfastPriceStr = string.Empty,
  15140. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15141. governmentRentStr = string.Empty,
  15142. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15143. cityTaxStr = string.Empty,
  15144. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15145. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15146. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15147. {
  15148. if (breakfastCurrency1.Equals("CNY"))
  15149. {
  15150. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15151. }
  15152. else
  15153. {
  15154. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15155. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15156. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15157. }
  15158. }
  15159. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15160. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15161. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15162. {
  15163. if (governmentRentCurrency.Equals("CNY"))
  15164. {
  15165. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15166. }
  15167. else
  15168. {
  15169. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15170. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15171. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15172. }
  15173. }
  15174. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15175. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15176. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15177. {
  15178. if (cityTaxStrCurrency1.Equals("CNY"))
  15179. {
  15180. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15181. }
  15182. else
  15183. {
  15184. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15185. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15186. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15187. }
  15188. }
  15189. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15190. int payDId = roomInfo?.PayDId ?? 0;
  15191. pcfds.Add(new HotelReservations_PCFD_View()
  15192. {
  15193. City = item.City,
  15194. HotelName = item.HotelName,
  15195. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15196. // SingleRoomCount = item.SingleRoomCount,
  15197. SingleRoomPrice = singleRoomFeeStr,
  15198. // DoubleRoomCount = item.DoubleRoomCount,
  15199. DoubleRoomPrice = doubleRoomFeeStr,
  15200. //SuiteRoomCount = item.SuiteRoomCount,
  15201. SuiteRoomPrice = suiteRoomFeeStr,
  15202. OtherRoomPrice = otherRoomFeeStr,
  15203. //OtherRoomCount = item.OtherRoomCount,
  15204. BreakfastPrice = breakfastPriceStr,
  15205. GovernmentRent = governmentRentStr,
  15206. CityTax = cityTaxStr,
  15207. RoomExplanation = item.RoomExplanation,
  15208. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15209. PayTime = roomInfo?.ConsumptionDate,
  15210. BankNo = roomInfo?.BankNo,
  15211. PayMoney = payMoneyStr,
  15212. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15213. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15214. CardPrice = cardPriceStr,
  15215. Remark = ccpInfo.Remark
  15216. });
  15217. }
  15218. #endregion
  15219. //载入模板
  15220. WorkbookDesigner designer = new WorkbookDesigner();
  15221. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15222. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15223. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15224. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15225. var rateDatas1 = rateDatas.Distinct();
  15226. var rateStr = string.Empty;
  15227. foreach (var item in rateDatas1)
  15228. {
  15229. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15230. }
  15231. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15232. designer.SetDataSource("Opertor", userInfo.CnName);
  15233. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15234. dt.TableName = "ViewMyHotelReservations";
  15235. designer.SetDataSource(dt);
  15236. designer.Process();
  15237. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15238. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15239. designer.Workbook.Save(serverPath);
  15240. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15241. #region 删除指定行
  15242. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15243. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15244. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15245. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15246. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15247. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15248. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15249. cssIndex = dt.Columns["CityTax"].Ordinal,
  15250. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15251. remarkIndex = dt.Columns["Remark"].Ordinal;
  15252. //删除指定列
  15253. foreach (DataRow item in dt.Rows)
  15254. {
  15255. string singleStr = item["SingleRoomPrice"].ToString();
  15256. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15257. if (containsDigitButNotZero1) singleDel = false;
  15258. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15259. string doubleStr = item["DoubleRoomPrice"].ToString();
  15260. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15261. if (containsDigitButNotZero2) doubleDel = false;
  15262. string suiteStr = item["SuiteRoomPrice"].ToString();
  15263. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15264. if (containsDigitButNotZero3) suiteDel = false;
  15265. string otherStr = item["OtherRoomPrice"].ToString();
  15266. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15267. if (containsDigitButNotZero4) otherDel = false;
  15268. string zcStr = item["BreakfastPrice"].ToString();
  15269. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15270. if (containsDigitButNotZero5) zcDel = false;
  15271. string dsStr = item["GovernmentRent"].ToString();
  15272. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15273. if (containsDigitButNotZero6) dsDel = false;
  15274. string cssStr = item["CityTax"].ToString();
  15275. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15276. if (containsDigitButNotZero7) cssDel = false;
  15277. string cpStr = item["ConsumptionPatterns"].ToString();
  15278. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15279. string remarkStr = item["Remark"].ToString();
  15280. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15281. }
  15282. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15283. DeleteColumn(serverPath, cpIndex, cpDel);
  15284. DeleteColumn(serverPath, dsIndex, dsDel);
  15285. DeleteColumn(serverPath, cssIndex, cssDel);
  15286. DeleteColumn(serverPath, zcIndex, zcDel);
  15287. DeleteColumn(serverPath, otherIndex, otherDel);
  15288. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15289. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15290. DeleteColumn(serverPath, singleIndex, singleDel);
  15291. #endregion
  15292. //只保留第一个表格
  15293. DeleteSheet(serverPath);
  15294. return Ok(JsonView(true, "操作成功", url = rst));
  15295. }
  15296. else
  15297. {
  15298. _currency = _GroupCostParameter.Currency;
  15299. bool isIntType = int.TryParse(_currency, out int currId);
  15300. if (isIntType)
  15301. {
  15302. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15303. }
  15304. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15305. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15306. if (currInfo == null)
  15307. {
  15308. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15309. }
  15310. if (!_currency.ToUpper().Equals("CNY"))
  15311. {
  15312. _rate = _GroupCostParameter.Rate;
  15313. }
  15314. _rate = currInfo.Rate;
  15315. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15316. //string strFileName = "HotelStatement/";
  15317. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15318. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15319. #region 数据处理
  15320. foreach (var item in hrDtas)
  15321. {
  15322. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15323. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15324. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15325. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15326. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15327. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15328. string singleRoomFeeStr = string.Empty,
  15329. doubleRoomFeeStr = string.Empty,
  15330. suiteRoomFeeStr = string.Empty,
  15331. otherRoomFeeStr = string.Empty,
  15332. payMoneyStr = string.Empty,
  15333. cardPriceStr = string.Empty;
  15334. if (roomCurr.Equals(_currency))
  15335. {
  15336. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15337. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15338. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15339. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15340. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15341. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15342. }
  15343. else
  15344. {
  15345. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15346. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15347. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15348. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15349. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15350. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15351. }
  15352. string breakfastPriceStr = string.Empty,
  15353. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15354. governmentRentStr = string.Empty,
  15355. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15356. cityTaxStrStr = string.Empty,
  15357. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15358. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15359. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15360. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15361. int payDId = roomInfo?.PayDId ?? 0;
  15362. pcfds.Add(new HotelReservations_PCFD_View()
  15363. {
  15364. City = item.City,
  15365. HotelName = item.HotelName,
  15366. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15367. // SingleRoomCount = item.SingleRoomCount,
  15368. SingleRoomPrice = singleRoomFeeStr,
  15369. // DoubleRoomCount = item.DoubleRoomCount,
  15370. DoubleRoomPrice = doubleRoomFeeStr,
  15371. //SuiteRoomCount = item.SuiteRoomCount,
  15372. SuiteRoomPrice = suiteRoomFeeStr,
  15373. OtherRoomPrice = otherRoomFeeStr,
  15374. //OtherRoomCount = item.OtherRoomCount,
  15375. BreakfastPrice = breakfastPriceStr,
  15376. GovernmentRent = governmentRentStr,
  15377. CityTax = cityTaxStrStr,
  15378. RoomExplanation = item.RoomExplanation,
  15379. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15380. PayTime = roomInfo?.ConsumptionDate,
  15381. BankNo = roomInfo?.BankNo,
  15382. PayMoney = payMoneyStr,
  15383. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15384. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15385. CardPrice = cardPriceStr,
  15386. Remark = ccpInfo.Remark
  15387. });
  15388. }
  15389. #endregion
  15390. //载入模板
  15391. WorkbookDesigner designer = new WorkbookDesigner();
  15392. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15393. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15394. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15395. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15396. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15397. designer.SetDataSource("Opertor", userInfo.CnName);
  15398. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15399. dt.TableName = "ViewMyHotelReservations";
  15400. designer.SetDataSource(dt);
  15401. designer.Process();
  15402. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15403. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15404. designer.Workbook.Save(serverPath);
  15405. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15406. #region 删除指定行
  15407. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15408. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15409. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15410. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15411. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15412. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15413. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15414. cssIndex = dt.Columns["CityTax"].Ordinal,
  15415. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15416. remarkIndex = dt.Columns["Remark"].Ordinal;
  15417. //删除指定列
  15418. foreach (DataRow item in dt.Rows)
  15419. {
  15420. string singleStr = item["SingleRoomPrice"].ToString();
  15421. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15422. if (containsDigitButNotZero1) singleDel = false;
  15423. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15424. string doubleStr = item["DoubleRoomPrice"].ToString();
  15425. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15426. if (containsDigitButNotZero2) doubleDel = false;
  15427. string suiteStr = item["SuiteRoomPrice"].ToString();
  15428. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15429. if (containsDigitButNotZero3) suiteDel = false;
  15430. string otherStr = item["OtherRoomPrice"].ToString();
  15431. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15432. if (containsDigitButNotZero4) otherDel = false;
  15433. string zcStr = item["BreakfastPrice"].ToString();
  15434. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15435. if (containsDigitButNotZero5) zcDel = false;
  15436. string dsStr = item["GovernmentRent"].ToString();
  15437. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15438. if (containsDigitButNotZero6) dsDel = false;
  15439. string cssStr = item["CityTax"].ToString();
  15440. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15441. if (containsDigitButNotZero7) cssDel = false;
  15442. string cpStr = item["ConsumptionPatterns"].ToString();
  15443. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15444. string remarkStr = item["Remark"].ToString();
  15445. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15446. }
  15447. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15448. DeleteColumn(serverPath, cpIndex, cpDel);
  15449. DeleteColumn(serverPath, dsIndex, dsDel);
  15450. DeleteColumn(serverPath, cssIndex, cssDel);
  15451. DeleteColumn(serverPath, zcIndex, zcDel);
  15452. DeleteColumn(serverPath, otherIndex, otherDel);
  15453. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15454. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15455. DeleteColumn(serverPath, singleIndex, singleDel);
  15456. #endregion
  15457. //只保留第一个表格
  15458. DeleteSheet(serverPath);
  15459. return Ok(JsonView(true, "操作成功", url = rst));
  15460. }
  15461. //return Ok(JsonView(false));
  15462. }
  15463. /// <summary>
  15464. /// 删除指定列
  15465. /// </summary>
  15466. /// <param name="file"></param>
  15467. /// <param name="columnIndex"></param>
  15468. /// <param name="isDel"></param>
  15469. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15470. {
  15471. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15472. //wb.Save(file);
  15473. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15474. if (sheet1 != null)
  15475. {
  15476. if (isDel)
  15477. {
  15478. Cells cells = sheet1.Cells;
  15479. cells.DeleteColumn(columnIndex);
  15480. }
  15481. }
  15482. wb.Save(file);
  15483. }
  15484. /// <summary>
  15485. /// 删除sheet
  15486. /// </summary>
  15487. /// <param name="file"></param>
  15488. /// <param name="sheetName"></param>
  15489. private void DeleteSheet(string file, string sheetName = "")
  15490. {
  15491. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15492. //wb.Save(file);
  15493. List<string> sheets = new List<string>();
  15494. foreach (var item in wb.Worksheets)
  15495. {
  15496. sheets.Add(item.Name);
  15497. }
  15498. if (sheets.Count > 0)
  15499. {
  15500. sheets.RemoveAt(0);//不删除第一个sheet
  15501. foreach (var item in sheets)
  15502. {
  15503. wb.Worksheets.RemoveAt(item);
  15504. }
  15505. }
  15506. wb.Save(file);
  15507. }
  15508. /// <summary>
  15509. /// 酒店预订
  15510. /// 确认单
  15511. /// </summary>
  15512. /// <param name="_dto"></param>
  15513. /// <returns></returns>
  15514. [HttpPost]
  15515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15516. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15517. {
  15518. try
  15519. {
  15520. #region 参数验证
  15521. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15522. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15523. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15524. #region 团组操作权限验证 76 酒店预定模块
  15525. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15526. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15527. #endregion
  15528. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15529. #region 页面操作权限验证
  15530. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15531. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15532. #endregion
  15533. #endregion
  15534. //团组信息
  15535. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15536. //酒店数据
  15537. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15538. if (listhoteldata.Count < 0)
  15539. {
  15540. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15541. }
  15542. //利datatable存储
  15543. DataTable dt = new DataTable();
  15544. dt.Columns.Add("CheckInDate", typeof(string));
  15545. dt.Columns.Add("City", typeof(string));
  15546. dt.Columns.Add("Hotel", typeof(string));
  15547. dt.Columns.Add("Room", typeof(string));
  15548. for (int i = 0; i < listhoteldata.Count; i++)
  15549. {
  15550. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15551. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15552. while (dayStart < dayEnd)
  15553. {
  15554. string temp = "";
  15555. DataRow row = dt.NewRow();
  15556. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15557. row["City"] = listhoteldata[i].City;
  15558. row["Hotel"] = listhoteldata[i].HotelName;
  15559. if (listhoteldata[i].SingleRoomCount > 0)
  15560. {
  15561. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15562. }
  15563. if (listhoteldata[i].DoubleRoomCount > 0)
  15564. {
  15565. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15566. }
  15567. if (listhoteldata[i].SuiteRoomCount > 0)
  15568. {
  15569. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15570. }
  15571. if (listhoteldata[i].OtherRoomCount > 0)
  15572. {
  15573. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15574. }
  15575. row["Room"] = temp;
  15576. dt.Rows.Add(row);
  15577. dayStart = dayStart.AddDays(1);
  15578. }
  15579. }
  15580. Dictionary<string, string> dic = new Dictionary<string, string>();
  15581. dic.Add("Dele", di.TeamName);
  15582. dic.Add("City", di.VisitCountry);
  15583. //模板路径
  15584. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15585. //载入模板
  15586. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15587. DocumentBuilder builder = new DocumentBuilder(doc);
  15588. foreach (var key in dic.Keys)
  15589. {
  15590. builder.MoveToBookmark(key);
  15591. builder.Write(dic[key]);
  15592. }
  15593. //获取word里所有表格
  15594. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15595. //获取所填表格的序数
  15596. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15597. var rowStart = tableOne.Rows[0]; //获取第1行
  15598. //循环赋值
  15599. for (int i = 0; i < dt.Rows.Count; i++)
  15600. {
  15601. builder.MoveToCell(0, i + 1, 0, 0);
  15602. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15603. builder.MoveToCell(0, i + 1, 1, 0);
  15604. builder.Write(dt.Rows[i]["City"].ToString());
  15605. builder.MoveToCell(0, i + 1, 2, 0);
  15606. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15607. builder.MoveToCell(0, i + 1, 3, 0);
  15608. builder.Write(dt.Rows[i]["Room"].ToString());
  15609. }
  15610. //删除多余行
  15611. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15612. {
  15613. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15614. }
  15615. string strFileName = di.TeamName + "酒店确认单.doc";
  15616. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15617. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15618. return Ok(JsonView(true, "成功", url));
  15619. }
  15620. catch (Exception ex)
  15621. {
  15622. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15623. }
  15624. }
  15625. #endregion
  15626. #region 团组状态
  15627. /// <summary>
  15628. /// 团组状态列表 Page
  15629. /// </summary>
  15630. /// <param name="dto">团组列表请求dto</param>
  15631. /// <returns></returns>
  15632. [HttpPost]
  15633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15634. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15635. {
  15636. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15637. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15638. {
  15639. string sqlWhere = string.Empty;
  15640. if (dto.IsSure == 0) //未完成
  15641. {
  15642. sqlWhere += string.Format(@" And IsSure = 0");
  15643. }
  15644. else if (dto.IsSure == 1) //已完成
  15645. {
  15646. sqlWhere += string.Format(@" And IsSure = 1");
  15647. }
  15648. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15649. {
  15650. string tj = dto.SearchCriteria;
  15651. 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}%')",
  15652. tj, tj, tj, tj, tj);
  15653. }
  15654. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15655. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15656. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15657. From (
  15658. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15659. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15660. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15661. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15662. From Grp_DelegationInfo gdi
  15663. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15664. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15665. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15666. Where gdi.IsDel = 0 {0}
  15667. ) temp ", sqlWhere);
  15668. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15669. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15670. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15671. }
  15672. else
  15673. {
  15674. return Ok(JsonView(false, "查询失败"));
  15675. }
  15676. }
  15677. /// <summary>
  15678. /// 团组状态
  15679. /// 设置操作完成
  15680. /// </summary>
  15681. /// <param name="dto">团组列表请求dto</param>
  15682. /// <returns></returns>
  15683. [HttpPost]
  15684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15685. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15686. {
  15687. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15688. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15689. {
  15690. Id = dto.Id,
  15691. IsSure = 1
  15692. };
  15693. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15694. .UpdateColumns(it => new { it.IsSure })
  15695. .WhereColumns(it => new { it.Id })
  15696. .ExecuteCommandAsync();
  15697. if (result > 0)
  15698. {
  15699. return Ok(JsonView(true, "操作完成!"));
  15700. }
  15701. return Ok(JsonView(false, "操作失败!"));
  15702. }
  15703. #endregion
  15704. #region 保险费用录入
  15705. /// <summary>
  15706. /// 根据团组Id查询保险费用列表
  15707. /// </summary>
  15708. /// <param name="dto"></param>
  15709. /// <returns></returns>
  15710. [HttpPost]
  15711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15712. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15713. {
  15714. Result groupData = await _customersRep.CustomersByDiId(dto);
  15715. if (groupData.Code != 0)
  15716. {
  15717. return Ok(JsonView(false, groupData.Msg));
  15718. }
  15719. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15720. }
  15721. /// <summary>
  15722. /// 根据保险费用Id查询保险费用详细
  15723. /// </summary>
  15724. /// <param name="dto"></param>
  15725. /// <returns></returns>
  15726. [HttpPost]
  15727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15728. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15729. {
  15730. try
  15731. {
  15732. Result groupData = await _customersRep.CustomersById(dto);
  15733. if (groupData.Code != 0)
  15734. {
  15735. return Ok(JsonView(false, groupData.Msg));
  15736. }
  15737. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15738. }
  15739. catch (Exception ex)
  15740. {
  15741. return Ok(JsonView(false, ex.Message));
  15742. }
  15743. }
  15744. /// <summary>
  15745. /// 保险费用录入页面初始化绑定
  15746. /// </summary>
  15747. /// <param name="dto"></param>
  15748. /// <returns></returns>
  15749. [HttpPost]
  15750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15751. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15752. {
  15753. try
  15754. {
  15755. Result groupData = await _customersRep.CustomersInitialize(dto);
  15756. if (groupData.Code != 0)
  15757. {
  15758. return Ok(JsonView(false, groupData.Msg));
  15759. }
  15760. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15761. }
  15762. catch (Exception ex)
  15763. {
  15764. return Ok(JsonView(false, ex.Message));
  15765. }
  15766. }
  15767. /// <summary>
  15768. /// 保险费用操作(Status:1.新增,2.修改)
  15769. /// </summary>
  15770. /// <param name="dto"></param>
  15771. /// <returns></returns>
  15772. [HttpPost]
  15773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15774. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15775. {
  15776. Result groupData = await _customersRep.OpCustomers(dto);
  15777. if (groupData.Code != 0)
  15778. {
  15779. return Ok(JsonView(false, groupData.Msg));
  15780. }
  15781. #region 应用推送
  15782. try
  15783. {
  15784. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15785. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15786. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15787. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15788. //自动审核
  15789. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15790. //2024-10-21 新增LZ UID
  15791. var userIds = new List<int>() { 21 };
  15792. string title = $"系统通知";
  15793. var diId = dto.DiId;
  15794. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15795. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15796. string content = "";
  15797. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15798. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15799. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15800. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15801. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15802. }
  15803. catch (Exception ex)
  15804. {
  15805. }
  15806. #endregion
  15807. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15808. }
  15809. /// <summary>
  15810. /// 保险文件上传
  15811. /// </summary>
  15812. /// <param name="file"></param>
  15813. /// <returns></returns>
  15814. [HttpPost]
  15815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15816. public async Task<IActionResult> UploadCus(IFormFile file)
  15817. {
  15818. try
  15819. {
  15820. if (file != null)
  15821. {
  15822. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15823. //文件名称
  15824. string projectFileName = file.FileName;
  15825. //上传的文件的路径
  15826. string filePath = "";
  15827. if (!Directory.Exists(fileDir))
  15828. {
  15829. Directory.CreateDirectory(fileDir);
  15830. }
  15831. //上传的文件的路径
  15832. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15833. using (FileStream fs = System.IO.File.Create(filePath))
  15834. {
  15835. file.CopyTo(fs);
  15836. fs.Flush();
  15837. }
  15838. return Ok(JsonView(true, "上传成功!", projectFileName));
  15839. }
  15840. else
  15841. {
  15842. return Ok(JsonView(false, "上传失败!"));
  15843. }
  15844. }
  15845. catch (Exception ex)
  15846. {
  15847. return Ok(JsonView(false, "程序错误!"));
  15848. throw;
  15849. }
  15850. }
  15851. /// <summary>
  15852. /// 保险删除指定文件
  15853. /// </summary>
  15854. /// <param name="dto"></param>
  15855. /// <returns></returns>
  15856. [HttpPost]
  15857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15858. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15859. {
  15860. try
  15861. {
  15862. string filePath = "";
  15863. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15864. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15865. //int id = 0;
  15866. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15867. // 删除该文件
  15868. try
  15869. {
  15870. System.IO.File.Delete(filePath);
  15871. 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()
  15872. {
  15873. Attachment = "",
  15874. }).ExecuteCommandAsync();
  15875. if (result != 0)
  15876. {
  15877. return Ok(JsonView(true, "成功!"));
  15878. }
  15879. else
  15880. {
  15881. return Ok(JsonView(false, "失败!"));
  15882. }
  15883. }
  15884. catch (Exception)
  15885. {
  15886. 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()
  15887. {
  15888. Attachment = "",
  15889. }).ExecuteCommandAsync();
  15890. if (result != 0)
  15891. {
  15892. return Ok(JsonView(true, "成功!"));
  15893. }
  15894. else
  15895. {
  15896. return Ok(JsonView(false, "失败!"));
  15897. }
  15898. }
  15899. }
  15900. catch (Exception ex)
  15901. {
  15902. return Ok(JsonView(false, "程序错误!"));
  15903. throw;
  15904. }
  15905. }
  15906. /// <summary>
  15907. /// 保险费用操作(删除)
  15908. /// </summary>
  15909. /// <param name="dto"></param>
  15910. /// <returns></returns>
  15911. [HttpPost]
  15912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15913. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15914. {
  15915. try
  15916. {
  15917. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15918. if (!res)
  15919. {
  15920. return Ok(JsonView(false, "删除失败"));
  15921. }
  15922. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15923. {
  15924. IsDel = 1,
  15925. DeleteUserId = dto.DeleteUserId,
  15926. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15927. }).ExecuteCommandAsync();
  15928. return Ok(JsonView(true, "删除成功!"));
  15929. }
  15930. catch (Exception ex)
  15931. {
  15932. return Ok(JsonView(false, "程序错误!"));
  15933. throw;
  15934. }
  15935. }
  15936. #endregion
  15937. #region 接团客户名单 PageId 104
  15938. /// <summary>
  15939. /// 接团客户名单
  15940. /// 迁移数据(慎用!)
  15941. /// </summary>
  15942. /// <returns></returns>
  15943. [HttpPost]
  15944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15945. public async Task<IActionResult> PostTourClientListChange()
  15946. {
  15947. try
  15948. {
  15949. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15950. //var groupClinetData1
  15951. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15952. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15953. int updateCount = 0;
  15954. if (oldOAClientList.Count > 0)
  15955. {
  15956. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15957. _sqlSugar.BeginTran();
  15958. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15959. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15960. foreach (var item in oldOAClientList)
  15961. {
  15962. int comId = 0;
  15963. string format = "yyyy-MM-dd HH:mm:ss";
  15964. string data11 = "1990-01-01 00:00";
  15965. var data1 = IsValidDate(item.OPdate, format);
  15966. if (data1) data11 = item.OPdate;
  15967. //客户公司验证
  15968. if (!string.IsNullOrEmpty(item.Company))
  15969. {
  15970. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15971. if (clientComInfo == null) // add
  15972. {
  15973. var addInfo = new Crm_CustomerCompany()
  15974. {
  15975. CompanyAbbreviation = "",
  15976. CompanyFullName = item.Company,
  15977. Address = "",
  15978. PostCodes = "",
  15979. LastedOpUserId = item.OPer,
  15980. LastedOpDt = Convert.ToDateTime(data11),
  15981. CreateUserId = item.OPer,
  15982. CreateTime = Convert.ToDateTime(data11),
  15983. IsDel = 0
  15984. };
  15985. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15986. if (comId1 > 0) comId = comId1;
  15987. }
  15988. else comId = clientComInfo.Id;
  15989. }
  15990. //客户人员验证
  15991. int clientId = 0;
  15992. string name = item.LastName + item.Name;
  15993. if (!string.IsNullOrEmpty(name))
  15994. {
  15995. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15996. if (clientInfo == null)
  15997. {
  15998. DateTime? dateTime = null;
  15999. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16000. if (isDt) dateTime = birthDayDt;
  16001. var addInfo1 = new Crm_DeleClient()
  16002. {
  16003. CrmCompanyId = comId,
  16004. DiId = -1,
  16005. LastName = item.LastName,
  16006. FirstName = item.Name,
  16007. OldName = "",
  16008. Pinyin = item.Pinyin,
  16009. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16010. Marriage = 0,
  16011. Phone = item.Phone,
  16012. Job = item.Job,
  16013. BirthDay = dateTime
  16014. };
  16015. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16016. if (clientId1 > 0) clientId = clientId1;
  16017. }
  16018. else clientId = clientInfo.Id;
  16019. }
  16020. if (clientId < 1)
  16021. {
  16022. continue;
  16023. }
  16024. int airType = 0;
  16025. if (item.AirType == "超经舱") airType = 459;
  16026. else if (item.AirType == "公务舱") airType = 458;
  16027. else if (item.AirType == "经济舱") airType = 460;
  16028. else if (item.AirType == "其他") airType = 565;
  16029. else if (item.AirType == "头等舱") airType = 457;
  16030. var _TourClientListEntity = new Grp_TourClientList()
  16031. {
  16032. DiId = item.Diid,
  16033. ClientId = clientId,
  16034. CreateUserId = item.OPer,
  16035. CreateTime = Convert.ToDateTime(data11),
  16036. Remark = item.Remark,
  16037. IsDel = item.Isdel,
  16038. ShippingSpaceTypeId = airType,
  16039. ShippingSpaceSpecialNeeds = item.AirRemark,
  16040. HotelSpecialNeeds = item.RoomType
  16041. };
  16042. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16043. if (_TourClientList > 0)
  16044. {
  16045. updateCount++;
  16046. }
  16047. }
  16048. _sqlSugar.CommitTran();
  16049. }
  16050. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16051. }
  16052. catch (Exception ex)
  16053. {
  16054. _sqlSugar.RollbackTran();
  16055. return Ok(JsonView(false, ex.Message));
  16056. }
  16057. //return Ok(JsonView(true));
  16058. }
  16059. private bool IsValidDate(string dateString, string format)
  16060. {
  16061. DateTime dateValue;
  16062. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16063. return valid;
  16064. }
  16065. /// <summary>
  16066. /// 接团客户名单
  16067. /// 根据团组Id查询List
  16068. /// </summary>
  16069. /// <param name="_dto"></param>
  16070. /// <returns></returns>
  16071. [HttpPost]
  16072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16073. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16074. {
  16075. #region 参数验证
  16076. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16077. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16078. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16079. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16080. #region 页面操作权限验证
  16081. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16082. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16083. #endregion
  16084. #endregion
  16085. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16086. if (viewData.Code != 0)
  16087. {
  16088. return Ok(JsonView(false, viewData.Msg));
  16089. }
  16090. return Ok(JsonView(viewData.Data));
  16091. }
  16092. /// <summary>
  16093. /// 接团客户名单
  16094. /// 基础数据 Init
  16095. /// </summary>
  16096. /// <param name="_dto"></param>
  16097. /// <returns></returns>
  16098. [HttpPost]
  16099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16100. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16101. {
  16102. #region 参数验证
  16103. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16104. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16105. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16106. #region 页面操作权限验证
  16107. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16108. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16109. #endregion
  16110. #endregion
  16111. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16112. }
  16113. /// <summary>
  16114. /// 接团客户名单
  16115. /// 根据 Id查询 Details
  16116. /// </summary>
  16117. /// <param name="_dto"></param>
  16118. /// <returns></returns>
  16119. [HttpPost]
  16120. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16121. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16122. {
  16123. #region 参数验证
  16124. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16125. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16126. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16127. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16128. #region 页面操作权限验证
  16129. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16130. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16131. #endregion
  16132. #endregion
  16133. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16134. if (viewData.Code != 0)
  16135. {
  16136. return Ok(JsonView(false, viewData.Msg));
  16137. }
  16138. return Ok(JsonView(viewData.Data));
  16139. }
  16140. /// <summary>
  16141. /// 接团客户名单
  16142. /// Add Or Edit
  16143. /// </summary>
  16144. /// <param name="_dto"></param>
  16145. /// <returns></returns>
  16146. [HttpPost]
  16147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16148. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16149. {
  16150. #region 参数验证
  16151. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16152. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16153. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16154. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16155. #region 页面操作权限验证
  16156. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16157. if (_dto.Id == 0) //添加
  16158. {
  16159. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16160. }
  16161. else if (_dto.Id >= 0) //修改
  16162. {
  16163. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16164. }
  16165. #endregion
  16166. #endregion
  16167. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16168. if (viewData.Code != 0)
  16169. {
  16170. return Ok(JsonView(false, viewData.Msg));
  16171. }
  16172. return Ok(JsonView(true));
  16173. }
  16174. /// <summary>
  16175. /// 接团客户名单
  16176. /// json字符串 AddMultiple(添加多个)
  16177. /// </summary>
  16178. /// <param name="_dto"></param>
  16179. /// <returns></returns>
  16180. [HttpPost]
  16181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16182. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16183. {
  16184. #region 参数验证
  16185. string jsonLabel = _dto.JsonLabel;
  16186. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16187. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16188. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16189. #region 页面操作权限验证
  16190. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16191. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16192. #endregion
  16193. #endregion
  16194. var request = new TourClientListAddMultipleDto();
  16195. request.DiId = _dto.DiId;
  16196. request.UserId = _dto.UserId;
  16197. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16198. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16199. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16200. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16201. var infos = new List<TourClientListInfo>();
  16202. foreach (var data in datas)
  16203. {
  16204. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16205. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16206. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16207. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16208. {
  16209. continue;
  16210. }
  16211. infos.Add(new TourClientListInfo()
  16212. {
  16213. IsAccompany = 1,
  16214. LastName = lastName,
  16215. FirstName = firstName,
  16216. Pinyin = lastNameEn + @"/" + firstNameEn,
  16217. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16218. CompanyFullName = data.CompanyFullName,
  16219. Job = data.Job
  16220. });
  16221. }
  16222. if (infos.Any())
  16223. {
  16224. var viewData = await _tourClientListRep._AddMultiple(request);
  16225. if (viewData.Code != 0)
  16226. {
  16227. return Ok(JsonView(false, viewData.Msg));
  16228. }
  16229. return Ok(JsonView(true));
  16230. }
  16231. return Ok(JsonView(false));
  16232. }
  16233. /// <summary>
  16234. /// 接团客户名单
  16235. /// AddMultiple(添加多个)
  16236. /// </summary>
  16237. /// <param name="_dto"></param>
  16238. /// <returns></returns>
  16239. [HttpPost]
  16240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16241. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16242. {
  16243. #region 参数验证
  16244. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16245. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16246. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16247. #region 页面操作权限验证
  16248. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16249. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16250. #endregion
  16251. #endregion
  16252. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16253. if (viewData.Code != 0)
  16254. {
  16255. return Ok(JsonView(false, viewData.Msg));
  16256. }
  16257. return Ok(JsonView(true));
  16258. }
  16259. /// <summary>
  16260. /// 接团客户名单
  16261. /// Del
  16262. /// </summary>
  16263. /// <param name="_dto"></param>
  16264. /// <returns></returns>
  16265. [HttpPost]
  16266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16267. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16268. {
  16269. #region 参数验证
  16270. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16271. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16272. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16273. #region 页面操作权限验证
  16274. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16275. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16276. #endregion
  16277. #endregion
  16278. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16279. if (viewData.Code != 0)
  16280. {
  16281. return Ok(JsonView(false, viewData.Msg));
  16282. }
  16283. return Ok(JsonView(true));
  16284. }
  16285. /// <summary>
  16286. /// 接团客户名单
  16287. /// 文件下载 客户名单
  16288. /// </summary>
  16289. /// <param name="_dto"></param>
  16290. /// <returns></returns>
  16291. [HttpPost]
  16292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16293. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16294. {
  16295. #region 参数验证
  16296. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16297. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16298. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16299. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16300. #region 页面操作权限验证
  16301. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16302. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16303. #endregion
  16304. #endregion
  16305. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16306. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16307. From Grp_TourClientList tcl
  16308. Left Join
  16309. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16310. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16311. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16312. From Crm_DeleClient dc
  16313. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16314. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16315. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16316. Where dc.IsDel = 0) temp
  16317. On temp.DcId =tcl.ClientId
  16318. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16319. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16320. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16321. //载入模板
  16322. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16323. if (_dto.Language == 1)
  16324. {
  16325. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16326. }
  16327. //载入模板
  16328. var doc = new Document(tempPath);
  16329. DocumentBuilder builder = new DocumentBuilder(doc);
  16330. //获取word里所有表格
  16331. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16332. //获取所填表格的序数
  16333. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16334. var rowStart = tableOne.Rows[0]; //获取第1行
  16335. if (_dto.Language == 0)
  16336. {
  16337. //循环赋值
  16338. for (int i = 0; i < DcList.Count; i++)
  16339. {
  16340. EncryptionProcessor.DecryptProperties(DcList[i]);
  16341. builder.MoveToCell(0, i + 1, 0, 0);
  16342. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16343. builder.MoveToCell(0, i + 1, 1, 0);
  16344. int sex = DcList[i].Sex;
  16345. string sexStr = string.Empty;
  16346. if (sex == 0) sexStr = "男";
  16347. else if (sex == 1) sexStr = "女";
  16348. else sexStr = "未设置";
  16349. builder.Write(sexStr);
  16350. builder.MoveToCell(0, i + 1, 2, 0);
  16351. string birthDay = DcList[i].BirthDay;
  16352. string birthDayStr = string.Empty;
  16353. if (!string.IsNullOrEmpty(birthDay))
  16354. {
  16355. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16356. }
  16357. builder.Write(birthDayStr);
  16358. builder.MoveToCell(0, i + 1, 3, 0);
  16359. string company = "";
  16360. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16361. {
  16362. company = DcList[i].CompanyFullName.ToString();
  16363. }
  16364. builder.Write(company);
  16365. builder.MoveToCell(0, i + 1, 4, 0);
  16366. builder.Write(DcList[i].Job);
  16367. }
  16368. }
  16369. else if (_dto.Language == 1)
  16370. {
  16371. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16372. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16373. List<string> transArrayStr = new List<string>();
  16374. string transStrRes1 = "";
  16375. for (int i = 0; i < DcList.Count; i++)
  16376. {
  16377. var dc = DcList[i];
  16378. EncryptionProcessor.DecryptProperties(dc);
  16379. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16380. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16381. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16382. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16383. else transStrRes1 += $"{str1}|";
  16384. }
  16385. //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";
  16386. string transStrRes = "";
  16387. if (transStrRes1.Length > 0)
  16388. {
  16389. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16390. }
  16391. //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
  16392. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16393. //List<string> transArray = new List<string> { };
  16394. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16395. if (transStrRes.Contains("|"))
  16396. {
  16397. string[] transArray1 = transStrRes.Split('|');
  16398. if (transArray1.Length > 0)
  16399. {
  16400. foreach (var item in transArray1)
  16401. {
  16402. if (item.Contains("&"))
  16403. {
  16404. string[] transArray2 = item.Split('&');
  16405. int index = 0;
  16406. string companyName = "", job = "";
  16407. if (transArray2.Length > 0)
  16408. {
  16409. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16410. if (1 < transArray2.Length) companyName = transArray2[1];
  16411. if (2 < transArray2.Length) job = transArray2[2];
  16412. }
  16413. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16414. }
  16415. }
  16416. }
  16417. }
  16418. //循环赋值
  16419. for (int i = 0; i < DcList.Count; i++)
  16420. {
  16421. string PYName = "";
  16422. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16423. {
  16424. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16425. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16426. PYName = PY_First + " " + PY_Last;
  16427. }
  16428. else
  16429. {
  16430. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16431. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16432. PYName = PY_First + " " + PY_Last;
  16433. }
  16434. builder.MoveToCell(0, i + 1, 0, 0);
  16435. builder.Write(PYName);
  16436. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16437. builder.MoveToCell(0, i + 1, 1, 0);
  16438. builder.Write(sex);
  16439. DateTime birthDt;
  16440. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16441. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16442. builder.MoveToCell(0, i + 1, 2, 0);
  16443. builder.Write(birthday);
  16444. string company = string.Empty, job = string.Empty;
  16445. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16446. if (dcTransInfo != null)
  16447. {
  16448. company = dcTransInfo.CompanyName;
  16449. job = dcTransInfo.Job;
  16450. }
  16451. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16452. {
  16453. //查询对照表
  16454. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16455. if (tempCec != null)
  16456. {
  16457. company = tempCec.enName;
  16458. }
  16459. //翻译
  16460. else
  16461. {
  16462. }
  16463. }
  16464. builder.MoveToCell(0, i + 1, 3, 0);
  16465. builder.Write(company);
  16466. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16467. {
  16468. //查询对照表
  16469. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16470. if (tempPec != null)
  16471. {
  16472. job = tempPec.enName;
  16473. }
  16474. //翻译
  16475. else
  16476. {
  16477. }
  16478. }
  16479. builder.MoveToCell(0, i + 1, 4, 0);
  16480. builder.Write(job);
  16481. }
  16482. }
  16483. //删除多余行
  16484. while (tableOne.Rows.Count > DcList.Count + 1)
  16485. {
  16486. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16487. }
  16488. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16489. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16490. doc.Save(fileDir);
  16491. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16492. return Ok(JsonView(true, "操作成功!", Url));
  16493. }
  16494. private class TranslateInfo
  16495. {
  16496. public int Index { get; set; }
  16497. public string CompanyName { get; set; }
  16498. public string Job { get; set; }
  16499. }
  16500. #endregion
  16501. #region 团组倒推表
  16502. /// <summary>
  16503. /// 倒推表基础数据
  16504. /// Init
  16505. /// </summary>
  16506. /// <returns></returns>
  16507. [HttpPost]
  16508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16509. public async Task<IActionResult> PostInvertedListInit()
  16510. {
  16511. var viewData = await _invertedListRep._Init();
  16512. if (viewData.Code != 0)
  16513. {
  16514. return Ok(JsonView(false, viewData.Msg));
  16515. }
  16516. return Ok(JsonView(viewData.Data));
  16517. }
  16518. /// <summary>
  16519. /// 倒推表
  16520. /// Info
  16521. /// </summary>
  16522. /// <param name="dto"></param>
  16523. /// <returns></returns>
  16524. [HttpPost]
  16525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16526. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16527. {
  16528. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16529. if (viewData.Code != 0)
  16530. {
  16531. return Ok(JsonView(false, viewData.Msg));
  16532. }
  16533. return Ok(JsonView(viewData.Data));
  16534. }
  16535. /// <summary>
  16536. /// 倒推表
  16537. /// Create
  16538. /// </summary>
  16539. /// <param name="dto"></param>
  16540. /// <returns></returns>
  16541. [HttpPost]
  16542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16543. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16544. {
  16545. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16546. if (viewData.Code != 0)
  16547. {
  16548. return Ok(JsonView(false, viewData.Msg));
  16549. }
  16550. return Ok(JsonView(viewData.Data));
  16551. }
  16552. /// <summary>
  16553. /// 倒推表
  16554. /// Update
  16555. /// </summary>
  16556. /// <param name="dto"></param>
  16557. /// <returns></returns>
  16558. [HttpPost]
  16559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16560. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16561. {
  16562. var viewData = await _invertedListRep._Update(dto);
  16563. if (viewData.Code != 0)
  16564. {
  16565. return Ok(JsonView(false, viewData.Msg));
  16566. }
  16567. return Ok(JsonView(viewData.Data));
  16568. }
  16569. /// <summary>
  16570. /// 倒推表
  16571. /// File Download
  16572. /// </summary>
  16573. /// <param name="dto"></param>
  16574. /// <returns></returns>
  16575. [HttpPost]
  16576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16577. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16578. {
  16579. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16580. if (info2.Code != 0)
  16581. {
  16582. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16583. }
  16584. var info1 = info2.Data as InvertedListInfoView;
  16585. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16586. string teamName = "";
  16587. if (info != null) teamName = info.TeamName;
  16588. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  16589. var doc = new Document();
  16590. var builder = new DocumentBuilder(doc);
  16591. #region old insert
  16592. ////载入模板
  16593. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  16594. //Document doc = new Document(tempPath);
  16595. //DocumentBuilder builder = new DocumentBuilder(doc);
  16596. //利用键值对存放数据
  16597. //Dictionary<string, string> dic = new Dictionary<string, string>();
  16598. //dic.Add("TeamName", teamName);
  16599. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16600. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16601. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  16602. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16603. //dic.Add("SQRemark", info1.ApprovalRemark);
  16604. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16605. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16606. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16607. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  16608. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16609. //dic.Add("QZRemark", info1.VisaInformationRemark);
  16610. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16611. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  16612. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16613. //dic.Add("CQRemark", info1.IssueVisaRemark);
  16614. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16615. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16616. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16617. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16618. //#region 填充word模板书签内容
  16619. //foreach (var key in dic.Keys)
  16620. //{
  16621. // builder.MoveToBookmark(key);
  16622. // builder.Write(dic[key]);
  16623. //}
  16624. //#endregion
  16625. #endregion
  16626. #region New Insert
  16627. string titleFont = $"仿宋",
  16628. contentFont = $"仿宋";
  16629. var fontColor = Color.FromArgb(64, 64, 64);
  16630. //设置标题 团组名称
  16631. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16632. builder.Font.Name = titleFont;
  16633. builder.Font.Color = fontColor;
  16634. builder.Font.Size = 12;
  16635. builder.Font.Bold = true;
  16636. builder.Writeln(teamName);
  16637. //设置副标题 团组出访时间
  16638. builder.Font.Size = 12;
  16639. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  16640. builder.Writeln();
  16641. var backgroundColor = Color.FromArgb(199, 199, 199);
  16642. var table = builder.StartTable();
  16643. builder.InsertCell();
  16644. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  16645. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  16646. builder.CellFormat.Borders.LineWidth = 1;
  16647. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  16648. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  16649. builder.RowFormat.Height = 40;
  16650. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16651. builder.Font.Name = contentFont;
  16652. builder.Font.Size = 12;
  16653. builder.Font.Bold = true;
  16654. builder.Font.Color = fontColor;
  16655. builder.Write("时间");
  16656. builder.InsertCell();
  16657. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  16658. builder.Write("流程");
  16659. builder.InsertCell();
  16660. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  16661. builder.Write("说明");
  16662. builder.EndRow();
  16663. //报批资料准备
  16664. if (info1.IsSelectedAirportd)
  16665. {
  16666. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  16667. }
  16668. //报批/提供送签资料
  16669. if (info1.IsSelectedApprovalData)
  16670. {
  16671. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  16672. }
  16673. //出批件护照办理
  16674. if (info1.IsSelectedIssueApproval)
  16675. {
  16676. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  16677. }
  16678. //签证资料准备
  16679. if (info1.IsSelectedVisaInfo)
  16680. {
  16681. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  16682. }
  16683. //送签
  16684. if (info1.IsSelectedSendVisa)
  16685. {
  16686. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  16687. }
  16688. //出签
  16689. if (info1.IsSelectedIssueVisa)
  16690. {
  16691. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  16692. }
  16693. //机票
  16694. if (info1.IsSelectedAirTicket)
  16695. {
  16696. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  16697. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  16698. }
  16699. //酒店
  16700. if (info1.IsSelectedHotel)
  16701. {
  16702. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  16703. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  16704. }
  16705. //开行前会
  16706. if (info1.IsSelectedPreTripMeeting)
  16707. {
  16708. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  16709. }
  16710. //送机
  16711. if (info1.IsSelectedAirportdDropOff)
  16712. {
  16713. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  16714. }
  16715. builder.EndTable();
  16716. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  16717. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  16718. for (int i = 0; i < table.Rows.Count; i++)
  16719. {
  16720. var row = table.Rows[i];
  16721. //设置宽度
  16722. row.Cells[0].CellFormat.Width = 20.00;
  16723. row.Cells[1].CellFormat.Width = 30.00;
  16724. row.Cells[2].CellFormat.Width = 50.00;
  16725. if (i != 0)
  16726. {
  16727. //边框设置
  16728. InvertedListFileDownloadSetBorders(row.Cells, 0);
  16729. InvertedListFileDownloadSetBorders(row.Cells, 1);
  16730. InvertedListFileDownloadSetBorders(row.Cells, 2);
  16731. }
  16732. }
  16733. #region 页脚插入图片
  16734. // 创建页脚
  16735. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  16736. doc.FirstSection.HeadersFooters.Add(footer);
  16737. Paragraph para = new Paragraph(doc);
  16738. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  16739. footer.AppendChild(para);
  16740. builder.MoveTo(para);
  16741. string imagePath = "./Images/FMGJ_Log.png";
  16742. builder.InsertImage(imagePath);
  16743. #endregion
  16744. #endregion
  16745. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16746. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  16747. string filePath = fileDir + $@"InvertedList/{fileName}";
  16748. doc.Save(filePath);
  16749. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16750. return Ok(JsonView(true, "操作成功!", Url));
  16751. }
  16752. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  16753. {
  16754. var fontColor = Color.FromArgb(64, 64, 64);
  16755. builder.InsertCell();
  16756. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  16757. builder.RowFormat.Height = 40;
  16758. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16759. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16760. builder.Font.Name = fontName;
  16761. builder.Font.Size = 8;
  16762. builder.Font.Bold = true;
  16763. builder.Font.Color = fontColor;
  16764. builder.Write(dateTime);
  16765. builder.InsertCell();
  16766. builder.Font.Size = 9;
  16767. builder.Font.Bold = true;
  16768. builder.Font.Color = fontColor;
  16769. builder.Write(content);
  16770. builder.InsertCell();
  16771. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16772. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16773. builder.Font.Size = 9;
  16774. builder.Font.Bold = false;
  16775. builder.Font.Color = fontColor;
  16776. builder.Write(reamrk);
  16777. builder.EndRow();
  16778. }
  16779. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  16780. {
  16781. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  16782. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  16783. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  16784. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  16785. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  16786. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  16787. }
  16788. #endregion
  16789. #region 会务倒推表
  16790. /// <summary>
  16791. /// 会务倒推表
  16792. /// Init
  16793. /// </summary>
  16794. /// <returns></returns>
  16795. [HttpPost]
  16796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16797. public async Task<IActionResult> InforRetrogressTableInit()
  16798. {
  16799. var groupData = await _groupRepository.PostShareGroupInfos(1);
  16800. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  16801. return Ok(JsonView(false, groupData.Msg));
  16802. }
  16803. /// <summary>
  16804. /// 会务倒推表
  16805. /// ExcelDownload
  16806. /// </summary>
  16807. /// <param name="dto"></param>
  16808. /// <returns></returns>
  16809. [HttpPost]
  16810. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  16811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16812. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  16813. {
  16814. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  16815. var validatorRes = await validator.ValidateAsync(dto);
  16816. if (!validatorRes.IsValid)
  16817. {
  16818. StringBuilder sb = new StringBuilder();
  16819. foreach (var item in validatorRes.Errors)
  16820. {
  16821. sb.AppendLine(item.ErrorMessage);
  16822. }
  16823. return Ok(JsonView(false, sb.ToString()));
  16824. }
  16825. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  16826. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  16827. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  16828. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  16829. #region Excel
  16830. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  16831. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  16832. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  16833. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  16834. var fileNamePrefix = string.Empty;
  16835. if (days >= 30)
  16836. {
  16837. tempPath += $"会务工作倒推进度表(30天).xlsx";
  16838. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  16839. }
  16840. else if (days < 30 && days > 7)
  16841. {
  16842. tempPath += $"会务工作倒推进度表(15天).xlsx";
  16843. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  16844. }
  16845. else if (days <= 7)
  16846. {
  16847. tempPath += $"会务工作倒推进度表(7天).xlsx";
  16848. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  16849. }
  16850. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  16851. fileName = CommonFun.ValidFileName(fileName);
  16852. //载入模板
  16853. WorkbookDesigner designer = new WorkbookDesigner();
  16854. designer.Workbook = new Workbook(tempPath);
  16855. designer.Process();
  16856. if (!Directory.Exists(savePath))
  16857. {
  16858. Directory.CreateDirectory(savePath);
  16859. }
  16860. string serverPath = $"{savePath}{fileName}";
  16861. designer.Workbook.Save(serverPath);
  16862. string rst = $"{servicePath}{ftpPath}{fileName}";
  16863. #endregion
  16864. return Ok(JsonView(new { url = rst }));
  16865. }
  16866. #endregion
  16867. #region 三公签证费用(签证费、代办费)
  16868. /// <summary>
  16869. /// 三公签证费用(签证费、代办费)
  16870. /// List
  16871. /// </summary>
  16872. /// <returns></returns>
  16873. [HttpPost]
  16874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16875. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16876. {
  16877. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16878. if (_view.Code != 0)
  16879. {
  16880. return Ok(JsonView(false, _view.Msg));
  16881. }
  16882. return Ok(JsonView(true, "操作成功!", _view.Data));
  16883. }
  16884. /// <summary>
  16885. /// 三公签证费用(签证费、代办费)
  16886. /// Add Or Update
  16887. /// </summary>
  16888. /// <returns></returns>
  16889. [HttpPost]
  16890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16891. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16892. {
  16893. var _view = await _visaFeeInfoRep._Update(_dto);
  16894. if (_view.Code != 0)
  16895. {
  16896. return Ok(JsonView(false, _view.Msg));
  16897. }
  16898. return Ok(JsonView(true, _view.Msg));
  16899. }
  16900. #endregion
  16901. #region 酒店询价
  16902. /// <summary>
  16903. /// 酒店询价
  16904. /// Init
  16905. /// </summary>
  16906. /// <returns></returns>
  16907. [HttpPost]
  16908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16909. public async Task<IActionResult> PostHotelInquiryInit()
  16910. {
  16911. var res = await _hotelInquiryRep._Init();
  16912. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16913. return Ok(JsonView(true, res.Msg, res.Data));
  16914. }
  16915. /// <summary>
  16916. /// 酒店询价
  16917. /// page Item
  16918. /// </summary>
  16919. /// <param name="_dto"></param>
  16920. /// <returns></returns>
  16921. [HttpPost]
  16922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16923. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16924. {
  16925. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16926. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16927. var view = res.Data as PageDataViewBase;
  16928. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16929. }
  16930. /// <summary>
  16931. /// 酒店询价
  16932. /// info
  16933. /// </summary>
  16934. /// <param name="_dto"></param>
  16935. /// <returns></returns>
  16936. [HttpPost]
  16937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16938. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16939. {
  16940. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16941. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16942. return Ok(JsonView(true, res.Msg, res.Data));
  16943. }
  16944. /// <summary>
  16945. /// 酒店询价
  16946. /// Add Or Edit
  16947. /// </summary>
  16948. /// <param name="_dto"></param>
  16949. /// <returns></returns>
  16950. [HttpPost]
  16951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16952. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16953. {
  16954. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16955. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16956. return Ok(JsonView(true, res.Msg, res.Data));
  16957. }
  16958. /// <summary>
  16959. /// 酒店询价
  16960. /// Del
  16961. /// </summary>
  16962. /// <param name="_dto"></param>
  16963. /// <returns></returns>
  16964. [HttpPost]
  16965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16966. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16967. {
  16968. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16969. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16970. return Ok(JsonView(true, res.Msg, res.Data));
  16971. }
  16972. #endregion
  16973. #region 下载匹配op行程单
  16974. /// <summary>
  16975. /// 匹配op行程单
  16976. /// Init
  16977. /// </summary>
  16978. /// <param name="dto">团组列表请求dto</param>
  16979. /// <returns></returns>
  16980. [HttpPost]
  16981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16982. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16983. {
  16984. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16985. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16986. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16987. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16988. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16989. .Where(it => it.IsDel == 0)
  16990. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16991. .OrderByDescending(it => it.CreateUserId)
  16992. .ToList();
  16993. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16994. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16995. var diids = groupInfos.Select(it => it.Id).ToList();
  16996. List<string> countrys = new List<string>();
  16997. foreach (var item in country)
  16998. {
  16999. var data = _groupRepository.FormartTeamName(item);
  17000. var dataArray = _groupRepository.GroupSplitCountry(data);
  17001. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17002. }
  17003. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17004. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17005. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17006. foreach (var item in areaItem)
  17007. {
  17008. string areaStr = item.Value;
  17009. if (!string.IsNullOrEmpty(areaStr))
  17010. {
  17011. string[] str1 = areaStr.Split("-");
  17012. if (str1.Length > 0)
  17013. {
  17014. areaArray.AddRange(str1);
  17015. }
  17016. }
  17017. }
  17018. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17019. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17020. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17021. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17022. .ToList();
  17023. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17024. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17025. .Where(it => countriesIds.Contains(it.Id))
  17026. .Select(it => new { it.Id, Name = it.Name_CN })
  17027. .ToList();
  17028. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17029. .Select(it => it.TeamName).ToList();
  17030. stopwatch.Stop();
  17031. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17032. }
  17033. ///// <summary>
  17034. ///// 匹配op行程单
  17035. ///// Init 查询区域数据
  17036. ///// </summary>
  17037. ///// <param name="dto">团组列表请求dto</param>
  17038. ///// <returns></returns>
  17039. //[HttpPost]
  17040. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17041. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17042. //{
  17043. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17044. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17045. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17046. // if (string.IsNullOrEmpty(countriesDataStr))
  17047. // {
  17048. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17049. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17050. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17051. // }
  17052. // else
  17053. // {
  17054. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17055. // }
  17056. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17057. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17058. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17059. // List<dynamic> childList = new List<dynamic>();
  17060. // int parentId = dto.CountriesId;
  17061. // if (provinceData.Count > 1)
  17062. // {
  17063. // foreach (var item1 in provinceData)
  17064. // {
  17065. // List<dynamic> childList1 = new List<dynamic>();
  17066. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17067. // foreach (var item2 in citiesData1)
  17068. // {
  17069. // List<dynamic> childList2 = new List<dynamic>();
  17070. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17071. // foreach (var item3 in countiesData1)
  17072. // {
  17073. // childList2.Add(new
  17074. // {
  17075. // id = item3.Id,
  17076. // parentId = item2.Id,
  17077. // level = "district",
  17078. // name = item3.Name_CN,
  17079. // });
  17080. // }
  17081. // childList1.Add(new
  17082. // {
  17083. // id = item2.Id,
  17084. // parentId = item1.Id,
  17085. // level = "city",
  17086. // name = item2.Name_CN,
  17087. // childList = childList2
  17088. // });
  17089. // }
  17090. // childList.Add(new
  17091. // {
  17092. // id = item1.Id,
  17093. // parentId = parentId,
  17094. // level = "province",
  17095. // name = item1.Name_CN,
  17096. // childList = childList1
  17097. // });
  17098. // }
  17099. // //城市
  17100. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17101. // foreach (var item2 in citiesData2)
  17102. // {
  17103. // List<dynamic> childList22 = new List<dynamic>();
  17104. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17105. // foreach (var item3 in countiesData1)
  17106. // {
  17107. // childList22.Add(new
  17108. // {
  17109. // id = item3.Id,
  17110. // parentId = item2.Id,
  17111. // level = "district",
  17112. // name = item3.Name_CN,
  17113. // });
  17114. // }
  17115. // childList.Add(new
  17116. // {
  17117. // id = item2.Id,
  17118. // parentId = parentId,
  17119. // level = "city",
  17120. // name = item2.Name_CN,
  17121. // childList = childList22
  17122. // });
  17123. // }
  17124. // }
  17125. // else
  17126. // {
  17127. // foreach (var item2 in citiesData)
  17128. // {
  17129. // string cname = item2.Name_CN;
  17130. // List<dynamic> childList1 = new List<dynamic>();
  17131. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17132. // foreach (var item3 in countiesData1)
  17133. // {
  17134. // childList1.Add(new
  17135. // {
  17136. // Id = item3.Id,
  17137. // parentId = item2.Id,
  17138. // level = "district",
  17139. // name = item3.Name_CN
  17140. // });
  17141. // }
  17142. // childList.Add(new
  17143. // {
  17144. // id = item2.Id,
  17145. // parentId = parentId,
  17146. // level = "city",
  17147. // name = item2.Name_CN,
  17148. // childList = childList1
  17149. // });
  17150. // }
  17151. // }
  17152. // stopwatch.Stop();
  17153. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17154. //}
  17155. /// <summary>
  17156. /// 匹配op行程单
  17157. /// 接团信息列表 Page
  17158. /// </summary>
  17159. /// <param name="dto">团组列表请求dto</param>
  17160. /// <returns></returns>
  17161. [HttpPost]
  17162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17163. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17164. {
  17165. var swatch = new Stopwatch();
  17166. swatch.Start();
  17167. #region 参数验证
  17168. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17169. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17170. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17171. #region 页面操作权限验证
  17172. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17173. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17174. #endregion
  17175. #endregion
  17176. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17177. {
  17178. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17179. //string sqlWhere = "";
  17180. if (!string.IsNullOrEmpty(dto.Country))
  17181. {
  17182. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17183. }
  17184. if (!string.IsNullOrEmpty(dto.Area))
  17185. {
  17186. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17187. }
  17188. if (!string.IsNullOrEmpty(dto.TeamName))
  17189. {
  17190. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17191. }
  17192. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17193. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17194. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17195. swatch.Stop();
  17196. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17197. }
  17198. else
  17199. {
  17200. return Ok(JsonView(false, "查询失败"));
  17201. }
  17202. }
  17203. /// <summary>
  17204. /// 匹配op行程单
  17205. /// 行程单下载
  17206. /// </summary>
  17207. /// <param name="dto">团组列表请求dto</param>
  17208. /// <returns></returns>
  17209. [HttpPost]
  17210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17211. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17212. {
  17213. #region 参数验证
  17214. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17215. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17216. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17217. #region 页面操作权限验证
  17218. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17219. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17220. #endregion
  17221. #endregion
  17222. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17223. {
  17224. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17225. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17226. }
  17227. else
  17228. {
  17229. return Ok(JsonView(false, "下载失败!"));
  17230. }
  17231. }
  17232. #endregion
  17233. #region 国家信息 数据 注释
  17234. //[HttpPost]
  17235. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17236. //{
  17237. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17238. // foreach (var item in dto)
  17239. // {
  17240. // infos.Add(new Grp_GroupsTaskAssignment()
  17241. // {
  17242. // DIId = item,
  17243. // CTId = 82,
  17244. // UId = 248,
  17245. // IsEnable = 1,
  17246. // CreateUserId = 233,
  17247. // CreateTime = DateTime.Now,
  17248. // IsDel = 0
  17249. // });
  17250. // infos.Add(new Grp_GroupsTaskAssignment()
  17251. // {
  17252. // DIId = item,
  17253. // CTId = 82,
  17254. // UId = 286,
  17255. // IsEnable = 1,
  17256. // CreateUserId = 233,
  17257. // CreateTime = DateTime.Now,
  17258. // IsDel = 0
  17259. // });
  17260. // }
  17261. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17262. // return Ok("操作成功");
  17263. //}
  17264. //public class paramJsonDto
  17265. //{
  17266. // public List<CountriesInfo> str { get; set; }
  17267. //}
  17268. //[HttpPost]
  17269. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17270. //{
  17271. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17272. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17273. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17274. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17275. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17276. // _sqlSugar.BeginTran();
  17277. // int countitiesIndex = 0;
  17278. // foreach (var item in dto.str)
  17279. // {
  17280. // dynamic data = item.c;
  17281. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17282. // if (data != null)
  17283. // {
  17284. // countitiesIndex++;
  17285. // foreach (var item1 in data)
  17286. // {
  17287. // string cnname = item1.cn;
  17288. // string enname = item1.en;
  17289. // Sys_Cities provinceInfo = new Sys_Cities()
  17290. // {
  17291. // CountriesId = countriesId,
  17292. // Name_CN = cnname,
  17293. // Name_EN = enname,
  17294. // ParentId = 0,
  17295. // IsCapital = 1,
  17296. // CreateUserId = 208,
  17297. // CreateTime = DateTime.Now,
  17298. // IsDel = 0
  17299. // };
  17300. // if (item1.lv == "province") //省份
  17301. // {
  17302. // provinceInfo.Level = 1;
  17303. // int provinceId = 0;
  17304. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17305. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17306. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17307. // var data1 = item1.c;
  17308. // foreach (var item2 in data1)
  17309. // {
  17310. // if (item2.lv == "city")
  17311. // {
  17312. // string citycnname = item2.cn;
  17313. // string cityenname = item2.en;
  17314. // Sys_Cities cityInfo = new Sys_Cities()
  17315. // {
  17316. // CountriesId = countriesId,
  17317. // ParentId = provinceId,
  17318. // Level = 2,
  17319. // Name_CN = citycnname,
  17320. // Name_EN = cityenname,
  17321. // IsCapital = 1,
  17322. // CreateUserId = 208,
  17323. // CreateTime = DateTime.Now,
  17324. // IsDel = 0
  17325. // };
  17326. // if (item2.c != null)
  17327. // {
  17328. // int cityId = 0;
  17329. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17330. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17331. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17332. // foreach (var item3 in item2.c)
  17333. // {
  17334. // if (item3.lv == "district")
  17335. // {
  17336. // var districtInfo = new Sys_Cities()
  17337. // {
  17338. // CountriesId = countriesId,
  17339. // Name_CN = item3.cn,
  17340. // Name_EN = item3.en,
  17341. // Level = 3,
  17342. // ParentId = cityId,
  17343. // IsCapital = 1,
  17344. // CreateUserId = 208,
  17345. // CreateTime = DateTime.Now,
  17346. // IsDel = 0
  17347. // };
  17348. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17349. // //{
  17350. // districts.Add(districtInfo);
  17351. // //}
  17352. // }
  17353. // }
  17354. // }
  17355. // else
  17356. // {
  17357. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17358. // //{
  17359. // cities.Add(cityInfo);
  17360. // //}
  17361. // }
  17362. // }
  17363. // }
  17364. // }
  17365. // else if (item1.lv == "city")//城市
  17366. // {
  17367. // provinceInfo.Level = 2;
  17368. // if (item1.c != null)
  17369. // {
  17370. // int cityId = 0;
  17371. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17372. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17373. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17374. // foreach (var item3 in item1.c)
  17375. // {
  17376. // if (item3.lv == "district")
  17377. // {
  17378. // var districtInfo = new Sys_Cities()
  17379. // {
  17380. // CountriesId = countriesId,
  17381. // Name_CN = item3.cn,
  17382. // Name_EN = item3.en,
  17383. // Level = 3,
  17384. // ParentId = cityId,
  17385. // IsCapital = 1,
  17386. // CreateUserId = 208,
  17387. // CreateTime = DateTime.Now,
  17388. // IsDel = 0
  17389. // };
  17390. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17391. // //{
  17392. // districts.Add(districtInfo);
  17393. // //}
  17394. // }
  17395. // }
  17396. // }
  17397. // else
  17398. // {
  17399. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17400. // //{
  17401. // cities.Add(provinceInfo);
  17402. // //}
  17403. // }
  17404. // }
  17405. // }
  17406. // }
  17407. // }
  17408. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17409. // cities = cities.Distinct().ToList();
  17410. // districts = districts.Distinct().ToList();
  17411. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17412. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17413. // cities.AddRange(districts);
  17414. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17415. // //_sqlSugar.RollbackTran();
  17416. // _sqlSugar.CommitTran();
  17417. // return Ok(JsonView(false, "操作成功!"));
  17418. //}
  17419. //[HttpPost]
  17420. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17421. //{
  17422. // List<CountitiesInfo> infos = dto.MyProperty;
  17423. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17424. // _sqlSugar.BeginTran();
  17425. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17426. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17427. // foreach (var item in infos)
  17428. // {
  17429. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17430. // if (countryInfo != null)
  17431. // {
  17432. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17433. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17434. // if (cityInfo1 != null)
  17435. // {
  17436. // cityInfo1.IsCapital = 0;
  17437. // cityInfos.Add(cityInfo1);
  17438. // }
  17439. // }
  17440. // }
  17441. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17442. // .UpdateColumns(it => it.IsCapital)
  17443. // .WhereColumns(it => it.Id)
  17444. // .ExecuteCommand();
  17445. // //_sqlSugar.RollbackTran();
  17446. // _sqlSugar.CommitTran();
  17447. // return Ok(JsonView(false, "操作成功!"));
  17448. //}
  17449. //public class CounrtiesDto
  17450. //{
  17451. // public List<CountitiesInfo> MyProperty { get; set; }
  17452. //}
  17453. //public class CountitiesInfo
  17454. //{
  17455. // /// <summary>
  17456. // /// 圣约翰
  17457. // /// </summary>
  17458. // public string capital_name_chinese { get; set; }
  17459. // /// <summary>
  17460. // ///
  17461. // /// </summary>
  17462. // public string capital_name { get; set; }
  17463. // /// <summary>
  17464. // ///
  17465. // /// </summary>
  17466. // public string country_type { get; set; }
  17467. // /// <summary>
  17468. // /// 安提瓜和巴布达
  17469. // /// </summary>
  17470. // public string country_name_chinese { get; set; }
  17471. // /// <summary>
  17472. // /// 安提瓜和巴布达
  17473. // /// </summary>
  17474. // public string country_name_chinese_short { get; set; }
  17475. // /// <summary>
  17476. // /// 安提瓜和巴布达
  17477. // /// </summary>
  17478. // public string country_name_chinese_UN { get; set; }
  17479. // /// <summary>
  17480. // ///
  17481. // /// </summary>
  17482. // public string country_name_english_abbreviation { get; set; }
  17483. // /// <summary>
  17484. // ///
  17485. // /// </summary>
  17486. // public string country_name_english_formal { get; set; }
  17487. // /// <summary>
  17488. // ///
  17489. // /// </summary>
  17490. // public string country_name_english_UN { get; set; }
  17491. // /// <summary>
  17492. // ///
  17493. // /// </summary>
  17494. // public string continent_name { get; set; }
  17495. // /// <summary>
  17496. // ///
  17497. // /// </summary>
  17498. // public string subregion_name { get; set; }
  17499. // /// <summary>
  17500. // ///
  17501. // /// </summary>
  17502. // public string country_code2 { get; set; }
  17503. // /// <summary>
  17504. // ///
  17505. // /// </summary>
  17506. // public string country_code3 { get; set; }
  17507. // /// <summary>
  17508. // ///
  17509. // /// </summary>
  17510. // public string phone_code { get; set; }
  17511. //}
  17512. //public class CountriesInfo : BasicInfo
  17513. //{
  17514. // public List<CitiesInfo> c { get; set; }
  17515. //}
  17516. //public class CitiesInfo : BasicInfo
  17517. //{
  17518. // public List<AreaInfo> c { get; set; }
  17519. //}
  17520. //public class AreaInfo : BasicInfo
  17521. //{
  17522. // public List<AreaInfo> c { get; set; }
  17523. //}
  17524. //public class BasicInfo
  17525. //{
  17526. // public string code { get; set; }
  17527. // public string cn { get; set; }
  17528. // public string lv { get; set; }
  17529. // public string en { get; set; }
  17530. //}
  17531. #endregion
  17532. #region 查看邀请方
  17533. /// <summary>
  17534. /// 查看邀请方
  17535. /// 邀请方信息 Init
  17536. /// </summary>
  17537. /// <param name="dto"></param>
  17538. /// <returns></returns>
  17539. [HttpPost]
  17540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17541. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17542. {
  17543. string sqlWhere = string.Empty;
  17544. if (!string.IsNullOrEmpty(dto.Search))
  17545. {
  17546. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17547. }
  17548. string sql = string.Format($@"Select
  17549. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17550. Id,
  17551. UnitName
  17552. From Res_InvitationOfficialActivityData
  17553. Where IsDel = 0
  17554. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17555. RefAsync<int> total = 0;
  17556. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17557. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17558. }
  17559. /// <summary>
  17560. /// 查看邀请方
  17561. /// 国家信息 Init
  17562. /// </summary>
  17563. /// <param name="dto"></param>
  17564. /// <returns></returns>
  17565. [HttpPost]
  17566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17567. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17568. {
  17569. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17570. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17571. var diids = groupInfos.Select(it => it.Id).ToList();
  17572. List<string> countrys = new List<string>();
  17573. foreach (var item in country)
  17574. {
  17575. var data = _groupRepository.FormartTeamName(item);
  17576. var dataArray = _groupRepository.GroupSplitCountry(data);
  17577. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17578. }
  17579. countrys = countrys.Distinct().ToList();
  17580. for (int i = 0; i < countrys.Count; i++)
  17581. {
  17582. string item = countrys[i];
  17583. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17584. {
  17585. countrys.Remove(item);
  17586. i--;
  17587. }
  17588. }
  17589. RefAsync<int> total = 0;
  17590. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17591. .Where(it => countrys.Contains(it.Name_CN))
  17592. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17593. .Select(it => new { id = it.Id, name = it.Name_CN })
  17594. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17595. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17596. }
  17597. /// <summary>
  17598. /// 查看邀请方
  17599. /// 城市信息 Init
  17600. /// </summary>
  17601. /// <param name="dto"></param>
  17602. /// <returns></returns>
  17603. [HttpPost]
  17604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17605. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17606. {
  17607. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17608. RefAsync<int> total = 0;
  17609. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17610. .Where(it => it.CountriesId == dto.CountiesId)
  17611. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17612. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17613. .Select(it => new { id = it.Id, name = it.Name_CN })
  17614. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17615. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17616. }
  17617. /// <summary>
  17618. /// 查看邀请方
  17619. /// 团组名称 Init
  17620. /// </summary>
  17621. /// <param name="dto"></param>
  17622. /// <returns></returns>
  17623. [HttpPost]
  17624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17625. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17626. {
  17627. var watch = new Stopwatch();
  17628. watch.Start();
  17629. RefAsync<int> total = 0;
  17630. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17631. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17632. .Where((oa, di) => oa.IsDel == 0)
  17633. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17634. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17635. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17636. .Distinct()
  17637. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17638. watch.Stop();
  17639. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17640. }
  17641. /// <summary>
  17642. /// 查看邀请方
  17643. /// 团组 & 邀请方信息
  17644. /// </summary>
  17645. /// <param name="dto"></param>
  17646. /// <returns></returns>
  17647. [HttpPost]
  17648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17649. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17650. {
  17651. var watch = new Stopwatch();
  17652. watch.Start();
  17653. RefAsync<int> total = 0;
  17654. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17655. .AS("Grp_DelegationInfo")
  17656. .Includes(x => x.InvitingInfos)
  17657. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17658. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17659. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17660. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17661. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17662. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17663. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17664. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17665. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17666. infos.ForEach(x =>
  17667. {
  17668. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17669. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17670. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17671. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17672. });
  17673. watch.Stop();
  17674. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17675. }
  17676. #endregion
  17677. #region 报批行程
  17678. /// <summary>
  17679. /// 报批行程初始化
  17680. /// </summary>
  17681. /// <param name="dto"></param>
  17682. /// <returns></returns>
  17683. [HttpPost]
  17684. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17685. {
  17686. const int chiNumber = 5;
  17687. var jw = JsonView(false);
  17688. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17689. var group = groupList.First();
  17690. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17691. group = groupList.First(x => x.Id == diid);
  17692. if (group == null)
  17693. {
  17694. jw.Msg = "暂无团组!";
  17695. return Ok(jw);
  17696. }
  17697. var data = new
  17698. {
  17699. groupList = groupList.Select(x => new
  17700. {
  17701. x.TeamName,
  17702. x.Id
  17703. }),
  17704. content = new ArrayList(),
  17705. groupInfo = new
  17706. {
  17707. group.VisitDays,
  17708. group.TourCode,
  17709. group.VisitPNumber,
  17710. group.TeamName,
  17711. group.Id,
  17712. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17713. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17714. },
  17715. };
  17716. var resultArr = new ArrayList();
  17717. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17718. if (content.Count == 0)
  17719. {
  17720. var stay = "-";
  17721. var cityPath = "-";
  17722. //添加城市路径以及住宿地
  17723. //黑屏代码数据
  17724. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17725. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17726. {
  17727. jw = JsonView(true, "黑屏代码有误!", data);
  17728. return Ok(jw);
  17729. }
  17730. foreach (DataRow row in dtBlack.Rows)
  17731. {
  17732. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17733. {
  17734. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17735. return Ok(jw);
  17736. }
  17737. }
  17738. //黑屏代码获取时间区间
  17739. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17740. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17741. _sqlSugar.BeginTran();
  17742. for (int i = 0; i < timeArr.Count; i++)
  17743. {
  17744. stay = "-";
  17745. cityPath = "-";
  17746. DateTime NewData = DateTime.Parse(timeArr[i]);
  17747. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17748. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17749. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17750. if (tbSelect.Length > 0)
  17751. {
  17752. List<string> threeCodeStr = new List<string>();
  17753. foreach (var item in tbSelect)
  17754. {
  17755. var threeCode = item["Three"].ToString() ?? "";
  17756. if (threeCode.Length == 6)
  17757. {
  17758. var start = threeCode.Substring(0, 3);
  17759. var end = threeCode.Substring(3, 3);
  17760. if (threeCodeStr.Count == 0)
  17761. {
  17762. threeCodeStr.Add(start);
  17763. threeCodeStr.Add(end);
  17764. }
  17765. else
  17766. {
  17767. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17768. {
  17769. threeCodeStr.Add(end);
  17770. }
  17771. else
  17772. {
  17773. threeCodeStr.Add(start);
  17774. threeCodeStr.Add(end);
  17775. }
  17776. }
  17777. }
  17778. }
  17779. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17780. var last = threeCodeStr.Last();
  17781. foreach (var item in threeCodeStr)
  17782. {
  17783. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17784. if (item.Equals(last))
  17785. {
  17786. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17787. }
  17788. }
  17789. cityPath = cityPath.Trim('-');
  17790. }
  17791. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17792. appro.Diid = diid ?? -1;
  17793. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17794. appro.Id = thisId;
  17795. appro.CreateUserId = dto.UserId;
  17796. appro.CreateTime = DateTime.Now;
  17797. content.Add(appro);
  17798. }
  17799. _sqlSugar.CommitTran();
  17800. }
  17801. foreach (var x in content)
  17802. {
  17803. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17804. if (chiList.Count < chiNumber)
  17805. {
  17806. for (int i = chiList.Count; i < chiNumber; i++)
  17807. {
  17808. chiList.Add(new Grp_ApprovalTravelDetails());
  17809. }
  17810. }
  17811. resultArr.Add(new
  17812. {
  17813. x.Id,
  17814. x.Date,
  17815. x.Diid,
  17816. chiList = chiList.Select(x1 => new
  17817. {
  17818. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17819. x1.Details,
  17820. x1.ParentId,
  17821. x1.Id
  17822. })
  17823. });
  17824. }
  17825. data = data with
  17826. {
  17827. content = resultArr,
  17828. };
  17829. jw = JsonView(true, "获取成功!", data);
  17830. return Ok(jw);
  17831. }
  17832. /// <summary>
  17833. /// 报批行程删除
  17834. /// </summary>
  17835. /// <param name="dto"></param>
  17836. /// <returns></returns>
  17837. [HttpPost]
  17838. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17839. {
  17840. var jw = JsonView(false);
  17841. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17842. if (group == null)
  17843. {
  17844. jw.Msg = "团组参数有误!";
  17845. return Ok(jw);
  17846. }
  17847. try
  17848. {
  17849. _sqlSugar.BeginTran();
  17850. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17851. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17852. {
  17853. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17854. DeleteUserId = dto.uesrId,
  17855. IsDel = 1
  17856. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17857. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17858. {
  17859. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17860. DeleteUserId = dto.uesrId,
  17861. IsDel = 1
  17862. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17863. _sqlSugar.CommitTran();
  17864. jw = JsonView(true, "删除成功");
  17865. }
  17866. catch (Exception ex)
  17867. {
  17868. jw = JsonView(false, ex.Message);
  17869. }
  17870. return Ok(jw);
  17871. }
  17872. /// <summary>
  17873. /// 报批行程保存
  17874. /// </summary>
  17875. /// <param name="dto"></param>
  17876. /// <returns></returns>
  17877. [HttpPost]
  17878. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17879. {
  17880. var jw = JsonView(false);
  17881. var Find = dto.Arr.Find(x => x.id == 0);
  17882. if (Find != null)
  17883. {
  17884. jw.Msg = "生成的ID为0!";
  17885. return Ok(jw);
  17886. }
  17887. foreach (var item in dto.Arr)
  17888. {
  17889. foreach (var chi in item.chiList)
  17890. {
  17891. if (chi.parentId == 0)
  17892. {
  17893. chi.parentId = item.id;
  17894. }
  17895. }
  17896. }
  17897. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17898. _sqlSugar.BeginTran();
  17899. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17900. {
  17901. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17902. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17903. {
  17904. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17905. DeleteUserId = dto.UserId,
  17906. IsDel = 1
  17907. }).ExecuteCommand();
  17908. }
  17909. try
  17910. {
  17911. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17912. {
  17913. CreateTime = DateTime.Now,
  17914. CreateUserId = dto.UserId,
  17915. Details = x.details,
  17916. ParentId = x.parentId,
  17917. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17918. Remark = "",
  17919. IsDel = 0
  17920. }).ToList()).ExecuteCommand();
  17921. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17922. {
  17923. Id = x.id,
  17924. Details = x.details,
  17925. ParentId = x.parentId,
  17926. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17927. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17928. {
  17929. Details = x.Details,
  17930. ParentId = x.ParentId,
  17931. Time = x.Time
  17932. }).ExecuteCommand();
  17933. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17934. {
  17935. Id = x.id,
  17936. Date = x.date,
  17937. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17938. {
  17939. Date = x.Date
  17940. }).ExecuteCommand();
  17941. _sqlSugar.CommitTran();
  17942. jw = JsonView(true, "保存成功!");
  17943. }
  17944. catch (Exception ex)
  17945. {
  17946. _sqlSugar.RollbackTran();
  17947. jw = JsonView(false, "保存失败!" + ex.Message);
  17948. }
  17949. return Ok(jw);
  17950. }
  17951. /// <summary>
  17952. /// 报批行程生成
  17953. /// </summary>
  17954. /// <param name="dto"></param>
  17955. /// <returns></returns>
  17956. [HttpPost]
  17957. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17958. {
  17959. var jw = JsonView(false);
  17960. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17961. if (group == null)
  17962. {
  17963. jw.Msg = "暂无该团组!";
  17964. return Ok(jw);
  17965. }
  17966. //黑屏代码数据
  17967. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17968. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17969. {
  17970. jw.Msg = "黑屏代码有误!";
  17971. return Ok(jw);
  17972. }
  17973. foreach (DataRow row in dtBlack.Rows)
  17974. {
  17975. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17976. {
  17977. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17978. return Ok(jw);
  17979. }
  17980. }
  17981. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17982. var resultArr = new ArrayList();
  17983. if (officialActivitiesArr.Count == 0)
  17984. {
  17985. jw.Msg = "暂无公务出访信息!";
  17986. return Ok(jw);
  17987. }
  17988. try
  17989. {
  17990. _sqlSugar.BeginTran();
  17991. DeleteApprovalJourney(new
  17992. Domain.Dtos.Groups.DeleteApprovalJourney
  17993. {
  17994. Diid = dto.Diid,
  17995. uesrId = dto.Userid
  17996. });
  17997. var stay = "-";
  17998. var cityPath = "-";
  17999. //添加城市路径以及住宿地
  18000. //黑屏代码获取时间区间
  18001. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18002. var empty = "【未收入该三字码!请机票同事录入】";
  18003. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18004. for (int i = 0; i < timeArr.Count; i++)
  18005. {
  18006. stay = "-";
  18007. cityPath = "-";
  18008. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18009. DateTime NewData = DateTime.Parse(timeArr[i]);
  18010. 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();
  18011. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18012. if (tbSelect.Length > 0)
  18013. {
  18014. List<string> threeCodeStr = new List<string>();
  18015. bool isTrade = false;
  18016. string trip = string.Empty;
  18017. var rowLast = tbSelect.Last();
  18018. var rowFirst = tbSelect.First();
  18019. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18020. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18021. var takeOffTime = DateTime.Parse(timeArr[i]);
  18022. var fallToTime = DateTime.Parse(timeArr[i]);
  18023. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18024. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18025. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18026. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18027. foreach (var item in tbSelect)
  18028. {
  18029. var start = string.Empty;
  18030. var end = string.Empty;
  18031. var threeCode = item["Three"].ToString() ?? "";
  18032. if (threeCode.Length == 6)
  18033. {
  18034. start = threeCode.Substring(0, 3);
  18035. end = threeCode.Substring(3, 3);
  18036. if (threeCodeStr.Count == 0)
  18037. {
  18038. threeCodeStr.Add(start);
  18039. threeCodeStr.Add(end);
  18040. }
  18041. else
  18042. {
  18043. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18044. {
  18045. threeCodeStr.Add(end);
  18046. }
  18047. else
  18048. {
  18049. threeCodeStr.Add(start);
  18050. threeCodeStr.Add(end);
  18051. }
  18052. }
  18053. }
  18054. //处理机票信息
  18055. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18056. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18057. if (start_Object == null)
  18058. {
  18059. start_Object = new Res_ThreeCode()
  18060. {
  18061. AirPort = empty,
  18062. AirPort_En = empty,
  18063. City = empty,
  18064. Country = empty,
  18065. Four = empty,
  18066. Three = empty,
  18067. };
  18068. }
  18069. if (end_Object == null)
  18070. {
  18071. end_Object = new Res_ThreeCode()
  18072. {
  18073. AirPort = empty,
  18074. AirPort_En = empty,
  18075. City = empty,
  18076. Country = empty,
  18077. Four = empty,
  18078. Three = empty,
  18079. };
  18080. }
  18081. //机型判断
  18082. string airModel = item["AirModel"].ToString();
  18083. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18084. string flightTime = item["FlightTime"].ToString();
  18085. if (flightTime!.Contains(":"))
  18086. {
  18087. flightTime = flightTime.Replace(":", "小时");
  18088. flightTime += "分钟";
  18089. }
  18090. if (flightTime.Contains("H"))
  18091. {
  18092. flightTime = flightTime.Replace("H", "小时");
  18093. }
  18094. if (flightTime.Contains("M"))
  18095. {
  18096. flightTime = flightTime.Replace("M", "分钟");
  18097. }
  18098. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18099. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18100. {
  18101. flightTime = flightDataTime.Hour > 0
  18102. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18103. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18104. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18105. }
  18106. //航班号
  18107. string flightcode = item["Fliagtcode"].ToString();
  18108. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18109. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18110. if (aircompany == null)
  18111. {
  18112. aircompany = new Res_AirCompany
  18113. {
  18114. CnName = hsEmpty,
  18115. EnName = hsEmpty,
  18116. ShortCode = hsEmpty,
  18117. };
  18118. }
  18119. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18120. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18121. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18122. if (isTrade)
  18123. {
  18124. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18125. }
  18126. else
  18127. {
  18128. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18129. }
  18130. }
  18131. chiarr.Add(new Grp_ApprovalTravelDetails
  18132. {
  18133. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18134. CreateTime = DateTime.Now,
  18135. CreateUserId = dto.Userid,
  18136. ParentId = 0,
  18137. Details = trip
  18138. });
  18139. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18140. var last = threeCodeStr.Last();
  18141. foreach (var item in threeCodeStr)
  18142. {
  18143. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18144. if (item.Equals(last))
  18145. {
  18146. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18147. }
  18148. }
  18149. cityPath = cityPath.Trim('-');
  18150. }
  18151. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18152. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18153. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18154. appro.Diid = dto.Diid;
  18155. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18156. appro.Id = thisId;
  18157. appro.CreateUserId = dto.Userid;
  18158. appro.CreateTime = DateTime.Now;
  18159. foreach (var item in gwinfo)
  18160. {
  18161. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18162. chi.Details = "拜访" + item.Client;
  18163. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18164. {
  18165. chi.Details += "," + item.ReqSample;
  18166. }
  18167. chi.ParentId = thisId;
  18168. chi.Time = item.Time;
  18169. chiarr.Add(chi);
  18170. }
  18171. if (chiarr.Count < 5)
  18172. {
  18173. for (int j = chiarr.Count; j < 5; j++)
  18174. {
  18175. chiarr.Add(new
  18176. Grp_ApprovalTravelDetails());
  18177. }
  18178. }
  18179. resultArr.Add(new
  18180. {
  18181. appro.Id,
  18182. appro.Date,
  18183. appro.Diid,
  18184. chiList = chiarr.Select(x1 => new
  18185. {
  18186. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  18187. x1.Details,
  18188. x1.ParentId,
  18189. x1.Id
  18190. })
  18191. });
  18192. }
  18193. _sqlSugar.CommitTran();
  18194. jw = JsonView(true, "生成成功!", resultArr);
  18195. }
  18196. catch (Exception ex)
  18197. {
  18198. jw.Code = 400;
  18199. jw.Msg = "生成失败!" + ex.Message;
  18200. }
  18201. return Ok(jw);
  18202. }
  18203. /// <summary>
  18204. /// 报批行程word导出
  18205. /// </summary>
  18206. /// <param name="dto"></param>
  18207. /// <returns></returns>
  18208. [HttpPost]
  18209. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18210. {
  18211. var jw = JsonView(false);
  18212. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18213. if (group == null)
  18214. {
  18215. jw.Msg = "暂无该团组!";
  18216. return Ok(jw);
  18217. }
  18218. //模板路径
  18219. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18220. //载入模板
  18221. Document doc = new Document(tempPath);
  18222. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18223. //获取所填表格的序数
  18224. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18225. Aspose.Words.Tables.Row titleRowClone = null;
  18226. Aspose.Words.Tables.Row CenterRowClone = null;
  18227. int index = 0;
  18228. int indexChi = 0;
  18229. int SetIndex = 0;
  18230. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18231. //获取数据,放到datatable
  18232. foreach (var item in ApprovalTravelArr)
  18233. {
  18234. if (index > 0)
  18235. {
  18236. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18237. tableOne.AppendChild(titleRowClone);
  18238. }
  18239. var textTime = item.Date;
  18240. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18241. SetCells(tableOne, doc, SetIndex, 0, textTime);
  18242. SetIndex++;
  18243. if (ChiRep.Count > 0)
  18244. {
  18245. foreach (var itemChi in ChiRep)
  18246. {
  18247. var txtTime = itemChi.Time;
  18248. var txtDetail = itemChi.Details;
  18249. if (indexChi > 0)
  18250. {
  18251. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18252. tableOne.AppendChild(CenterRowClone);
  18253. }
  18254. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18255. {
  18256. SetCells(tableOne, doc, SetIndex, 0, "");
  18257. SetCells(tableOne, doc, SetIndex, 1, "");
  18258. indexChi++;
  18259. SetIndex++;
  18260. break;
  18261. }
  18262. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  18263. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  18264. indexChi++;
  18265. SetIndex++;
  18266. }
  18267. }
  18268. else
  18269. {
  18270. if (indexChi > 0)
  18271. {
  18272. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18273. tableOne.AppendChild(CenterRowClone);
  18274. }
  18275. SetCells(tableOne, doc, SetIndex, 0, "");
  18276. SetCells(tableOne, doc, SetIndex, 1, "");
  18277. indexChi++;
  18278. SetIndex++;
  18279. }
  18280. index++;
  18281. }
  18282. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  18283. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18284. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18285. jw.Code = 200;
  18286. jw.Msg = "";
  18287. return Ok(jw);
  18288. }
  18289. private string intToString(int numberVal)
  18290. {
  18291. string numberval = numberVal.ToString();
  18292. Dictionary<char, string> Number = new Dictionary<char, string>();
  18293. Number.Add('1', "一");
  18294. Number.Add('2', "二");
  18295. Number.Add('3', "三");
  18296. Number.Add('4', "四");
  18297. Number.Add('5', "五");
  18298. Number.Add('6', "六");
  18299. Number.Add('7', "七");
  18300. Number.Add('8', "八");
  18301. Number.Add('9', "九");
  18302. string stringNumberVal = string.Empty;
  18303. for (int i = 0; i < numberval.Length; i++)
  18304. {
  18305. if (i == 0)
  18306. {
  18307. stringNumberVal += Number[numberval[i]];
  18308. }
  18309. else if (i >= 1)
  18310. {
  18311. if (numberval[i] == '0')
  18312. {
  18313. stringNumberVal = "十";
  18314. }
  18315. else
  18316. {
  18317. stringNumberVal += "十" + Number[numberval[i]];
  18318. }
  18319. }
  18320. }
  18321. return stringNumberVal;
  18322. }
  18323. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  18324. {
  18325. //获取table中的某个单元格,从0开始
  18326. Cell lshCell = table.Rows[rows].Cells[cells];
  18327. //将单元格中段落移除
  18328. foreach (Node item in lshCell.Paragraphs)
  18329. {
  18330. lshCell.Paragraphs.Remove(item);
  18331. }
  18332. if (val.Contains("\r\n"))
  18333. {
  18334. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18335. foreach (var item in spArr)
  18336. {
  18337. //新建一个段落
  18338. Paragraph p = new Paragraph(doc);
  18339. var r = new Run(doc, item);
  18340. //把设置的值赋给之前新建的段落
  18341. p.AppendChild(r);
  18342. //将此段落加到单元格内
  18343. lshCell.AppendChild(p);
  18344. }
  18345. }
  18346. else
  18347. {
  18348. //新建一个段落
  18349. Paragraph p = new Paragraph(doc);
  18350. var r = new Run(doc, val);
  18351. //把设置的值赋给之前新建的段落
  18352. p.AppendChild(r);
  18353. //将此段落加到单元格内
  18354. lshCell.AppendChild(p);
  18355. }
  18356. }
  18357. [HttpPost]
  18358. public async Task<IActionResult> ServerHttp(string paramStr)
  18359. {
  18360. paramStr = paramStr.TrimEnd('\'');
  18361. paramStr = paramStr.TrimStart('\'');
  18362. JsonView jw = JsonView(false);
  18363. JObject param = JObject.Parse(paramStr);
  18364. if (!param.ContainsKey("url"))
  18365. {
  18366. jw.Msg = "url null";
  18367. return Ok(jw);
  18368. }
  18369. string url = param["url"]!.ToString();
  18370. var methon = "get";
  18371. Dictionary<string, string> headValues = null;
  18372. string bodyStr = string.Empty;
  18373. if (param.ContainsKey("methon"))
  18374. {
  18375. methon = param["methon"]!.ToString().ToLower();
  18376. }
  18377. if (param.ContainsKey("header"))
  18378. {
  18379. var header = param["header"]!.ToString();
  18380. JObject headerJobject = JObject.Parse(header);
  18381. headValues = new Dictionary<string, string>();
  18382. foreach (JProperty item in headerJobject.Properties())
  18383. {
  18384. var value = item.Value.ToString();
  18385. var head = item.Path;
  18386. headValues.Add(head, value);
  18387. }
  18388. }
  18389. HttpClient client = new HttpClient();
  18390. string responseString = string.Empty;
  18391. StringContent content = null;
  18392. if (headValues != null)
  18393. {
  18394. foreach (var item in headValues.Keys)
  18395. {
  18396. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18397. {
  18398. if (param.ContainsKey("body"))
  18399. {
  18400. bodyStr = param["body"]!.ToString();
  18401. }
  18402. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18403. }
  18404. else
  18405. {
  18406. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18407. }
  18408. }
  18409. }
  18410. try
  18411. {
  18412. if (methon == "get")
  18413. {
  18414. responseString = await client.GetStringAsync(url);
  18415. }
  18416. else if (methon == "post")
  18417. {
  18418. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18419. {
  18420. Content = content
  18421. };
  18422. var response = await client.SendAsync(request);
  18423. try
  18424. {
  18425. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18426. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18427. {
  18428. using (StreamReader reader = new StreamReader(gzipStream))
  18429. {
  18430. responseString = await reader.ReadToEndAsync();
  18431. }
  18432. }
  18433. }
  18434. catch (Exception)
  18435. {
  18436. responseString = await response.Content.ReadAsStringAsync();
  18437. }
  18438. }
  18439. else
  18440. {
  18441. responseString = "methon error";
  18442. }
  18443. jw = JsonView(true, "success", responseString);
  18444. }
  18445. catch (Exception ex)
  18446. {
  18447. jw.Msg = "error " + ex.Message;
  18448. jw.Data = ex.StackTrace;
  18449. }
  18450. finally
  18451. {
  18452. client.Dispose();
  18453. }
  18454. return Ok(jw);
  18455. }
  18456. #endregion
  18457. #region 团组接待意见调查
  18458. /// <summary>
  18459. /// 团组接待意见调查 - 信息管理
  18460. /// 基础数据(团组)
  18461. /// </summary>
  18462. /// <returns></returns>
  18463. [HttpGet]
  18464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18465. public async Task<IActionResult> OpinionaireInit()
  18466. {
  18467. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18468. .Select(x => new
  18469. {
  18470. x.Id,
  18471. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18472. })
  18473. .OrderByDescending(x => x.Id)
  18474. .ToListAsync();
  18475. return Ok(JsonView(groupData, groupData.Count));
  18476. }
  18477. /// <summary>
  18478. /// 团组接待意见调查 - 信息管理
  18479. /// 列表
  18480. /// </summary>
  18481. /// <param name="groupId"></param>
  18482. /// <returns></returns>
  18483. [HttpGet("{groupId}")]
  18484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18485. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18486. {
  18487. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18488. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18489. .Select(x => new
  18490. {
  18491. x.Id,
  18492. x.TourGuideName,
  18493. x.CityName,
  18494. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18495. x.CreateTime
  18496. })
  18497. .OrderBy(x => x.Id)
  18498. .ToListAsync();
  18499. return Ok(JsonView(data));
  18500. }
  18501. /// <summary>
  18502. /// 团组接待意见调查 - 信息管理
  18503. /// 保存
  18504. /// </summary>
  18505. /// <param name="dto"></param>
  18506. /// <returns></returns>
  18507. [HttpPost]
  18508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18509. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18510. {
  18511. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18512. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18513. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18514. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18515. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18516. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18517. _opinionaireRep.BeginTran();
  18518. if (addData != null && addData.Count > 0)
  18519. {
  18520. foreach (var item in addData)
  18521. {
  18522. item.CreateUserId = currUserInfo.UserId;
  18523. item.DiId = dto.DiId;
  18524. }
  18525. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18526. }
  18527. if (updData != null && updData.Count > 0)
  18528. {
  18529. var upd = await _opinionaireRep._sqlSugar
  18530. .Updateable(updData)
  18531. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18532. .WhereColumns(x => new { x.Id })
  18533. .ExecuteCommandAsync();
  18534. }
  18535. _opinionaireRep.CommitTran();
  18536. return Ok(JsonView("操作成功!"));
  18537. }
  18538. /// <summary>
  18539. /// 团组接待意见调查 - 信息管理
  18540. /// 删除
  18541. /// </summary>
  18542. /// <param name="id"></param>
  18543. /// <returns></returns>
  18544. [HttpDelete("{id}")]
  18545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18546. public async Task<IActionResult> OpinionaireManageDel(int id)
  18547. {
  18548. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18549. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18550. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18551. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18552. if (!del) return Ok(JsonView("操作失败!"));
  18553. return Ok(JsonView("操作成功!"));
  18554. }
  18555. /// <summary>
  18556. /// 团组接待意见调查 - 用户
  18557. /// 列表
  18558. /// </summary>
  18559. /// <param name="diId"></param>
  18560. /// <returns></returns>
  18561. [HttpGet("{diId}")]
  18562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18563. public async Task<IActionResult> OpinionaireUserList(int diId)
  18564. {
  18565. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18566. var sql = string.Format(@"
  18567. SELECT
  18568. o.Id,
  18569. o.DiId,
  18570. di.TeamName AS 'GroupName',
  18571. di.VisitPNumber AS 'PeopleNumber',
  18572. di.ClientName AS 'LeadGroup',
  18573. di.VisitCountry AS 'Travel',
  18574. di.VisitDays AS 'Days',
  18575. o.CityName,
  18576. o.TourGuideName,
  18577. o.Catering,
  18578. o.CateringReason,
  18579. o.Stay,
  18580. o.StayReason,
  18581. o.[Route],
  18582. o.RouteReason,
  18583. o.OfficialActivity,
  18584. o.OfficialActivityReason,
  18585. o.TourGuide,
  18586. o.TourGuideReason,
  18587. o.[Translate],
  18588. o.TranslateReason,
  18589. o.Trip,
  18590. o.TripReason,
  18591. o.ESFileName,
  18592. o.SignatureDate,
  18593. o.Remark
  18594. FROM
  18595. Grp_Opinionaire o
  18596. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18597. WHERE
  18598. o.IsDel = 0
  18599. AND o.DiId = {0}
  18600. ORDER BY
  18601. o.Id ASC", diId);
  18602. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18603. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18604. return Ok(JsonView(data));
  18605. }
  18606. /// <summary>
  18607. /// 团组接待意见调查 - 用户
  18608. /// 保存
  18609. /// </summary>
  18610. /// <param name="dto"></param>
  18611. /// <returns></returns>
  18612. [HttpPost]
  18613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18614. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18615. {
  18616. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18617. foreach (var item in dto)
  18618. {
  18619. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18620. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18621. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18622. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18623. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18624. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18625. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18626. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18627. }
  18628. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18629. if (!Directory.Exists(filePathBase))
  18630. {
  18631. Directory.CreateDirectory(filePathBase);
  18632. }
  18633. #region 上传文件
  18634. var filePaths = new List<string>();
  18635. foreach (var item in dto)
  18636. {
  18637. var file = item.File;
  18638. // 将文件保存到指定位置
  18639. var filePath = Path.Combine(filePathBase, file.FileName);
  18640. using (var stream = new FileStream(filePath, FileMode.Create))
  18641. {
  18642. await file.CopyToAsync(stream);
  18643. }
  18644. //验证文件是否上传成功
  18645. if (!System.IO.File.Exists(filePath))
  18646. {
  18647. foreach (var filePathStr in filePaths)
  18648. {
  18649. System.IO.File.Delete(filePathStr);
  18650. }
  18651. return Ok(JsonView(false, "文件上传失败!"));
  18652. }
  18653. item.ESFileName = file.FileName;
  18654. }
  18655. #endregion
  18656. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18657. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18658. .UpdateColumns(x => new
  18659. {
  18660. x.Catering,
  18661. x.CateringReason,
  18662. x.Stay,
  18663. x.StayReason,
  18664. x.Route,
  18665. x.RouteReason,
  18666. x.OfficialActivity,
  18667. x.OfficialActivityReason,
  18668. x.TourGuide,
  18669. x.TourGuideReason,
  18670. x.Translate,
  18671. x.TranslateReason,
  18672. x.Trip,
  18673. x.TripReason,
  18674. x.ESFileName,
  18675. x.SignatureDate,
  18676. x.Remark
  18677. })
  18678. .WhereColumns(x => new { x.Id })
  18679. .ExecuteCommandAsync();
  18680. if (upd < 1)
  18681. {
  18682. foreach (var filePathStr in filePaths)
  18683. {
  18684. System.IO.File.Delete(filePathStr);
  18685. }
  18686. return Ok(JsonView(false));
  18687. }
  18688. return Ok(JsonView(true));
  18689. }
  18690. #endregion
  18691. #region 团组餐厅相关信息
  18692. /// <summary>
  18693. /// 团组相关餐厅信息
  18694. /// 基础数据(团组)
  18695. /// </summary>
  18696. /// <returns></returns>
  18697. [HttpGet]
  18698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18699. public async Task<IActionResult> RestaurantInit()
  18700. {
  18701. return Ok(await _restaurantRep.InitAsync());
  18702. }
  18703. /// <summary>
  18704. /// 团组相关餐厅信息
  18705. /// Item
  18706. /// </summary>
  18707. /// <param name="dto"></param>
  18708. /// <returns></returns>
  18709. [HttpPost]
  18710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18711. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18712. {
  18713. int portType = dto.PortType,
  18714. groupId = dto.GroupId;
  18715. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18716. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18717. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  18718. }
  18719. /// <summary>
  18720. /// 团组相关餐厅信息
  18721. /// List
  18722. /// </summary>
  18723. /// <param name="dto"></param>
  18724. /// <returns></returns>
  18725. [HttpPost]
  18726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18727. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18728. {
  18729. int portType = dto.PortType,
  18730. groupId = dto.GroupId;
  18731. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18732. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18733. var sql = string.Format(@" SELECT
  18734. ri.Id,
  18735. ri.GroupId,
  18736. ri.Date,
  18737. ri.StartTime,
  18738. ri.EndTime,
  18739. CASE WHEN ri.Type = 1 THEN '早餐'
  18740. WHEN ri.Type = 2 THEN '午餐'
  18741. WHEN ri.Type = 3 THEN '晚餐'
  18742. ELSE '其他'
  18743. END AS 'Type',
  18744. ri.Name,
  18745. ri.Address,
  18746. ri.Tel,
  18747. ri.Remark,
  18748. ri.CreateTime,
  18749. u.CnName AS CreateUserName
  18750. FROM
  18751. Grp_RestaurantInfo ri
  18752. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18753. WHERE
  18754. ri.IsDel = 0
  18755. AND ri.GroupId = {0}
  18756. ORDER BY
  18757. ri.Date ASC
  18758. ", groupId);
  18759. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18760. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18761. return Ok(JsonView(infos));
  18762. }
  18763. /// <summary>
  18764. /// 团组相关餐厅信息
  18765. /// Info
  18766. /// </summary>
  18767. /// <param name="dto"></param>
  18768. /// <returns></returns>
  18769. [HttpPost]
  18770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18771. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18772. {
  18773. int portType = dto.PortType,
  18774. id = dto.Id;
  18775. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18776. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18777. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18778. }
  18779. /// <summary>
  18780. /// 团组相关餐厅信息
  18781. /// Op
  18782. /// </summary>
  18783. /// <param name="dto"></param>
  18784. /// <returns></returns>
  18785. [HttpPost]
  18786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18787. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18788. {
  18789. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18790. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18791. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18792. return Ok(await _restaurantRep.OpAsync(dto));
  18793. }
  18794. /// <summary>
  18795. /// 团组相关餐厅信息
  18796. /// Del
  18797. /// </summary>
  18798. /// <param name="dto"></param>
  18799. /// <returns></returns>
  18800. [HttpPost]
  18801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18802. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18803. {
  18804. int userId = dto.DeleteUserId;
  18805. var id = dto.Id;
  18806. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18807. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18808. return Ok(await _restaurantRep.DelAsync(dto));
  18809. }
  18810. #endregion
  18811. // /// <summary>
  18812. // ///
  18813. // /// </summary>
  18814. // /// <param name="_dto"></param>
  18815. // /// <returns></returns>
  18816. // [HttpPost]
  18817. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18818. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18819. // {
  18820. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18821. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18822. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18823. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18824. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18825. // dic_psg.Add("客人", 974);
  18826. // dic_psg.Add("司机", 975);
  18827. // dic_psg.Add("导游", 976);
  18828. // dic_psg.Add("公司内部人员", 977);
  18829. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18830. // foreach (var item in list_visa)
  18831. // {
  18832. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18833. // temp.Id = item.Id;
  18834. // temp.DIId = item.DIId;
  18835. // temp.VisaClient = item.VisaClient;
  18836. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18837. // temp.VisaCurrency = item.VisaCurrency;
  18838. // temp.IsThird = item.IsThird;
  18839. // if (dic_psg.ContainsKey(item.PassengerType))
  18840. // {
  18841. // temp.PassengerType = dic_psg[item.PassengerType];
  18842. // }
  18843. // else {
  18844. // temp.PassengerType = -1;
  18845. // }
  18846. // temp.VisaNumber = item.VisaNumber;
  18847. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18848. // temp.CreateUserId = item.Operators;
  18849. // DateTime dt_ct;
  18850. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18851. // if (b_ct)
  18852. // {
  18853. // temp.CreateTime = dt_ct;
  18854. // }
  18855. // else
  18856. // {
  18857. // temp.CreateTime = DateTime.Now;
  18858. // }
  18859. // temp.DeleteTime = "";
  18860. // temp.DeleteUserId = 0;
  18861. // temp.Remark = item.Remark;
  18862. // if (string.IsNullOrEmpty(temp.Remark)) {
  18863. // temp.Remark = "";
  18864. // }
  18865. // temp.IsDel = item.IsDel;
  18866. // temp.VisaDescription = item.VisaAttachment;
  18867. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18868. //([Id]
  18869. // ,[DIId]
  18870. // ,[VisaClient]
  18871. // ,[VisaPrice]
  18872. // ,[VisaCurrency]
  18873. // ,[IsThird]
  18874. // ,[PassengerType]
  18875. // ,[VisaNumber]
  18876. // ,[VisaFreeNumber]
  18877. // ,[CreateUserId]
  18878. // ,[CreateTime]
  18879. // ,[DeleteTime]
  18880. // ,[DeleteUserId]
  18881. // ,[Remark]
  18882. // ,[IsDel]
  18883. // ,[visaDescription])
  18884. // VALUES
  18885. // ({0},{1},'{2}',{3},{4}
  18886. //,{5},{6},{7},{8},{9}
  18887. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18888. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18889. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18890. //);
  18891. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18892. // }
  18893. // return Ok(JsonView(true, "操作成功!"));
  18894. // }
  18895. /// <summary>
  18896. /// 123132123
  18897. /// </summary>
  18898. /// <param name="_dto"></param>
  18899. /// <returns></returns>
  18900. [HttpPost]
  18901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18902. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18903. {
  18904. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18905. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18906. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18907. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18908. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18909. dicDetail.Add(789, 1034);
  18910. dicDetail.Add(790, 1035);
  18911. dicDetail.Add(791, 1036);
  18912. dicDetail.Add(792, 1037);
  18913. dicDetail.Add(793, 1038);
  18914. dicDetail.Add(794, 1039);
  18915. dicDetail.Add(795, 1040);
  18916. dicDetail.Add(796, 1041);
  18917. dicDetail.Add(797, 1042);
  18918. dicDetail.Add(798, 1043);
  18919. dicDetail.Add(801, 1044);
  18920. dicDetail.Add(802, 1045);
  18921. dicDetail.Add(803, 1046);
  18922. Dictionary<int, int> dic = new Dictionary<int, int>();
  18923. dic.Add(806, 1027);
  18924. dic.Add(807, 1028);
  18925. dic.Add(808, 1029);
  18926. dic.Add(809, 1030);
  18927. dic.Add(810, 1031);
  18928. dic.Add(811, 1032);
  18929. dic.Add(812, 1033);
  18930. foreach (var item in list_visa)
  18931. {
  18932. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18933. temp.Coefficient = item.coefficient;
  18934. DateTime dtCrt;
  18935. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18936. if (b1)
  18937. {
  18938. temp.CreateTime = dtCrt;
  18939. }
  18940. else
  18941. {
  18942. temp.CreateTime = DateTime.Now;
  18943. }
  18944. temp.CreateUserId = item.Operators;
  18945. temp.DeleteTime = "";
  18946. temp.DeleteUserId = 0;
  18947. temp.DiId = int.Parse(item.DIID);
  18948. temp.FilePath = item.FilePath;
  18949. temp.IsDel = item.IsDel;
  18950. temp.Price = item.Price;
  18951. temp.PriceCount = 1;
  18952. temp.PriceCurrency = item.Currency;
  18953. int detailId = 0;
  18954. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18955. {
  18956. detailId = dicDetail[item.PriceTypeDetail];
  18957. }
  18958. temp.PriceDetailType = detailId;
  18959. temp.PriceDt = DateTime.Now;
  18960. temp.PriceName = item.PriceName;
  18961. temp.PriceSum = item.Price;
  18962. int tid = 0;
  18963. if (dic.ContainsKey(item.PriceType))
  18964. {
  18965. tid = dic[item.PriceType];
  18966. }
  18967. temp.PriceType = tid;
  18968. temp.Remark = item.Remark;
  18969. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18970. }
  18971. return Ok(JsonView(true, "操作成功!"));
  18972. }
  18973. [HttpPost]
  18974. public IActionResult TimeTest()
  18975. {
  18976. var jw = JsonView(false, "error");
  18977. _sqlSugar.BeginTran();
  18978. try
  18979. {
  18980. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18981. .Select(x => new Crm_NewClientData
  18982. {
  18983. Id = x.Id,
  18984. Client = x.Client,
  18985. Contact = x.Contact,
  18986. Location = x.Location,
  18987. })
  18988. .ToList();
  18989. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  18990. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18991. Stopwatch stopwatch = new Stopwatch();
  18992. // 开始计时
  18993. stopwatch.Start();
  18994. foreach (var item in clientList)
  18995. {
  18996. EncryptionProcessor.DecryptProperties(item);
  18997. }
  18998. stopwatch.Stop();
  18999. jw.Code = 200;
  19000. jw.Data = stopwatch.ElapsedMilliseconds;
  19001. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19002. }
  19003. catch (Exception ex)
  19004. {
  19005. jw.Code = 400;
  19006. jw.Msg = ex.Message;
  19007. }
  19008. return Ok(jw);
  19009. }
  19010. }
  19011. }