GroupsController.cs 1021 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075
  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 OASystem.Infrastructure.Tools;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using System.Text.Json;
  44. using TencentCloud.Ocr.V20181119.Models;
  45. using static OASystem.API.OAMethodLib.JWTHelper;
  46. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  47. using Bookmark = Aspose.Words.Bookmark;
  48. using Cell = Aspose.Words.Tables.Cell;
  49. using Table = Aspose.Words.Tables.Table;
  50. namespace OASystem.API.Controllers
  51. {
  52. /// <summary>
  53. /// 团组相关
  54. /// </summary>
  55. //[Authorize]
  56. [Route("api/[controller]/[action]")]
  57. public class GroupsController : ControllerBase
  58. {
  59. private readonly ILogger<GroupsController> _logger;
  60. private readonly GrpScheduleRepository _grpScheduleRep;
  61. private readonly IMapper _mapper;
  62. private readonly DelegationInfoRepository _groupRepository;
  63. private readonly TaskAssignmentRepository _taskAssignmentRep;
  64. private readonly AirTicketResRepository _airTicketResRep;
  65. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  66. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  67. private readonly DelegationEnDataRepository _delegationEnDataRep;
  68. private readonly DelegationVisaRepository _delegationVisaRep;
  69. private readonly VisaPriceRepository _visaPriceRep;
  70. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  71. private readonly HotelPriceRepository _hotelPriceRep;
  72. private readonly CustomersRepository _customersRep;
  73. private readonly MessageRepository _message;
  74. private readonly SqlSugarClient _sqlSugar;
  75. private readonly TourClientListRepository _tourClientListRep;
  76. private readonly TeamRateRepository _teamRateRep;
  77. #region 成本相关
  78. private readonly CheckBoxsRepository _checkBoxs;
  79. private readonly GroupCostRepository _GroupCostRepository;
  80. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  81. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  82. #endregion
  83. private readonly SetDataRepository _setDataRep;
  84. private string url;
  85. private string path;
  86. private readonly EnterExitCostRepository _enterExitCostRep;
  87. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  88. private readonly UsersRepository _usersRep;
  89. private readonly IJuHeApiService _juHeApi;
  90. private readonly InvertedListRepository _invertedListRep;
  91. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  92. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  93. private readonly ThreeCodeRepository _threeCodeRepository;
  94. private readonly HotelInquiryRepository _hotelInquiryRep;
  95. private readonly FeeAuditRepository _feeAuditRep;
  96. private readonly VisaCommissionRepository _visaCommissionRep;
  97. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  98. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  99. private readonly List<CurrencyInfo> _currencyInit;
  100. private readonly List<int> _portTypeData;
  101. private readonly TableOperationRecordRepository _tableorRep;
  102. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  103. private readonly RestaurantRepository _restaurantRep;
  104. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  105. /// <summary>
  106. /// 构造函数
  107. /// </summary>
  108. /// <param name="logger"></param>
  109. /// <param name="mapper"></param>
  110. /// <param name="hubContext"></param>
  111. /// <param name="sqlSugar"></param>
  112. /// <param name="grpScheduleRep"></param>
  113. /// <param name="groupRepository"></param>
  114. /// <param name="taskAssignmentRep"></param>
  115. /// <param name="airTicketResRep"></param>
  116. /// <param name="decreasePaymentsRep"></param>
  117. /// <param name="InvitationOfficialActivitiesRep"></param>
  118. /// <param name="delegationEnDataRep"></param>
  119. /// <param name="enterExitCostRep"></param>
  120. /// <param name="delegationVisaRep"></param>
  121. /// <param name="message"></param>
  122. /// <param name="visaPriceRep"></param>
  123. /// <param name="carTouristGuideGroundRep"></param>
  124. /// <param name="checkBoxs"></param>
  125. /// <param name="GroupCostRepository"></param>
  126. /// <param name="CostTypeHotelNumberRepository"></param>
  127. /// <param name="GroupCostParameterRepository"></param>
  128. /// <param name="hotelPriceRep"></param>
  129. /// <param name="customersRep"></param>
  130. /// <param name="setDataRep"></param>
  131. /// <param name="tourClientListRep"></param>
  132. /// <param name="teamRateRep"></param>
  133. /// <param name="usersRep"></param>
  134. /// <param name="juHeApi"></param>
  135. /// <param name="invertedListRep"></param>
  136. /// <param name="visaFeeInfoRep"></param>
  137. /// <param name="ticketBlackCodeRep"></param>
  138. /// <param name="hotelInquiryRep"></param>
  139. /// <param name="threeCodeRepository"></param>
  140. /// <param name="feeAuditRep"></param>
  141. /// <param name="visaCommissionRep"></param>
  142. /// <param name="ffrRep"></param>
  143. /// <param name="opinionaireRep"></param>
  144. /// <param name="tableorRep"></param>
  145. /// <param name="enterExitCostDraftRep"></param>
  146. /// <param name="restaurantRep"></param>
  147. /// <param name="enterExitCostQuoteRep"></param>
  148. public GroupsController(
  149. ILogger<GroupsController> logger,
  150. IMapper mapper,
  151. IHubContext<ChatHub, IChatClient> hubContext,
  152. SqlSugarClient sqlSugar,
  153. GrpScheduleRepository grpScheduleRep,
  154. DelegationInfoRepository groupRepository,
  155. TaskAssignmentRepository taskAssignmentRep,
  156. AirTicketResRepository airTicketResRep,
  157. DecreasePaymentsRepository decreasePaymentsRep,
  158. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  159. DelegationEnDataRepository delegationEnDataRep,
  160. EnterExitCostRepository enterExitCostRep,
  161. DelegationVisaRepository delegationVisaRep,
  162. MessageRepository message,
  163. VisaPriceRepository visaPriceRep,
  164. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  165. CheckBoxsRepository checkBoxs,
  166. GroupCostRepository GroupCostRepository,
  167. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  168. GroupCostParameterRepository GroupCostParameterRepository,
  169. HotelPriceRepository hotelPriceRep,
  170. CustomersRepository customersRep,
  171. SetDataRepository setDataRep,
  172. TourClientListRepository tourClientListRep,
  173. TeamRateRepository teamRateRep,
  174. UsersRepository usersRep, IJuHeApiService juHeApi,
  175. InvertedListRepository invertedListRep,
  176. VisaFeeInfoRepository visaFeeInfoRep,
  177. TicketBlackCodeRepository ticketBlackCodeRep,
  178. HotelInquiryRepository hotelInquiryRep,
  179. ThreeCodeRepository threeCodeRepository,
  180. FeeAuditRepository feeAuditRep,
  181. VisaCommissionRepository visaCommissionRep,
  182. ForeignReceivablesRepository ffrRep,
  183. OpinionaireRepository opinionaireRep,
  184. TableOperationRecordRepository tableorRep,
  185. EnterExitCostDraftRepository enterExitCostDraftRep,
  186. RestaurantRepository restaurantRep,
  187. EnterExitCostQuoteRepository enterExitCostQuoteRep
  188. )
  189. {
  190. _logger = logger;
  191. _mapper = mapper;
  192. _grpScheduleRep = grpScheduleRep;
  193. _groupRepository = groupRepository;
  194. _taskAssignmentRep = taskAssignmentRep;
  195. _airTicketResRep = airTicketResRep;
  196. _sqlSugar = sqlSugar;
  197. url = AppSettingsHelper.Get("ExcelBaseUrl");
  198. path = AppSettingsHelper.Get("ExcelBasePath");
  199. if (!System.IO.Directory.Exists(path))
  200. {
  201. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  202. }
  203. _decreasePaymentsRep = decreasePaymentsRep;
  204. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  205. _delegationEnDataRep = delegationEnDataRep;
  206. _enterExitCostRep = enterExitCostRep;
  207. _delegationVisaRep = delegationVisaRep;
  208. _message = message;
  209. _visaPriceRep = visaPriceRep;
  210. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  211. _checkBoxs = checkBoxs;
  212. _GroupCostRepository = GroupCostRepository;
  213. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  214. _GroupCostParameterRepository = GroupCostParameterRepository;
  215. _hotelPriceRep = hotelPriceRep;
  216. _customersRep = customersRep;
  217. _setDataRep = setDataRep;
  218. _tourClientListRep = tourClientListRep;
  219. _teamRateRep = teamRateRep;
  220. _hubContext = hubContext;
  221. _usersRep = usersRep;
  222. _juHeApi = juHeApi;
  223. _invertedListRep = invertedListRep;
  224. _visaFeeInfoRep = visaFeeInfoRep;
  225. _ticketBlackCodeRep = ticketBlackCodeRep;
  226. _hotelInquiryRep = hotelInquiryRep;
  227. _threeCodeRepository = threeCodeRepository;
  228. _feeAuditRep = feeAuditRep;
  229. _visaCommissionRep = visaCommissionRep;
  230. _ffrRep = ffrRep;
  231. _opinionaireRep = opinionaireRep;
  232. _currencyInit = new List<CurrencyInfo>()
  233. {
  234. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  235. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  236. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  237. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  238. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  239. };
  240. _portTypeData = new List<int>() { 2, 3 };
  241. _tableorRep = tableorRep;
  242. _enterExitCostDraftRep = enterExitCostDraftRep;
  243. _restaurantRep = restaurantRep;
  244. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  245. }
  246. #region 流程管控
  247. /// <summary>
  248. /// 获取团组流程管控信息
  249. /// </summary>
  250. /// <param name="_jsonDto"></param>
  251. /// <returns></returns>
  252. [HttpPost]
  253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  254. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  255. {
  256. if (string.IsNullOrEmpty(_jsonDto.Paras))
  257. {
  258. return Ok(JsonView(false, "参数为空"));
  259. }
  260. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  261. if (_ScheduleDto != null)
  262. {
  263. if (_ScheduleDto.SearchType == 2)//获取列表
  264. {
  265. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  266. return Ok(JsonView(_grpScheduleViewList));
  267. }
  268. else//获取对象
  269. {
  270. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  271. if (_grpScheduleView != null)
  272. {
  273. return Ok(JsonView(_grpScheduleView));
  274. }
  275. }
  276. }
  277. else
  278. {
  279. return Ok(JsonView(false, "参数反序列化失败"));
  280. }
  281. return Ok(JsonView(false, "暂无数据!"));
  282. }
  283. /// <summary>
  284. /// 修改团组流程管控详细表数据
  285. /// </summary>
  286. /// <param name="dto"></param>
  287. /// <returns></returns>
  288. [HttpPost]
  289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  290. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  291. {
  292. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  293. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  294. .SetColumns(it => it.Duty == _detail.Duty)
  295. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  296. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  297. .SetColumns(it => it.JobContent == _detail.JobContent)
  298. .SetColumns(it => it.Remark == _detail.Remark)
  299. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  300. .Where(s => s.Id == dto.Id)
  301. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  302. .ExecuteCommandAsync();
  303. if (result > 0)
  304. {
  305. return Ok(JsonView(true, "保存成功!"));
  306. }
  307. return Ok(JsonView(false, "保存失败!"));
  308. }
  309. /// <summary>
  310. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  311. /// </summary>
  312. /// <param name="dto"></param>
  313. /// <returns></returns>
  314. [HttpPost]
  315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  316. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  317. {
  318. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  319. _detail.IsDel = 1;
  320. _detail.DeleteUserId = dto.Duty;
  321. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  322. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  323. .SetColumns(it => it.IsDel == _detail.IsDel)
  324. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  325. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  326. .Where(it => it.Id == dto.Id)
  327. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  328. //.WhereColumns(s => s.Id == dto.Id)
  329. .ExecuteCommandAsync();
  330. if (result > 0)
  331. {
  332. return Ok(JsonView(true, "删除成功!"));
  333. }
  334. return Ok(JsonView(false, "删除失败!"));
  335. }
  336. /// <summary>
  337. /// 增加团组流程管控详细表数据
  338. /// </summary>
  339. /// <param name="dto"></param>
  340. /// <returns></returns>
  341. [HttpPost]
  342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  343. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  344. {
  345. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  346. if (DateTime.Now < _detail.ExpectBeginDt)
  347. {
  348. _detail.StepStatus = 0;
  349. }
  350. else
  351. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  352. _detail.StepStatus = 1;
  353. }
  354. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  355. if (result > 0)
  356. {
  357. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  358. return Ok(JsonView(true, "添加成功!", _result));
  359. }
  360. return Ok(JsonView(false, "添加失败!"));
  361. }
  362. #endregion
  363. #region 团组基本信息
  364. /// <summary>
  365. /// 接团信息列表
  366. /// </summary>
  367. /// <param name="dto">团组列表请求dto</param>
  368. /// <returns></returns>
  369. [HttpPost]
  370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  371. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  372. {
  373. var groupData = await _groupRepository.GetGroupList(dto);
  374. if (groupData.Code != 0)
  375. {
  376. return Ok(JsonView(false, groupData.Msg));
  377. }
  378. return Ok(JsonView(groupData.Data));
  379. }
  380. /// <summary>
  381. /// 分页查询团组列表
  382. /// </summary>
  383. /// <param name="dto"></param>
  384. /// <returns></returns>
  385. [HttpPost]
  386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  387. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  388. {
  389. var watch = new Stopwatch();
  390. watch.Start();
  391. RefAsync<int> total = 0;
  392. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  393. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  394. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  395. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  396. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  397. .Distinct()
  398. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  399. watch.Stop();
  400. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  401. }
  402. /// <summary>
  403. /// 接团信息列表 Page Init
  404. /// </summary>
  405. /// <returns></returns>
  406. [HttpPost]
  407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  408. public async Task<IActionResult> PostGroupPageListInit()
  409. {
  410. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  411. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  412. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  413. var _view = new
  414. {
  415. depData = depDatas,
  416. rankData = rankDatas
  417. };
  418. return Ok(JsonView(true, "查询成功!", _view));
  419. }
  420. /// <summary>
  421. /// 接团信息列表 Page
  422. /// </summary>
  423. /// <param name="dto">团组列表请求dto</param>
  424. /// <returns></returns>
  425. [HttpPost]
  426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  427. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  428. {
  429. #region 参数验证
  430. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  431. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  432. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  433. #region 页面操作权限验证
  434. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  435. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  436. #endregion
  437. #endregion
  438. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  439. {
  440. string sqlWhere = string.Empty;
  441. if (dto.IsSure == 0) //未完成
  442. {
  443. sqlWhere += string.Format(@" And IsSure = 0");
  444. }
  445. else if (dto.IsSure == 1) //已完成
  446. {
  447. sqlWhere += string.Format(@" And IsSure = 1");
  448. }
  449. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  450. {
  451. string tj = dto.SearchCriteria;
  452. 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}%')",
  453. tj, tj, tj, tj, tj);
  454. }
  455. if (int.TryParse(dto.Rank, out int rankId))
  456. {
  457. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  458. }
  459. string sqlWhere1 = string.Empty;
  460. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  461. {
  462. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  463. }
  464. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  465. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  466. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  467. JietuanOperator,IsSure,CreateTime,IsBid
  468. From (
  469. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  470. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  471. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  472. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  473. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  474. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  475. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  476. From Grp_DelegationInfo gdi
  477. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  478. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  479. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  480. Where gdi.IsDel = 0 {0}
  481. ) temp {1}", sqlWhere, sqlWhere1);
  482. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  483. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  484. var _view = new
  485. {
  486. PageFuncAuth = pageFunAuthView,
  487. Data = _DelegationList
  488. };
  489. return Ok(JsonView(true, "查询成功!", _view, total));
  490. }
  491. else
  492. {
  493. return Ok(JsonView(false, "查询失败"));
  494. }
  495. }
  496. /// <summary>
  497. /// 团组列表
  498. /// </summary>
  499. /// <returns></returns>
  500. [HttpPost]
  501. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  502. {
  503. #region 参数验证
  504. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  505. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  506. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  507. #region 页面操作权限验证
  508. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  509. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  510. #endregion
  511. #endregion
  512. if (dto.PortType != 1 && dto.PortType != 2)
  513. {
  514. return Ok(JsonView(false, "查询失败!"));
  515. }
  516. string orderbyStr = "order by gdi.CreateTime Desc";
  517. string sqlWhere = string.Empty;
  518. if (dto.IsSure == 0) //未完成
  519. {
  520. sqlWhere += string.Format(@" And IsSure = 0");
  521. }
  522. else if (dto.IsSure == 1) //已完成
  523. {
  524. sqlWhere += string.Format(@" And IsSure = 1");
  525. }
  526. //团组类型
  527. if (dto.TeamDid > 0)
  528. {
  529. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  530. }
  531. //团组名称
  532. if (!string.IsNullOrEmpty(dto.TeamName))
  533. {
  534. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  535. }
  536. //客户名称
  537. if (!string.IsNullOrEmpty(dto.ClientName))
  538. {
  539. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  540. }
  541. //客户单位
  542. if (!string.IsNullOrEmpty(dto.ClientUnit))
  543. {
  544. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  545. }
  546. //出访时间
  547. if (!string.IsNullOrEmpty(dto.visitDataTime))
  548. {
  549. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  550. orderbyStr = "order by gdi.VisitDate";
  551. }
  552. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  553. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  554. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  555. JietuanOperator,IsSure,CreateTime
  556. From (
  557. Select row_number() over({0}) as Row_Number,
  558. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  559. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  560. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  561. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  562. From Grp_DelegationInfo gdi
  563. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  564. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  565. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  566. Where gdi.IsDel = 0 {1}
  567. ) temp ", orderbyStr, sqlWhere);
  568. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  569. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  570. #region 处理所属部门
  571. /*
  572. * 1.sq 和 gyy 等显示 市场部
  573. * 2.王鸽和主管及张总还有管理员号统一国交部
  574. * 2-1. 4 管理员 ,21 张海麟
  575. */
  576. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  577. List<int> userIds1 = new List<int>() { 4, 21 };
  578. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  579. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  580. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  581. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  582. .ToList();
  583. foreach (var item in _DelegationList)
  584. {
  585. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  586. }
  587. #endregion
  588. var _view = new
  589. {
  590. PageFuncAuth = pageFunAuthView,
  591. Data = _DelegationList
  592. };
  593. return Ok(JsonView(true, "查询成功!", _view, total));
  594. }
  595. /// <summary>
  596. /// 接团信息详情
  597. /// </summary>
  598. /// <param name="dto">团组info请求dto</param>
  599. /// <returns></returns>
  600. [HttpPost]
  601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  602. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  603. {
  604. var groupData = await _groupRepository.GetGroupInfo(dto);
  605. if (groupData.Code != 0)
  606. {
  607. return Ok(JsonView(false, groupData.Msg));
  608. }
  609. return Ok(JsonView(groupData.Data));
  610. }
  611. /// <summary>
  612. /// 接团信息 编辑添加
  613. /// 基础信息数据源
  614. /// </summary>
  615. /// <param name="dto"></param>
  616. /// <returns></returns>
  617. [HttpPost]
  618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  619. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  620. {
  621. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  622. if (groupData.Code != 0)
  623. {
  624. return Ok(JsonView(false, groupData.Msg));
  625. }
  626. return Ok(JsonView(groupData.Data));
  627. }
  628. /// <summary>
  629. /// 接团信息 操作(增改)
  630. /// </summary>
  631. /// <param name="dto"></param>
  632. /// <returns></returns>
  633. [HttpPost]
  634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  635. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  636. {
  637. // 创建 Stopwatch 实例
  638. Stopwatch stopwatch = Stopwatch.StartNew();
  639. decimal ffrPrice = 0.00M;
  640. DateTime? visitDt = null;
  641. if (dto.Status == 2)
  642. {
  643. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  644. if (groupInfo != null)
  645. {
  646. ffrPrice = groupInfo.PaymentMoney;
  647. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  648. }
  649. }
  650. var groupData = await _groupRepository.GroupOperation(dto);
  651. if (groupData.Code != 0)
  652. {
  653. return Ok(JsonView(false, groupData.Msg));
  654. }
  655. int diId = 0;
  656. try
  657. {
  658. //添加时 默认加入团组汇率
  659. if (dto.Status == 1) //添加
  660. {
  661. diId = groupData.Data;
  662. //添加默认币种
  663. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  664. //默认分配权限
  665. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  666. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  667. var _managerIds = new List<int>() { 22, 32, 21 };
  668. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  669. if (userIds.Count > 0)
  670. {
  671. userIds.Add(208);
  672. //创建团组管控
  673. GroupStepForDelegation.CreateWorkStep(diId);
  674. //发送消息
  675. string groupName = dto.TeamName;
  676. string createGroupUser = string.Empty;
  677. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  678. if (userInfo != null) createGroupUser = userInfo.CnName;
  679. string title = $"系统通知";
  680. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  681. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  682. }
  683. //默认创建倒推表
  684. await _invertedListRep._Create(dto.UserId, diId);
  685. }
  686. else if (dto.Status == 2)
  687. {
  688. diId = dto.Id;
  689. }
  690. #region 签证人员团组时间通知
  691. #region 计算出访起止时间
  692. var startTime = new DateTime();
  693. var endTime = new DateTime();
  694. if (DateTime.TryParse(dto.VisitDate, out startTime))
  695. {
  696. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  697. }
  698. #endregion
  699. #endregion
  700. #region 团组操作默认添加/修改收款账单
  701. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  702. {
  703. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  704. .Where(x => x.IsDel == 0 &&
  705. x.Diid == diId &&
  706. x.Remark.Equals("预付款")
  707. )
  708. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  709. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  710. .FirstAsync();
  711. ffrInfo = new Fin_ForeignReceivables()
  712. {
  713. Diid = diId,
  714. PriceName = dto.ClientUnit,
  715. Price = dto.PaymentMoney,
  716. Count = 1,
  717. Unit = $"元",
  718. ItemSumPrice = dto.PaymentMoney,
  719. Rate = 1.0000M,
  720. Currency = 836,
  721. AddingWay = 0,
  722. CreateUserId = dto.UserId,
  723. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  724. Remark = $"预付款"
  725. };
  726. if (ffrInfo == null) //Add
  727. {
  728. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  729. }
  730. else //修改
  731. {
  732. await _sqlSugar.Updateable(ffrInfo)
  733. .UpdateColumns(x => new
  734. {
  735. x.PriceName,
  736. x.Price,
  737. x.ItemSumPrice,
  738. x.CreateTime,
  739. x.CreateUserId
  740. })
  741. .WhereColumns(x => x.Id)
  742. .ExecuteCommandAsync();
  743. }
  744. }
  745. #endregion
  746. if (diId > 0)
  747. {
  748. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  749. }
  750. // 停止计时
  751. stopwatch.Stop();
  752. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  753. }
  754. catch (Exception ex)
  755. {
  756. // 停止计时
  757. stopwatch.Stop();
  758. Logs("[response]" + JsonConvert.SerializeObject(dto));
  759. Logs(ex.Message);
  760. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  761. }
  762. // 停止计时
  763. stopwatch.Stop();
  764. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  765. }
  766. /// <summary>
  767. /// 接团流程操作(增改)
  768. /// 安卓端使用 建团时添加客户名单
  769. /// </summary>
  770. /// <param name="dto"></param>
  771. /// <returns></returns>
  772. [HttpPost]
  773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  774. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  775. {
  776. #region 参数验证
  777. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  778. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  779. #region 页面操作权限验证
  780. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  781. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  782. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  783. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  784. #endregion
  785. #endregion
  786. try
  787. {
  788. //_sqlSugar.BeginTran();
  789. decimal ffrPrice = 0.00M;
  790. DateTime? visitDt = null;
  791. if (dto.Status == 2)
  792. {
  793. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  794. if (groupInfo != null)
  795. {
  796. ffrPrice = groupInfo.PaymentMoney;
  797. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  798. }
  799. }
  800. var _dto = new GroupOperationDto();
  801. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  802. var groupData = await _groupRepository.GroupOperation(_dto);
  803. if (groupData.Code != 0)
  804. {
  805. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  806. }
  807. int diId = 0;
  808. //添加时 默认加入团组汇率
  809. if (dto.Status == 1) //添加
  810. {
  811. diId = groupData.Data;
  812. //添加默认币种
  813. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  814. //默认分配权限
  815. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  816. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  817. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  818. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  819. if (userIds.Count > 0)
  820. {
  821. userIds.Add(208);
  822. //创建团组管控
  823. GroupStepForDelegation.CreateWorkStep(diId);
  824. //发送消息
  825. string groupName = dto.TeamName;
  826. string createGroupUser = string.Empty;
  827. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  828. if (userInfo != null) createGroupUser = userInfo.CnName;
  829. string title = $"系统通知";
  830. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  831. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  832. }
  833. #region 应用推送
  834. try
  835. {
  836. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  837. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  838. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  839. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  840. {
  841. List<string> userList = new List<string>() { users.QiyeChatUserId };
  842. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  843. }
  844. }
  845. catch (Exception ex)
  846. {
  847. }
  848. #endregion
  849. //默认创建倒推表
  850. await _invertedListRep._Create(dto.UserId, diId);
  851. }
  852. if (dto.Status == 2)
  853. {
  854. diId = dto.Id;
  855. if (diId == 0)
  856. {
  857. //_sqlSugar.RollbackTran();
  858. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  859. }
  860. }
  861. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  862. if (viewData.Code != 0)
  863. {
  864. //_sqlSugar.RollbackTran();
  865. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  866. }
  867. #region 团组操作默认添加/修改收款账单
  868. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  869. {
  870. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  871. .Where(x => x.IsDel == 0 &&
  872. x.Diid == diId &&
  873. x.Remark.Equals("预付款")
  874. )
  875. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  876. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  877. .FirstAsync();
  878. ffrInfo = new Fin_ForeignReceivables()
  879. {
  880. Diid = diId,
  881. PriceName = dto.ClientUnit,
  882. Price = dto.PaymentMoney,
  883. Count = 1,
  884. Unit = $"元",
  885. ItemSumPrice = dto.PaymentMoney,
  886. Rate = 1.0000M,
  887. Currency = 836,
  888. AddingWay = 0,
  889. CreateUserId = dto.UserId,
  890. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  891. Remark = $"预付款"
  892. };
  893. if (ffrInfo == null) //Add
  894. {
  895. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  896. }
  897. else //修改
  898. {
  899. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  900. .UpdateColumns(x => new
  901. {
  902. x.PriceName,
  903. x.Price,
  904. x.ItemSumPrice,
  905. x.CreateTime,
  906. x.CreateUserId
  907. })
  908. .WhereColumns(x => x.Id)
  909. .ExecuteCommandAsync();
  910. }
  911. }
  912. #endregion
  913. #region 签证人员团组时间通知
  914. #region 计算出访起止时间
  915. var startTime = new DateTime();
  916. var endTime = new DateTime();
  917. if (DateTime.TryParse(dto.VisitDate, out startTime))
  918. {
  919. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  920. }
  921. #endregion
  922. if (diId > 0)
  923. {
  924. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  925. }
  926. #endregion
  927. //_sqlSugar.CommitTran();
  928. return Ok(JsonView(true, "添加成功"));
  929. }
  930. catch (Exception ex)
  931. {
  932. _sqlSugar.RollbackTran();
  933. return Ok(JsonView(false, ex.Message));
  934. }
  935. }
  936. /// <summary>
  937. /// 接团流程操作(增改)
  938. /// 安卓端使用 建团时添加客户名单
  939. /// </summary>
  940. /// <param name="dto"></param>
  941. /// <returns></returns>
  942. [HttpPost]
  943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  944. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  945. {
  946. #region 参数验证
  947. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  948. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  949. #region 页面操作权限验证
  950. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  951. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  952. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  953. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  954. #endregion
  955. #endregion
  956. _sqlSugar.BeginTran();
  957. decimal ffrPrice = 0.00M;
  958. DateTime? visitDt = null;
  959. if (dto.Status == 2)
  960. {
  961. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  962. if (groupInfo != null)
  963. {
  964. ffrPrice = groupInfo.PaymentMoney;
  965. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  966. }
  967. }
  968. var _dto = new GroupOperationDto();
  969. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  970. var groupData = await _groupRepository.GroupOperation(_dto);
  971. if (groupData.Code != 0)
  972. {
  973. _sqlSugar.RollbackTran();
  974. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  975. }
  976. try
  977. {
  978. int diId = 0;
  979. //添加时 默认加入团组汇率
  980. if (dto.Status == 1) //添加
  981. {
  982. diId = groupData.Data;
  983. //添加默认币种
  984. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  985. //默认分配权限
  986. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  987. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  988. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  989. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  990. if (userIds.Count > 0)
  991. {
  992. userIds.Add(208);
  993. //创建团组管控
  994. GroupStepForDelegation.CreateWorkStep(diId);
  995. //发送消息
  996. string groupName = dto.TeamName;
  997. string createGroupUser = string.Empty;
  998. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  999. if (userInfo != null) createGroupUser = userInfo.CnName;
  1000. string title = $"系统通知";
  1001. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1002. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1003. }
  1004. #region 应用推送
  1005. try
  1006. {
  1007. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1008. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1009. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1010. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1011. {
  1012. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1013. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1014. }
  1015. }
  1016. catch (Exception ex)
  1017. {
  1018. _sqlSugar.CommitTran();
  1019. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1020. }
  1021. #endregion
  1022. //默认创建倒推表
  1023. await _invertedListRep._Create(dto.UserId, diId);
  1024. }
  1025. else if (dto.Status == 2)
  1026. {
  1027. diId = dto.Id;
  1028. if (diId == 0)
  1029. {
  1030. _sqlSugar.RollbackTran();
  1031. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1032. }
  1033. }
  1034. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1035. if (viewData.Code != 0)
  1036. {
  1037. _sqlSugar.RollbackTran();
  1038. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1039. }
  1040. #region 团组操作默认添加/修改收款账单
  1041. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1042. {
  1043. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1044. .Where(x => x.IsDel == 0 &&
  1045. x.Diid == diId &&
  1046. x.Remark.Equals("预付款")
  1047. )
  1048. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1049. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1050. .FirstAsync();
  1051. ffrInfo = new Fin_ForeignReceivables()
  1052. {
  1053. Diid = diId,
  1054. PriceName = dto.ClientUnit,
  1055. Price = dto.PaymentMoney,
  1056. Count = 1,
  1057. Unit = $"元",
  1058. ItemSumPrice = dto.PaymentMoney,
  1059. Rate = 1.0000M,
  1060. Currency = 836,
  1061. AddingWay = 0,
  1062. CreateUserId = dto.UserId,
  1063. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1064. Remark = $"预付款"
  1065. };
  1066. if (ffrInfo == null) //Add
  1067. {
  1068. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1069. }
  1070. else //修改
  1071. {
  1072. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1073. .UpdateColumns(x => new
  1074. {
  1075. x.PriceName,
  1076. x.Price,
  1077. x.ItemSumPrice,
  1078. x.CreateTime,
  1079. x.CreateUserId
  1080. })
  1081. .WhereColumns(x => x.Id)
  1082. .ExecuteCommandAsync();
  1083. }
  1084. }
  1085. #endregion
  1086. #region 签证人员团组时间通知
  1087. #region 计算出访起止时间
  1088. var startTime = new DateTime();
  1089. var endTime = new DateTime();
  1090. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1091. {
  1092. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1093. }
  1094. #endregion
  1095. if (diId > 0)
  1096. {
  1097. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1098. }
  1099. #endregion
  1100. _sqlSugar.CommitTran();
  1101. return Ok(JsonView(true));
  1102. }
  1103. catch (Exception ex)
  1104. {
  1105. _sqlSugar.RollbackTran();
  1106. return Ok(JsonView(false, ex.Message));
  1107. }
  1108. }
  1109. /// <summary>
  1110. /// 接团信息 操作(删除)
  1111. /// </summary>
  1112. /// <param name="dto"></param>
  1113. /// <returns></returns>
  1114. [HttpPost]
  1115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1116. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1117. {
  1118. var diId = dto.Id;
  1119. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1120. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1121. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1122. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1123. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1124. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1125. #endregion
  1126. var groupData = await _groupRepository.GroupDel(dto);
  1127. if (groupData.Code != 0)
  1128. {
  1129. return Ok(JsonView(false, groupData.Msg));
  1130. }
  1131. return Ok(JsonView(true));
  1132. }
  1133. /// <summary>
  1134. /// 获取团组销售报价号
  1135. /// 团组添加时 使用
  1136. /// </summary>
  1137. /// <returns></returns>
  1138. [HttpPost]
  1139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1140. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1141. {
  1142. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1143. if (groupData.Code != 0)
  1144. {
  1145. return Ok(JsonView(false, groupData.Msg));
  1146. }
  1147. object salesQuoteNo = new
  1148. {
  1149. SalesQuoteNo = groupData.Data
  1150. };
  1151. return Ok(JsonView(salesQuoteNo));
  1152. }
  1153. /// <summary>
  1154. /// 设置确认出团
  1155. /// </summary>
  1156. /// <param name="dto"></param>
  1157. /// <returns></returns>
  1158. [HttpPost]
  1159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1160. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1161. {
  1162. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1163. if (groupData.Code != 0)
  1164. {
  1165. return Ok(JsonView(false, groupData.Msg));
  1166. }
  1167. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1168. #region OA消息推送
  1169. try
  1170. {
  1171. string groupName = groupInfo.TeamName;
  1172. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1173. string title = $"系统通知";
  1174. string content = $"团组[{groupName}]已确认出团!";
  1175. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. }
  1180. #endregion
  1181. #region 应用推送
  1182. try
  1183. {
  1184. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1185. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1186. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1187. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1188. {
  1189. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1190. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1191. }
  1192. }
  1193. catch (Exception ex)
  1194. {
  1195. }
  1196. #endregion
  1197. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1198. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1199. }
  1200. /// <summary>
  1201. /// 获取团组名称data And 签证国别Data
  1202. /// </summary>
  1203. /// <param name="dto"></param>
  1204. /// <returns></returns>
  1205. [HttpPost]
  1206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1207. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1208. {
  1209. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1210. if (groupData.Code != 0)
  1211. {
  1212. return Ok(JsonView(false, groupData.Msg));
  1213. }
  1214. return Ok(JsonView(groupData.Data));
  1215. }
  1216. /// <summary>
  1217. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1218. /// </summary>
  1219. /// <returns></returns>
  1220. [HttpPost]
  1221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1222. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1223. {
  1224. try
  1225. {
  1226. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1227. if (groupData.Code != 0)
  1228. {
  1229. return Ok(JsonView(false, groupData.Msg));
  1230. }
  1231. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1232. }
  1233. catch (Exception ex)
  1234. {
  1235. return Ok(JsonView(false, "程序错误!"));
  1236. throw;
  1237. }
  1238. }
  1239. /// <summary>
  1240. /// 团组清单 Excel
  1241. /// </summary>
  1242. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1243. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1244. /// <returns></returns>
  1245. [HttpGet]
  1246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1247. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1248. {
  1249. DateTime _beginDt, _endDt;
  1250. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1251. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1252. if (!beginBool && !endBool)
  1253. {
  1254. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1255. }
  1256. string sql = string.Format(@"
  1257. SELECT
  1258. ROW_NUMBER,
  1259. Id,
  1260. SalesQuoteNo,
  1261. TourCode,
  1262. TeamTypeId,
  1263. TeamType,
  1264. TeamLevId,
  1265. TeamLev,
  1266. TeamName,
  1267. ClientName,
  1268. ClientUnit,
  1269. VisitDate,
  1270. VisitDays,
  1271. VisitPNumber,
  1272. JietuanOperatorId,
  1273. JietuanOperator,
  1274. IsSure,
  1275. CreateUserName,
  1276. IsBid
  1277. FROM
  1278. (
  1279. SELECT
  1280. ROW_NUMBER() OVER(
  1281. ORDER BY
  1282. gdi.CreateTime Desc
  1283. ) AS ROW_NUMBER,
  1284. gdi.Id,
  1285. SalesQuoteNo,
  1286. TourCode,
  1287. ssd.Id TeamTypeId,
  1288. ssd.Name TeamType,
  1289. ssd1.Id TeamLevId,
  1290. ssd1.Name TeamLev,
  1291. TeamName,
  1292. ClientName,
  1293. ClientUnit,
  1294. VisitDate,
  1295. VisitDays,
  1296. VisitPNumber,
  1297. JietuanOperator JietuanOperatorId,
  1298. su.CnName JietuanOperator,
  1299. IsSure,
  1300. gdi.CreateTime,
  1301. su1.CnName As CreateUserName,
  1302. gdi.IsBid
  1303. FROM
  1304. Grp_DelegationInfo gdi
  1305. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1306. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1307. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1308. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1309. WHERE
  1310. gdi.IsDel = 0
  1311. AND gdi.IsBid = 0
  1312. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1313. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1314. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1315. #region 处理所属部门
  1316. /*
  1317. * 1.sq 和 gyy 等显示 市场部
  1318. * 2.王鸽和主管及张总还有管理员号统一国交部
  1319. * 2-1. 4 管理员 ,21 张海麟
  1320. */
  1321. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1322. List<int> userIds1 = new List<int>() { 4, 21 };
  1323. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1324. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1325. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1326. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1327. .ToListAsync();
  1328. var droupIds = groupList.Select(it => it.Id).ToList();
  1329. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1330. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1331. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1332. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1333. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1334. {
  1335. DiId = tcl.DiId,
  1336. LastName = dc.LastName,
  1337. FirstName = dc.FirstName,
  1338. Sex = dc.Sex,
  1339. Birthday = dc.BirthDay,
  1340. Company = cc.CompanyFullName,
  1341. Job = dc.Job,
  1342. CreateTime = tcl.CreateTime,
  1343. })
  1344. .ToList();
  1345. foreach (var item in groupList)
  1346. {
  1347. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1348. string groupFirstName = "";
  1349. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1350. if (currDatas.Any())
  1351. {
  1352. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1353. }
  1354. item.GroupFirst = groupFirstName;
  1355. }
  1356. #endregion
  1357. #region Excel
  1358. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1359. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1360. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1361. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1362. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1363. //载入模板
  1364. WorkbookDesigner designer = new WorkbookDesigner();
  1365. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1366. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1367. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1368. dt.TableName = "GroupList";
  1369. designer.SetDataSource(dt);
  1370. designer.Process();
  1371. if (!Directory.Exists(savePath))
  1372. {
  1373. Directory.CreateDirectory(savePath);
  1374. }
  1375. string serverPath = $"{savePath}{fileName}";
  1376. designer.Workbook.Save(serverPath);
  1377. string rst = $"{servicePath}{ftpPath}{fileName}";
  1378. #endregion
  1379. return Ok(JsonView(true, "操作成功!", rst));
  1380. }
  1381. #endregion
  1382. #region 团组&签证
  1383. /// <summary>
  1384. /// 根据团组Id获取签证客户信息List
  1385. /// </summary>
  1386. /// <param name="dto">请求dto</param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1391. {
  1392. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1393. if (groupData.Code != 0)
  1394. {
  1395. return Ok(JsonView(false, groupData.Msg));
  1396. }
  1397. return Ok(JsonView(groupData.Data));
  1398. }
  1399. /// <summary>
  1400. /// IOS获取团组签证拍照上传进度01(团组列表)
  1401. /// </summary>
  1402. /// <param name="dto">请求dto</param>
  1403. /// <returns></returns>
  1404. [HttpPost]
  1405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1406. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1407. {
  1408. if (dto == null)
  1409. {
  1410. return Ok(JsonView(false, "参数为空"));
  1411. }
  1412. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1413. return Ok(JsonView(visaList));
  1414. }
  1415. /// <summary>
  1416. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1417. /// </summary>
  1418. /// <returns></returns>
  1419. [HttpPost]
  1420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1421. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1422. {
  1423. if (dto == null)
  1424. {
  1425. return Ok(JsonView(false, "请求错误:"));
  1426. }
  1427. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1428. return Ok(JsonView(list));
  1429. }
  1430. /// <summary>
  1431. /// IOS获取团组签证拍照上传进度03(相册)
  1432. /// </summary>
  1433. /// <returns></returns>
  1434. [HttpPost]
  1435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1436. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1437. {
  1438. if (dto == null)
  1439. {
  1440. return Ok(JsonView(false, "请求错误:"));
  1441. }
  1442. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1443. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1444. list.ForEach(s => s.url = url);
  1445. return Ok(JsonView(list));
  1446. }
  1447. /// <summary>
  1448. /// IOS获取团组签证拍照上传进度04(图片上传)
  1449. /// </summary>
  1450. /// <param name="dto"></param>
  1451. /// <returns></returns>
  1452. [HttpPost]
  1453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1454. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1455. {
  1456. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1457. //if (!string.IsNullOrEmpty(result))
  1458. //{
  1459. //}
  1460. //else {
  1461. // return Ok(JsonView(false, "上传失败"));
  1462. //}
  1463. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1464. int sucNum = 0;
  1465. try
  1466. {
  1467. foreach (var item in dto.base64DataList)
  1468. {
  1469. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1470. string result = DecodeBase64ToImage(item, imageName);
  1471. if (!string.IsNullOrEmpty(result))
  1472. {
  1473. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1474. pic.CreateUserId = dto.CreateUserId;
  1475. pic.PicName = imageName;
  1476. pic.PicPath = result;
  1477. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1478. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1479. if (insertResult > 0)
  1480. {
  1481. sucNum++;
  1482. }
  1483. }
  1484. }
  1485. }
  1486. catch (Exception ex)
  1487. {
  1488. return Ok(JsonView(false, ex.Message));
  1489. }
  1490. string msg = string.Format(@"成功上传{0}张", sucNum);
  1491. return Ok(JsonView(true, msg));
  1492. }
  1493. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1494. {
  1495. string filename = "";//声明一个string类型的相对路径
  1496. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1497. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1498. try//会有异常抛出,try,catch一下
  1499. {
  1500. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1501. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1502. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1503. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1504. //文件名称
  1505. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1506. //上传的文件的路径
  1507. string filePath = "";
  1508. if (!Directory.Exists(fileDir))
  1509. {
  1510. Directory.CreateDirectory(fileDir);
  1511. }
  1512. //上传的文件的路径
  1513. filePath = fileDir + filename;
  1514. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1515. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1516. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1517. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1518. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1519. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1520. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1521. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1522. bitmap.Dispose();
  1523. }
  1524. catch (Exception e)
  1525. {
  1526. string massage = e.Message;
  1527. Logs("IOS图片上传Error:" + massage);
  1528. //filename = e.Message;
  1529. }
  1530. return filename;//返回相对路径
  1531. }
  1532. /// <summary>
  1533. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1534. /// </summary>
  1535. /// <param name="dto"></param>
  1536. /// <returns></returns>
  1537. [HttpPost]
  1538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1539. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1540. {
  1541. if (dto == null)
  1542. {
  1543. return Ok(JsonView(false, "请求错误:"));
  1544. }
  1545. string msg = "参数错误";
  1546. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1547. {
  1548. try
  1549. {
  1550. //_delegationVisaRep.BeginTran();
  1551. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1552. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1553. .Where(s => s.Id == dto.visaProgressCustomerId)
  1554. .ExecuteCommandAsync();
  1555. if (updCount > 0 && dto.publishCode == 1)
  1556. {
  1557. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1558. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1559. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1560. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1561. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1562. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1563. if (groupData == null)
  1564. {
  1565. _delegationVisaRep.RollbackTran();
  1566. }
  1567. string title = string.Format(@"[签证进度更新]");
  1568. string content = string.Format(@"测试文本");
  1569. bool rst = await _message.AddMsg(new MessageDto()
  1570. {
  1571. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1572. IssuerId = dto.publisher,
  1573. Title = title,
  1574. Content = content,
  1575. ReleaseTime = DateTime.Now,
  1576. UIdList = new List<int> {
  1577. 234
  1578. }
  1579. });
  1580. if (rst)
  1581. {
  1582. return Ok(JsonView(true, "发送通知成功"));
  1583. }
  1584. }
  1585. //_delegationVisaRep.CommitTran();
  1586. }
  1587. catch (Exception)
  1588. {
  1589. //_delegationVisaRep.RollbackTran();
  1590. }
  1591. }
  1592. return Ok(JsonView(true, msg));
  1593. }
  1594. #endregion
  1595. #region 团组任务分配
  1596. /// <summary>
  1597. /// 团组任务分配初始化
  1598. /// </summary>
  1599. /// <returns></returns>
  1600. [HttpPost]
  1601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1602. public async Task<IActionResult> GetTaskAssignmen()
  1603. {
  1604. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1605. if (groupData.Code != 0)
  1606. {
  1607. return Ok(JsonView(false, groupData.Msg));
  1608. }
  1609. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1610. }
  1611. /// <summary>
  1612. /// 团组任务分配查询
  1613. /// </summary>
  1614. /// <param name="dto"></param>
  1615. /// <returns></returns>
  1616. [HttpPost]
  1617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1618. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1619. {
  1620. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1621. if (groupData.Code != 0)
  1622. {
  1623. return Ok(JsonView(false, groupData.Msg));
  1624. }
  1625. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1626. }
  1627. /// <summary>
  1628. /// 团组任务分配操作
  1629. /// </summary>
  1630. /// <param name="dto"></param>
  1631. /// <returns></returns>
  1632. [HttpPost]
  1633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1634. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1635. {
  1636. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1637. if (groupData.Code != 0)
  1638. {
  1639. return Ok(JsonView(false, groupData.Msg));
  1640. }
  1641. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1642. }
  1643. /// <summary>
  1644. /// 团组任务分配
  1645. /// 批量分配
  1646. /// 查询团组
  1647. /// </summary>
  1648. /// <param name="dto"></param>
  1649. /// <returns></returns>
  1650. [HttpPost]
  1651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1652. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1653. {
  1654. //参数验证
  1655. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1656. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1657. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1658. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1659. }
  1660. /// <summary>
  1661. /// 团组任务分配
  1662. /// 批量分配
  1663. /// </summary>
  1664. /// <param name="dto"></param>
  1665. /// <returns></returns>
  1666. [HttpPost]
  1667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1668. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1669. {
  1670. //参数验证
  1671. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1672. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1673. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1674. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1675. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1676. }
  1677. #endregion
  1678. #region 团组费用审核
  1679. /// <summary>
  1680. /// 费用审核
  1681. /// 团组列表 Page
  1682. /// </summary>
  1683. /// <param name="_dto">团组列表请求dto</param>
  1684. /// <returns></returns>
  1685. [HttpPost]
  1686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1687. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1688. {
  1689. #region 参数验证
  1690. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1691. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1692. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1693. #region 页面操作权限验证
  1694. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1695. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1696. #endregion
  1697. #endregion
  1698. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1699. {
  1700. string sqlWhere = string.Empty;
  1701. if (_dto.IsSure == 0) //未完成
  1702. {
  1703. sqlWhere += string.Format(@" And IsSure = 0");
  1704. }
  1705. else if (_dto.IsSure == 1) //已完成
  1706. {
  1707. sqlWhere += string.Format(@" And IsSure = 1");
  1708. }
  1709. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1710. {
  1711. string tj = _dto.SearchCriteria;
  1712. 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}%')",
  1713. tj, tj, tj, tj, tj);
  1714. }
  1715. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1716. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1717. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1718. From (
  1719. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1720. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1721. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1722. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1723. From Grp_DelegationInfo gdi
  1724. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1725. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1726. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1727. Where gdi.IsDel = 0 {0}
  1728. ) temp ", sqlWhere);
  1729. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1730. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1731. var _view = new
  1732. {
  1733. PageFuncAuth = pageFunAuthView,
  1734. Data = _DelegationList
  1735. };
  1736. return Ok(JsonView(true, "查询成功!", _view, total));
  1737. }
  1738. else
  1739. {
  1740. return Ok(JsonView(false, "查询失败"));
  1741. }
  1742. }
  1743. /// <summary>
  1744. /// 获取团组费用审核
  1745. /// </summary>
  1746. /// <param name="_dto"></param>
  1747. /// <returns></returns>
  1748. [HttpPost]
  1749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1750. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1751. {
  1752. try
  1753. {
  1754. #region 参数验证
  1755. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1756. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1757. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1758. #region 页面操作权限验证
  1759. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1760. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1761. #endregion
  1762. #endregion
  1763. var _view = new Grp_CreditCardPaymentView();
  1764. var clientNameList = getSimplClientList(_dto.DiId);
  1765. #region 费用清单
  1766. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1767. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1768. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1769. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1770. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1771. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1772. /*
  1773. * 76://酒店预订
  1774. */
  1775. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1776. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1777. /*
  1778. * 79://车/导游地接
  1779. */
  1780. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1781. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1782. /*
  1783. * 80: //签证
  1784. */
  1785. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1786. /*
  1787. *81: //邀请/公务活动
  1788. */
  1789. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1790. /*
  1791. * 82: //团组客户保险
  1792. */
  1793. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1794. /*
  1795. * Lable = 85 机票预订
  1796. */
  1797. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1798. /*
  1799. * 85 机票预定
  1800. */
  1801. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1802. /*
  1803. * 98 其他款项
  1804. */
  1805. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1806. /*
  1807. * 285:收款退还
  1808. */
  1809. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1810. /*
  1811. * 1015: //超支费用
  1812. */
  1813. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1814. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1815. /*
  1816. * 币种信息
  1817. */
  1818. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1819. /*
  1820. * 车/导游地接 费用类型
  1821. */
  1822. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1823. /*
  1824. * 车/导游地接 费用类型
  1825. */
  1826. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1827. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1828. /*
  1829. * 用户信息
  1830. */
  1831. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1832. /*
  1833. * 费用模块
  1834. */
  1835. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1836. string priceModule = string.Empty;
  1837. if (sdPriceName != null)
  1838. {
  1839. priceModule = sdPriceName.Name;
  1840. }
  1841. /*
  1842. * 成本信息
  1843. */
  1844. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1845. decimal _groupRate = 0.0000M;
  1846. string _groupCurrencyCode = "-";
  1847. if (groupCost != null)
  1848. {
  1849. _groupRate = groupCost.Rate;
  1850. if (int.TryParse(groupCost.Currency, out int _currency))
  1851. {
  1852. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1853. }
  1854. else _groupCurrencyCode = groupCost.Currency;
  1855. }
  1856. string costContentSql = $"Select * From Grp_GroupCost";
  1857. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1858. //处理日期为空的天数
  1859. for (int i = 0; i < groupCostDetails.Count; i++)
  1860. if (i != 0)
  1861. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1862. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1863. /*
  1864. * 处理详情数据
  1865. */
  1866. foreach (var entity in entityList)
  1867. {
  1868. var _detail = new Grp_CreditCardPaymentDetailView();
  1869. _detail.Id = entity.Id;
  1870. _detail.PriceName = priceModule;
  1871. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1872. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1873. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1874. //处理金额
  1875. if (entity.CTable == 1015)
  1876. {
  1877. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1878. if (czInfo != null)
  1879. {
  1880. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1881. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1882. }
  1883. }
  1884. /*
  1885. * 应付款金额
  1886. */
  1887. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1888. string PaymentCurrency_WaitPay = "Unknown";
  1889. string hotelCurrncyCode = "Unknown";
  1890. string hotelCurrncyName = "Unknown";
  1891. if (sdPaymentCurrency_WaitPay != null)
  1892. {
  1893. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1894. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1895. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1896. if (hotelCurrncyCode.Equals("CNY"))
  1897. {
  1898. entity.DayRate = 1.0000M;
  1899. }
  1900. }
  1901. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1902. /*
  1903. * 此次付款金额
  1904. */
  1905. decimal CurrPayStr = 0.00M,
  1906. OriginalCurrPay = 0.00M;
  1907. if (entity.PayPercentage == 0)
  1908. {
  1909. if (entity.PayThenMoney != 0)
  1910. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1911. }
  1912. else
  1913. {
  1914. if (entity.PayMoney != 0)
  1915. {
  1916. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1917. }
  1918. }
  1919. //if (_dto.Label == 79)
  1920. //{
  1921. // string original = string.Empty;
  1922. // if (hotelCurrncyCode.Equals("CNY"))
  1923. // {
  1924. // OriginalCurrPay = CurrPayStr;
  1925. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1926. // }
  1927. // else
  1928. // {
  1929. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1930. // //760 EUR(7600.00 CNY)
  1931. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1932. // }
  1933. //}
  1934. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1935. string original = string.Empty;
  1936. if (hotelCurrncyCode.Equals("CNY"))
  1937. {
  1938. OriginalCurrPay = CurrPayStr;
  1939. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1940. }
  1941. else
  1942. {
  1943. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1944. //760 EUR(7600.00 CNY)
  1945. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1946. }
  1947. /*
  1948. * 剩余尾款
  1949. */
  1950. decimal BalanceStr = 0;
  1951. if (CurrPayStr != 0)
  1952. {
  1953. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1954. BalanceStr = 0;
  1955. else
  1956. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1957. }
  1958. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1959. /*
  1960. * Bus名称
  1961. */
  1962. _detail.BusName = "待增加";
  1963. /*
  1964. *费用所属
  1965. */
  1966. switch (entity.CTable)
  1967. {
  1968. case 76://酒店预订
  1969. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1970. if (hotelReservations != null)
  1971. {
  1972. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1973. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1974. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1975. string roomFeeStr = "", roomFeestr1 = "";
  1976. //是否比较房型价格
  1977. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1978. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1979. roomFeeStr += $"<br/>";
  1980. var roomTotal = 0.00M;
  1981. if (hotelReservations.SingleRoomPrice > 0)
  1982. {
  1983. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1984. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1985. //__isSingle = true;
  1986. roomTotal += fee;
  1987. }
  1988. if (hotelReservations.DoubleRoomPrice > 0)
  1989. {
  1990. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1991. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1992. // __isDouble = true;
  1993. roomTotal += fee;
  1994. }
  1995. if (hotelReservations.SuiteRoomPrice > 0)
  1996. {
  1997. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1998. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1999. //__isSuite = true;
  2000. roomTotal += fee;
  2001. }
  2002. if (hotelReservations.OtherRoomPrice > 0)
  2003. {
  2004. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2005. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2006. //__isOther = true;
  2007. roomTotal += fee;
  2008. }
  2009. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2010. else roomFeeStr += " 0.00 * 0";
  2011. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2012. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2013. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2014. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2015. /*
  2016. * 费用类型
  2017. * 1:房费
  2018. * 2:早餐
  2019. * 3:地税
  2020. * 4:城市税
  2021. * </summary>
  2022. */
  2023. //地税
  2024. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2025. if (governmentRentData != null)
  2026. {
  2027. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2028. governmentRentFee = governmentRentData.Price;
  2029. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2030. if (governmentRentCurrData != null)
  2031. {
  2032. governmentRentCode = governmentRentCurrData.Name;
  2033. governmentRentName = $"({governmentRentCurrData.Remark})";
  2034. }
  2035. }
  2036. //城市税
  2037. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2038. if (cityTaxData != null)
  2039. {
  2040. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2041. cityTaxFee = cityTaxData.Price;
  2042. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2043. if (cityTaxCurrData != null)
  2044. {
  2045. cityTaxCode = cityTaxCurrData.Name;
  2046. cityTaxName = $"({cityTaxCurrData.Remark})";
  2047. }
  2048. }
  2049. //酒店早餐
  2050. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2051. if (breakfastData != null)
  2052. {
  2053. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2054. breakfastFee = breakfastData.Price;
  2055. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2056. if (breakfastCurrData != null)
  2057. {
  2058. breakfastCode = breakfastCurrData.Name;
  2059. breakfastName = $"({breakfastCurrData.Remark})";
  2060. }
  2061. }
  2062. //房间费用
  2063. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2064. if (roomData != null)
  2065. {
  2066. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2067. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2068. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2069. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2070. roomFee = roomData.Price;
  2071. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2072. if (roomCurrData != null)
  2073. {
  2074. roomCode = roomCurrData.Name;
  2075. roomName = $"({roomCurrData.Remark})";
  2076. }
  2077. }
  2078. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2079. string hotelCostStr = "";
  2080. decimal hotelCsotTotal = 0.00M;
  2081. if (groupCost != null)
  2082. {
  2083. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2084. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2085. }
  2086. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2087. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2088. string hotelCost_day = "";
  2089. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2090. foreach (var item in hotelCostDetails1)
  2091. {
  2092. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2093. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2094. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2095. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2096. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2097. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2098. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2099. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2100. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2101. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2102. hotelCost_day += @$"<br/>";
  2103. }
  2104. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2105. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2106. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2107. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2108. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2109. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2110. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2111. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2112. $"房间说明: {hotelReservations.Remark} <br/>" +
  2113. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2114. $"{hotelBreakfastStr}" +
  2115. $"{hotelGovernmentRentStr}" +
  2116. $"{hotelCityTaxStr}";
  2117. _detail.PriceNameContent = hotelReservations.HotelName;
  2118. }
  2119. break;
  2120. case 79://车/导游地接
  2121. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2122. if (touristGuideGroundReservations != null)
  2123. {
  2124. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2125. {
  2126. _detail.BusName = touristGuideGroundReservations.BusName;
  2127. }
  2128. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2129. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2130. //if (isInt)
  2131. //{
  2132. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2133. // if (cityInfo != null)
  2134. // {
  2135. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2136. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2137. // if (carFeeItem != null)
  2138. // {
  2139. // nameContent += $@"({carFeeItem.Name})";
  2140. // }
  2141. // _detail.PriceNameContent = nameContent;
  2142. // }
  2143. //}
  2144. //else
  2145. //{
  2146. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2147. //}
  2148. var touristGuideGroundReservationsContents =
  2149. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2150. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2151. foreach (var item in touristGuideGroundReservationsContents)
  2152. {
  2153. string typeName = "Unknown";
  2154. string carCurrencyCode = "Unknown";
  2155. string carCurrencyName = "Unknown";
  2156. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2157. if (carTypeData != null) typeName = carTypeData.Name;
  2158. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2159. if (currencyData != null)
  2160. {
  2161. carCurrencyCode = currencyData.Name;
  2162. carCurrencyName = currencyData.Remark;
  2163. }
  2164. //op、成本 币种是否一致
  2165. bool IsCurrencyAgreement = false;
  2166. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2167. string opCostStr = string.Empty;
  2168. decimal opCostTypePrice = 0.00M;
  2169. #region 处理成本各项费用
  2170. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2171. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2172. if (opCost.Count > 0)
  2173. {
  2174. switch (item.SId)
  2175. {
  2176. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2177. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2178. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2179. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2180. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2181. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2182. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2183. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2184. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2185. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2186. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2187. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2188. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2189. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2190. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2191. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2192. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2193. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2194. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2195. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2196. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2197. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2198. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2200. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2201. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2202. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2203. }
  2204. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2205. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2206. }
  2207. #endregion
  2208. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2209. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2210. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2211. $"{opTypeStr} {opCostStr}<br/>" +
  2212. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2213. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2214. }
  2215. _detail.PriceMsgContent = priceMsg;
  2216. }
  2217. break;
  2218. case 80: //签证
  2219. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2220. if (visaInfo != null)
  2221. {
  2222. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2223. _detail.PriceNameContent = visaInfo.VisaDescription;
  2224. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2225. }
  2226. break;
  2227. case 81: //邀请/公务活动
  2228. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2229. if (_ioa != null)
  2230. {
  2231. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2232. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2233. sendCurrName = "Unknown", //快递费用币种 Name
  2234. sendCurrCode = "Unknown", //快递费用币种 Code
  2235. eventsCurrName = "Unknown", //公务活动费币种 Name
  2236. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2237. translateCurrName = "Unknown", //公务翻译费 Name
  2238. translateCurrCode = "Unknown"; //公务翻译费 Code
  2239. #region 处理费用币种
  2240. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2241. if (inviteCurrData != null)
  2242. {
  2243. inviteCurrName = inviteCurrData.Remark;
  2244. inviteCurrCode = inviteCurrData.Name;
  2245. }
  2246. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2247. if (sendCurrData != null)
  2248. {
  2249. sendCurrName = sendCurrData.Remark;
  2250. sendCurrCode = sendCurrData.Name;
  2251. }
  2252. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2253. if (eventsCurrData != null)
  2254. {
  2255. eventsCurrName = eventsCurrData.Remark;
  2256. eventsCurrCode = eventsCurrData.Name;
  2257. }
  2258. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2259. if (translateCurrData != null)
  2260. {
  2261. translateCurrName = translateCurrData.Remark;
  2262. translateCurrCode = translateCurrData.Name;
  2263. }
  2264. #endregion
  2265. _detail.PriceNameContent = _ioa.InviterArea;
  2266. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2267. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2268. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2269. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2270. $@"备注:" + _ioa.Remark + "<br/>";
  2271. }
  2272. break;
  2273. case 82: //团组客户保险
  2274. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2275. if (customers != null)
  2276. {
  2277. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2278. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2279. }
  2280. break;
  2281. case 85: //机票预订
  2282. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2283. if (jpRes != null)
  2284. {
  2285. string FlightsDescription = jpRes.FlightsDescription;
  2286. string PriceDescription = jpRes.PriceDescription;
  2287. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2288. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2289. }
  2290. break;
  2291. case 98://其他款项
  2292. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2293. if (gdpRes != null)
  2294. {
  2295. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2296. _detail.PriceNameContent = gdpRes.PriceName;
  2297. }
  2298. break;
  2299. case 285://收款退还
  2300. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2301. if (refundAndOtherMoney != null)
  2302. {
  2303. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2304. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2305. }
  2306. break;
  2307. case 751://酒店早餐
  2308. break;
  2309. case 1015://超支费用
  2310. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2311. if (groupExtraCost != null)
  2312. {
  2313. _detail.PriceNameContent = groupExtraCost.PriceName;
  2314. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2315. }
  2316. break;
  2317. default:
  2318. break;
  2319. }
  2320. /*
  2321. * 申请人
  2322. */
  2323. string operatorName = " - ";
  2324. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2325. if (_opUser != null)
  2326. {
  2327. operatorName = _opUser.CnName;
  2328. }
  2329. _detail.OperatorName = operatorName;
  2330. /*
  2331. * 审核人
  2332. */
  2333. string auditOperatorName = "Unknown";
  2334. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2335. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2336. else
  2337. {
  2338. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2339. if (_adUser != null)
  2340. {
  2341. auditOperatorName = _adUser.CnName;
  2342. }
  2343. }
  2344. _detail.AuditOperatorName = auditOperatorName;
  2345. /*
  2346. * 超预算比例
  2347. */
  2348. string overBudgetStr = "";
  2349. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2350. else if (entity.ExceedBudget == 0)
  2351. {
  2352. if (entity.CTable == 76 || entity.CTable == 79)
  2353. {
  2354. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2355. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2356. }
  2357. else
  2358. {
  2359. overBudgetStr = "未超预算";
  2360. }
  2361. }
  2362. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2363. _detail.OverBudget = overBudgetStr;
  2364. decimal auditFee = 0.00M; //已审核金额 人名币
  2365. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2366. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2367. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2368. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2369. {
  2370. auditedFeeOriginal = entity.PayMoney;
  2371. auditFee = CurrPayStr;
  2372. }
  2373. else if (entity.IsAuditGM == 0)
  2374. {
  2375. unAuditFeeCNY = CurrPayStr;
  2376. unAuditFeeOriginal = OriginalCurrPay;
  2377. OriginalCurrPay = 0.00M;
  2378. }
  2379. /*
  2380. * 费用总计
  2381. */
  2382. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2383. {
  2384. CurrencyId = entity.PaymentCurrency,
  2385. CurrencyName = PaymentCurrency_WaitPay,
  2386. AmountPayable = entity.PayMoney,
  2387. ThisPayment = OriginalCurrPay,
  2388. BalancePayment = BalanceStr,
  2389. AuditedFunds = auditFee,
  2390. AuditedFundsOriginal = auditedFeeOriginal,
  2391. UnAuditFundsCNY = unAuditFeeCNY,
  2392. UnAuditFundsOriginal = unAuditFeeOriginal
  2393. });
  2394. _detail.IsAuditGM = entity.IsAuditGM;
  2395. detailList.Add(_detail);
  2396. }
  2397. #endregion
  2398. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2399. /*
  2400. * 下方描述处理
  2401. */
  2402. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2403. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2404. if (ccpCurrencyPrice != null)
  2405. {
  2406. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2407. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2408. }
  2409. else
  2410. {
  2411. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2412. }
  2413. string amountPayableStr = string.Format(@"应付款总金额: ");
  2414. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2415. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2416. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2417. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2418. foreach (var item in nonDuplicat)
  2419. {
  2420. var currencyName = item.CurrencyName;
  2421. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2422. if (strs.Count > 0)
  2423. {
  2424. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2425. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2426. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2427. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2428. //单独处理此次付款金额
  2429. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2430. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2431. //单独处理已审核费用
  2432. //if (item.CurrencyId == 836) //人民币
  2433. //{
  2434. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2435. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2436. //}
  2437. //else
  2438. //{
  2439. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2440. //}
  2441. if (currencyName.Equals("CNY"))
  2442. {
  2443. //已审核费用
  2444. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2445. //未审核费用
  2446. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2447. }
  2448. else
  2449. {
  2450. //已审核费用
  2451. 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"));
  2452. //未审核费用
  2453. 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"));
  2454. }
  2455. }
  2456. }
  2457. _view.TotalStr1 = amountPayableStr[..^1];
  2458. _view.TotalStr2 = thisPaymentStr[..^1];
  2459. _view.TotalStr3 = balancePaymentStr[..^1];
  2460. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2461. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2462. var _view1 = new
  2463. {
  2464. PageFuncAuth = pageFunAuthView,
  2465. Data = _view
  2466. };
  2467. return Ok(JsonView(_view1));
  2468. }
  2469. catch (Exception ex)
  2470. {
  2471. return Ok(JsonView(false, ex.Message));
  2472. }
  2473. }
  2474. /// <summary>
  2475. /// 费用审核
  2476. /// 修改团组费用审核状态
  2477. /// </summary>
  2478. /// <param name="_dto">参数Json字符串</param>
  2479. /// <returns></returns>
  2480. [HttpPost]
  2481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2482. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2483. {
  2484. #region 参数验证
  2485. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2486. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2487. #endregion
  2488. #region 页面操作权限验证
  2489. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2490. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2491. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2492. #endregion
  2493. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2494. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2495. DateTime dtNow = DateTime.Now;
  2496. _groupRepository.BeginTran();
  2497. int rst = 0;
  2498. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2499. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2500. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2501. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2502. List<dynamic> msgDatas = new List<dynamic>();
  2503. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2504. foreach (var item in idList)
  2505. {
  2506. int CreditId = int.Parse(item);
  2507. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2508. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2509. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2510. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2511. .Where(s => s.Id == CreditId)
  2512. .ExecuteCommandAsync();
  2513. if (result < 1)
  2514. {
  2515. rst = -1;
  2516. _groupRepository.RollbackTran();
  2517. return Ok(JsonView(false, "操作失败并回滚!"));
  2518. }
  2519. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2520. if (creditData != null)
  2521. {
  2522. #region 应用通知配置
  2523. try
  2524. {
  2525. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2526. }
  2527. catch (Exception ex)
  2528. {
  2529. }
  2530. #endregion
  2531. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2532. string groupNameStr = string.Empty;
  2533. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2534. if (groupData != null) groupNameStr = groupData.TeamName;
  2535. string creditTypeStr = string.Empty;
  2536. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2537. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2538. string creditCurrency = string.Empty;
  2539. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2540. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2541. if (creditCurrency.Equals("CNY"))
  2542. {
  2543. creditData.DayRate = 1.0000M;
  2544. }
  2545. if (creditData.PayPercentage == 0.00M)
  2546. {
  2547. creditData.PayPercentage = 100M;
  2548. }
  2549. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2550. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2551. string msgContent = "";
  2552. if (creditCurrency.Equals("CNY"))
  2553. {
  2554. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2555. }
  2556. else
  2557. {
  2558. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2559. }
  2560. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2561. }
  2562. }
  2563. if (rst == 0)
  2564. {
  2565. _groupRepository.CommitTran();
  2566. foreach (var item in msgDatas)
  2567. {
  2568. //发送消息
  2569. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2570. }
  2571. #region 应用推送
  2572. try
  2573. {
  2574. foreach (var ccpId in dic_ccp_user.Keys)
  2575. {
  2576. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2577. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2578. }
  2579. }
  2580. catch (Exception)
  2581. {
  2582. }
  2583. #endregion
  2584. return Ok(JsonView(true, "操作成功!"));
  2585. }
  2586. return Ok(JsonView(false, "操作失败!"));
  2587. }
  2588. #endregion
  2589. #region 机票费用录入
  2590. /// <summary>
  2591. /// 机票录入当前登录人可操作团组
  2592. /// </summary>
  2593. /// <param name="dto"></param>
  2594. /// <returns></returns>
  2595. [HttpPost]
  2596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2597. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2598. {
  2599. try
  2600. {
  2601. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2602. if (groupData.Code != 0)
  2603. {
  2604. return Ok(JsonView(false, groupData.Msg));
  2605. }
  2606. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2607. }
  2608. catch (Exception ex)
  2609. {
  2610. return Ok(JsonView(false, "程序错误!"));
  2611. throw;
  2612. }
  2613. }
  2614. /// <summary>
  2615. /// 机票费用录入列表
  2616. /// </summary>
  2617. /// <param name="dto"></param>
  2618. /// <returns></returns>
  2619. [HttpPost]
  2620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2621. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2622. {
  2623. try
  2624. {
  2625. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2626. if (groupData.Code != 0)
  2627. {
  2628. return Ok(JsonView(false, groupData.Msg));
  2629. }
  2630. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2631. }
  2632. catch (Exception ex)
  2633. {
  2634. return Ok(JsonView(false, ex.Message));
  2635. throw;
  2636. }
  2637. }
  2638. /// <summary>
  2639. /// 根据id查询费用录入信息
  2640. /// </summary>
  2641. /// <param name="dto"></param>
  2642. /// <returns></returns>
  2643. [HttpPost]
  2644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2645. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2646. {
  2647. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2648. if (groupData.Code != 0)
  2649. {
  2650. return Ok(JsonView(false, groupData.Msg));
  2651. }
  2652. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2653. }
  2654. /// <summary>
  2655. /// 机票费用录入操作(Status:1.新增,2.修改)
  2656. /// </summary>
  2657. /// <param name="dto"></param>
  2658. /// <returns></returns>
  2659. [HttpPost]
  2660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2661. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2662. {
  2663. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2664. if (groupData.Code != 0)
  2665. {
  2666. return Ok(JsonView(false, groupData.Msg));
  2667. }
  2668. #region 应用推送
  2669. try
  2670. {
  2671. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2672. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2673. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2674. //2024-10-21 新增LZ UID
  2675. var userIds = new List<int>() { 21 };
  2676. string title = $"系统通知";
  2677. string content = "";
  2678. var diId = dto.AirTicketResOpData.DiId;
  2679. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2680. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2681. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2682. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2683. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2684. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2685. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2686. }
  2687. catch (Exception ex)
  2688. {
  2689. }
  2690. #endregion
  2691. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2692. }
  2693. /// <summary>
  2694. /// 根据舱位类型查询接团客户名单信息
  2695. /// </summary>
  2696. /// <param name="dto"></param>
  2697. /// <returns></returns>
  2698. [HttpPost]
  2699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2700. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2701. {
  2702. try
  2703. {
  2704. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2705. if (crm_Groups.Count != 0)
  2706. {
  2707. List<dynamic> Customer = new List<dynamic>();
  2708. foreach (var item in crm_Groups)
  2709. {
  2710. var data = new
  2711. {
  2712. Id = item.Id,
  2713. Pinyin = item.Pinyin,
  2714. Name = item.LastName + item.FirstName
  2715. };
  2716. Customer.Add(data);
  2717. }
  2718. return Ok(JsonView(true, "查询成功!", Customer));
  2719. }
  2720. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2721. }
  2722. catch (Exception ex)
  2723. {
  2724. return Ok(JsonView(false, "程序错误!"));
  2725. throw;
  2726. }
  2727. }
  2728. /// <summary>
  2729. /// 根据团号获取客户信息
  2730. /// </summary>
  2731. /// <param name="dto"></param>
  2732. /// <returns></returns>
  2733. [HttpPost]
  2734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2735. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2736. {
  2737. var jw = JsonView(false);
  2738. if (dto.DIID < 1)
  2739. {
  2740. jw.Msg += "请输入正确的diid";
  2741. return Ok(jw);
  2742. }
  2743. var arr = getSimplClientList(dto.DIID);
  2744. jw = JsonView(true, "获取成功!", arr);
  2745. return Ok(jw);
  2746. }
  2747. private List<SimplClientInfo> getSimplClientList(int diId)
  2748. {
  2749. 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);
  2750. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2751. foreach (var item in arr)
  2752. {
  2753. EncryptionProcessor.DecryptProperties(item);
  2754. }
  2755. return arr;
  2756. }
  2757. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2758. {
  2759. string result = origin;
  2760. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2761. {
  2762. string[] temparr = origin.Split(',');
  2763. string fistrStr = temparr[0];
  2764. int count = temparr.Count();
  2765. int tempId;
  2766. bool success = int.TryParse(fistrStr, out tempId);
  2767. if (success)
  2768. {
  2769. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2770. if (tempInfo != null)
  2771. {
  2772. if (count > 1)
  2773. {
  2774. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2775. }
  2776. else
  2777. {
  2778. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2779. }
  2780. }
  2781. }
  2782. }
  2783. return result;
  2784. }
  2785. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2786. {
  2787. string result = origin;
  2788. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2789. {
  2790. string[] temparr = origin.Split(',');
  2791. result = "";
  2792. foreach (var item in temparr)
  2793. {
  2794. int tempId;
  2795. bool success = int.TryParse(item, out tempId);
  2796. if (success)
  2797. {
  2798. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2799. if (tempInfo != null)
  2800. {
  2801. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2802. }
  2803. }
  2804. }
  2805. }
  2806. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2807. return result;
  2808. }
  2809. /// <summary>
  2810. /// 机票费用录入,删除
  2811. /// </summary>
  2812. /// <param name="dto"></param>
  2813. /// <returns></returns>
  2814. [HttpPost]
  2815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2816. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2817. {
  2818. try
  2819. {
  2820. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2821. if (res)
  2822. {
  2823. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2824. {
  2825. IsDel = 1,
  2826. DeleteUserId = dto.DeleteUserId,
  2827. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2828. }).ExecuteCommandAsync();
  2829. return Ok(JsonView(true, "删除成功!"));
  2830. }
  2831. return Ok(JsonView(false, "删除失败!"));
  2832. }
  2833. catch (Exception ex)
  2834. {
  2835. return Ok(JsonView(false, "程序错误!"));
  2836. throw;
  2837. }
  2838. }
  2839. /// <summary>
  2840. /// 导出机票录入报表
  2841. /// </summary>
  2842. /// <param name="dto"></param>
  2843. /// <returns></returns>
  2844. [HttpPost]
  2845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2846. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2847. {
  2848. try
  2849. {
  2850. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2851. if (groupData.Code != 0)
  2852. {
  2853. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2854. }
  2855. else
  2856. {
  2857. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2858. if (AirTicketReservations.Count != 0)
  2859. {
  2860. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2861. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2862. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2863. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2864. WorkbookDesigner designer = new WorkbookDesigner();
  2865. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2866. decimal countCost = 0;
  2867. foreach (var item in AirTicketReservations)
  2868. {
  2869. #region 处理客人姓名
  2870. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2871. item.ClientName = clientNames;
  2872. #endregion
  2873. if (item.BankType == "其他")
  2874. {
  2875. item.BankNo = "--";
  2876. }
  2877. else
  2878. {
  2879. if (!string.IsNullOrEmpty(item.BankType))
  2880. {
  2881. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2882. }
  2883. }
  2884. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2885. item.Price = System.Decimal.Round(item.Price, 2);
  2886. countCost += Convert.ToDecimal(item.Price);
  2887. }
  2888. designer.SetDataSource("Export", AirTicketReservations);
  2889. designer.SetDataSource("ExportDiCode", diCode);
  2890. designer.SetDataSource("ExportDiName", diName);
  2891. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2892. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2893. designer.Process();
  2894. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2895. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2896. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2897. return Ok(JsonView(true, "成功", url = rst));
  2898. }
  2899. else
  2900. {
  2901. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2902. }
  2903. }
  2904. }
  2905. catch (Exception ex)
  2906. {
  2907. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2908. throw;
  2909. }
  2910. }
  2911. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2912. /// <summary>
  2913. /// 行程单导出
  2914. /// </summary>
  2915. /// <param name="dto"></param>
  2916. /// <returns></returns>
  2917. [HttpPost]
  2918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2919. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2920. {
  2921. try
  2922. {
  2923. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2924. if (groupData.Code != 0)
  2925. {
  2926. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2927. }
  2928. else
  2929. {
  2930. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2931. if (dto.Language == "CN")
  2932. {
  2933. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2934. DocumentBuilder builder = new DocumentBuilder(doc);
  2935. int tableIndex = 0;//表格索引
  2936. //得到文档中的第一个表格
  2937. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2938. foreach (var item in _AirTicketReservations)
  2939. {
  2940. #region 处理固定数据
  2941. string[] FlightsCode = item.FlightsCode.Split('/');
  2942. if (FlightsCode.Length != 0)
  2943. {
  2944. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2945. if (_AirCompany != null)
  2946. {
  2947. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2948. }
  2949. else
  2950. {
  2951. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2952. }
  2953. }
  2954. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2955. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2956. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2957. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2958. string name = "";
  2959. foreach (string clientName in nameArray)
  2960. {
  2961. if (!name.Contains(clientName))
  2962. {
  2963. name += clientName + ",";
  2964. }
  2965. }
  2966. if (!string.IsNullOrWhiteSpace(name))
  2967. {
  2968. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2969. }
  2970. else
  2971. {
  2972. table.Range.Bookmarks["ClientName"].Text = "--";
  2973. }
  2974. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2975. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2976. table.Range.Bookmarks["JointTicket"].Text = "--";
  2977. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2978. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2979. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2980. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2981. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2982. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2983. #endregion
  2984. #region 循环数据处理
  2985. List<AirInfo> airs = new List<AirInfo>();
  2986. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2987. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2988. for (int i = 0; i < FlightsCode.Length; i++)
  2989. {
  2990. AirInfo air = new AirInfo();
  2991. string[] tempstr = DayArray[i]
  2992. .Replace("\r\n", string.Empty)
  2993. .Replace("\\r\\n", string.Empty)
  2994. .TrimStart().TrimEnd()
  2995. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2996. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2997. string starCity = "";
  2998. if (star_Three != null)
  2999. {
  3000. starCity = star_Three.AirPort;
  3001. }
  3002. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3003. string EndCity = "";
  3004. if (End_Three != null)
  3005. {
  3006. EndCity = End_Three.AirPort;
  3007. }
  3008. air.Destination = starCity + "/" + EndCity;
  3009. air.Flight = FlightsCode[i];
  3010. air.SeatingClass = item.CTypeName;
  3011. string dateTime = tempstr[2];
  3012. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3013. air.FlightDate = DateTemp;
  3014. air.DepartureTime = tempstr[5];
  3015. air.LandingTime = tempstr[6];
  3016. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3017. air.TicketStatus = "--";
  3018. air.Luggage = "--";
  3019. air.DepartureTerminal = "--";
  3020. air.LandingTerminal = "--";
  3021. airs.Add(air);
  3022. }
  3023. int row = 13;
  3024. for (int i = 0; i < airs.Count; i++)
  3025. {
  3026. if (airs.Count > 2)
  3027. {
  3028. for (int j = 0; j < airs.Count - 2; j++)
  3029. {
  3030. var CopyRow = table.Rows[12].Clone(true);
  3031. table.Rows.Add(CopyRow);
  3032. }
  3033. }
  3034. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3035. int index = 0;
  3036. foreach (PropertyInfo property in properties)
  3037. {
  3038. string value = property.GetValue(airs[i]).ToString();
  3039. Cell ishcel0 = table.Rows[row].Cells[index];
  3040. Paragraph p = new Paragraph(doc);
  3041. string s = value;
  3042. p.AppendChild(new Run(doc, s));
  3043. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3044. ishcel0.AppendChild(p);
  3045. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3046. index++;
  3047. }
  3048. row++;
  3049. }
  3050. #endregion
  3051. Paragraph lastParagraph = new Paragraph(doc);
  3052. //第一个表格末尾加段落
  3053. table.ParentNode.InsertAfter(lastParagraph, table);
  3054. //复制第一个表格
  3055. Table cloneTable = (Table)table.Clone(true);
  3056. //在文档末尾段落后面加入复制的表格
  3057. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3058. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3059. {
  3060. int rownewsIndex = 13;
  3061. for (int i = 0; i < 2; i++)
  3062. {
  3063. var CopyRow = table.Rows[12].Clone(true);
  3064. table.Rows.RemoveAt(13);
  3065. table.Rows.Add(CopyRow);
  3066. rownewsIndex++;
  3067. }
  3068. }
  3069. else
  3070. {
  3071. table.Rows.RemoveAt(12);
  3072. }
  3073. cloneTable.Rows.RemoveAt(12);
  3074. }
  3075. if (_AirTicketReservations.Count != 0)
  3076. {
  3077. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3078. if (FlightsCode.Length != 0)
  3079. {
  3080. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3081. if (_AirCompany != null)
  3082. {
  3083. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3084. }
  3085. else
  3086. {
  3087. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3088. }
  3089. }
  3090. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3091. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3092. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3093. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3094. string name = "";
  3095. foreach (string clientName in nameArray)
  3096. {
  3097. if (!name.Contains(clientName))
  3098. {
  3099. name += clientName + ",";
  3100. }
  3101. }
  3102. if (!string.IsNullOrWhiteSpace(name))
  3103. {
  3104. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3105. }
  3106. else
  3107. {
  3108. table.Range.Bookmarks["ClientName"].Text = "--";
  3109. }
  3110. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3111. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3112. table.Range.Bookmarks["JointTicket"].Text = "--";
  3113. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3114. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3115. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3116. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3117. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3118. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3119. }
  3120. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3121. //保存合并后的文档
  3122. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3123. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3124. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3125. return Ok(JsonView(true, "成功!", rst));
  3126. }
  3127. else
  3128. {
  3129. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3130. DocumentBuilder builder = new DocumentBuilder(doc);
  3131. int tableIndex = 0;//表格索引
  3132. //得到文档中的第一个表格
  3133. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3134. List<string> texts = new List<string>();
  3135. foreach (var item in _AirTicketReservations)
  3136. {
  3137. string[] FlightsCode = item.FlightsCode.Split('/');
  3138. if (FlightsCode.Length != 0)
  3139. {
  3140. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3141. if (_AirCompany != null)
  3142. {
  3143. if (!transDic.ContainsKey(_AirCompany.CnName))
  3144. {
  3145. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3146. }
  3147. }
  3148. else
  3149. {
  3150. if (!transDic.ContainsKey("--"))
  3151. {
  3152. transDic.Add("--", "--");
  3153. }
  3154. }
  3155. }
  3156. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3157. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3158. string name = "";
  3159. foreach (string clientName in nameArray)
  3160. {
  3161. name += clientName + ",";
  3162. }
  3163. if (!texts.Contains(name))
  3164. {
  3165. texts.Add(name);
  3166. }
  3167. List<AirInfo> airs = new List<AirInfo>();
  3168. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3169. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3170. for (int i = 0; i < FlightsCode.Length; i++)
  3171. {
  3172. AirInfo air = new AirInfo();
  3173. string[] tempstr = DayArray[i]
  3174. .Replace("\r\n", string.Empty)
  3175. .Replace("\\r\\n", string.Empty)
  3176. .TrimStart().TrimEnd()
  3177. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3178. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3179. if (star_Three != null)
  3180. {
  3181. if (!transDic.ContainsKey(star_Three.AirPort))
  3182. {
  3183. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3184. }
  3185. }
  3186. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3187. if (End_Three != null)
  3188. {
  3189. if (!transDic.ContainsKey(End_Three.AirPort))
  3190. {
  3191. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3192. }
  3193. }
  3194. if (!texts.Contains(item.CTypeName))
  3195. {
  3196. texts.Add(item.CTypeName);
  3197. }
  3198. }
  3199. }
  3200. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3201. if (transData.Count > 0)
  3202. {
  3203. foreach (TranslateResult item in transData)
  3204. {
  3205. if (!transDic.ContainsKey(item.Query))
  3206. {
  3207. transDic.Add(item.Query, item.Translation);
  3208. }
  3209. }
  3210. }
  3211. foreach (var item in _AirTicketReservations)
  3212. {
  3213. #region 处理固定数据
  3214. string[] FlightsCode = item.FlightsCode.Split('/');
  3215. if (FlightsCode.Length != 0)
  3216. {
  3217. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3218. if (_AirCompany != null)
  3219. {
  3220. string str = "--";
  3221. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3222. if (!string.IsNullOrEmpty(translateResult))
  3223. {
  3224. str = translateResult;
  3225. str = _airTicketResRep.Processing(str);
  3226. }
  3227. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3228. }
  3229. else
  3230. {
  3231. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3232. }
  3233. }
  3234. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3235. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3236. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3237. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3238. string names = "";
  3239. foreach (string clientName in nameArray)
  3240. {
  3241. names += clientName + ",";
  3242. }
  3243. if (!string.IsNullOrWhiteSpace(names))
  3244. {
  3245. string str = "--";
  3246. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3247. if (!string.IsNullOrEmpty(translateResult))
  3248. {
  3249. str = translateResult;
  3250. str = _airTicketResRep.Processing(str);
  3251. }
  3252. table.Range.Bookmarks["ClientName"].Text = str;
  3253. }
  3254. else
  3255. {
  3256. table.Range.Bookmarks["ClientName"].Text = "--";
  3257. }
  3258. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3259. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3260. table.Range.Bookmarks["JointTicket"].Text = "--";
  3261. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3262. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3263. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3264. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3265. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3266. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3267. #endregion
  3268. #region 循环数据处理
  3269. List<AirInfo> airs = new List<AirInfo>();
  3270. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3271. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3272. for (int i = 0; i < FlightsCode.Length; i++)
  3273. {
  3274. AirInfo air = new AirInfo();
  3275. string[] tempstr = DayArray[i]
  3276. .Replace("\r\n", string.Empty)
  3277. .Replace("\\r\\n", string.Empty)
  3278. .TrimStart().TrimEnd()
  3279. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3280. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3281. string starCity = "";
  3282. if (star_Three != null)
  3283. {
  3284. string str2 = "--";
  3285. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3286. if (!string.IsNullOrEmpty(translateResult2))
  3287. {
  3288. str2 = translateResult2;
  3289. str2 = _airTicketResRep.Processing(str2);
  3290. }
  3291. starCity = str2;
  3292. }
  3293. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3294. string EndCity = "";
  3295. if (End_Three != null)
  3296. {
  3297. string str1 = "--";
  3298. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3299. if (!string.IsNullOrEmpty(translateResult1))
  3300. {
  3301. str1 = translateResult1;
  3302. str1 = _airTicketResRep.Processing(str1);
  3303. }
  3304. EndCity = str1;
  3305. }
  3306. air.Destination = starCity + "/" + EndCity;
  3307. air.Flight = FlightsCode[i];
  3308. string str = "--";
  3309. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3310. if (!string.IsNullOrEmpty(translateResult))
  3311. {
  3312. str = translateResult;
  3313. str = _airTicketResRep.Processing(str);
  3314. }
  3315. air.SeatingClass = str;
  3316. string dateTime = tempstr[2];
  3317. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3318. air.FlightDate = DateTemp;
  3319. air.DepartureTime = tempstr[5];
  3320. air.LandingTime = tempstr[6];
  3321. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3322. air.TicketStatus = "--";
  3323. air.Luggage = "--";
  3324. air.DepartureTerminal = "--";
  3325. air.LandingTerminal = "--";
  3326. airs.Add(air);
  3327. }
  3328. int row = 13;
  3329. for (int i = 0; i < airs.Count; i++)
  3330. {
  3331. if (airs.Count > 2)
  3332. {
  3333. for (int j = 0; j < airs.Count - 2; j++)
  3334. {
  3335. var CopyRow = table.Rows[12].Clone(true);
  3336. table.Rows.Add(CopyRow);
  3337. }
  3338. }
  3339. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3340. int index = 0;
  3341. foreach (PropertyInfo property in properties)
  3342. {
  3343. string value = property.GetValue(airs[i]).ToString();
  3344. Cell ishcel0 = table.Rows[row].Cells[index];
  3345. Paragraph p = new Paragraph(doc);
  3346. string s = value;
  3347. p.AppendChild(new Run(doc, s));
  3348. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3349. ishcel0.AppendChild(p);
  3350. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3351. //ishcel0.CellFormat.VerticalAlignment=
  3352. index++;
  3353. }
  3354. row++;
  3355. }
  3356. #endregion
  3357. Paragraph lastParagraph = new Paragraph(doc);
  3358. //第一个表格末尾加段落
  3359. table.ParentNode.InsertAfter(lastParagraph, table);
  3360. //复制第一个表格
  3361. Table cloneTable = (Table)table.Clone(true);
  3362. //在文档末尾段落后面加入复制的表格
  3363. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3364. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3365. {
  3366. int rownewsIndex = 13;
  3367. for (int i = 0; i < 2; i++)
  3368. {
  3369. var CopyRow = table.Rows[12].Clone(true);
  3370. table.Rows.RemoveAt(13);
  3371. table.Rows.Add(CopyRow);
  3372. rownewsIndex++;
  3373. }
  3374. }
  3375. else
  3376. {
  3377. table.Rows.RemoveAt(12);
  3378. }
  3379. cloneTable.Rows.RemoveAt(12);
  3380. }
  3381. if (_AirTicketReservations.Count != 0)
  3382. {
  3383. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3384. if (FlightsCode.Length != 0)
  3385. {
  3386. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3387. if (_AirCompany != null)
  3388. {
  3389. string str = "--";
  3390. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3391. if (!string.IsNullOrEmpty(translateResult))
  3392. {
  3393. str = translateResult;
  3394. str = _airTicketResRep.Processing(str);
  3395. }
  3396. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3397. }
  3398. else
  3399. {
  3400. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3401. }
  3402. }
  3403. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3404. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3405. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3406. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3407. string names = "";
  3408. foreach (string clientName in nameArray)
  3409. {
  3410. names += clientName + ",";
  3411. }
  3412. if (!string.IsNullOrWhiteSpace(names))
  3413. {
  3414. string str = "--";
  3415. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3416. if (!string.IsNullOrEmpty(translateResult))
  3417. {
  3418. str = translateResult;
  3419. str = _airTicketResRep.Processing(str);
  3420. }
  3421. table.Range.Bookmarks["ClientName"].Text = str;
  3422. }
  3423. else
  3424. {
  3425. table.Range.Bookmarks["ClientName"].Text = "--";
  3426. }
  3427. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3428. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3429. table.Range.Bookmarks["JointTicket"].Text = "--";
  3430. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3431. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3432. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3433. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3434. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3435. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3436. }
  3437. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3438. //保存合并后的文档
  3439. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3440. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3441. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3442. return Ok(JsonView(true, "成功!", rst));
  3443. }
  3444. }
  3445. }
  3446. catch (Exception ex)
  3447. {
  3448. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3449. throw;
  3450. }
  3451. }
  3452. #endregion
  3453. #region 团组增减款项 --> 其他款项
  3454. /// <summary>
  3455. /// 团组增减款项下拉框绑定
  3456. /// </summary>
  3457. /// <param name="dto"></param>
  3458. /// <returns></returns>
  3459. [HttpPost]
  3460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3461. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3462. {
  3463. #region 参数验证
  3464. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3465. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3466. #endregion
  3467. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3468. }
  3469. /// <summary>
  3470. /// 根据团组Id查询团组增减款项
  3471. /// </summary>
  3472. /// <param name="dto"></param>
  3473. /// <returns></returns>
  3474. [HttpPost]
  3475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3476. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3477. {
  3478. #region 参数验证
  3479. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3480. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3481. #endregion
  3482. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3483. }
  3484. /// <summary>
  3485. /// 团组增减款项操作(Status:1.新增,2.修改)
  3486. /// </summary>
  3487. /// <param name="dto"></param>
  3488. /// <returns></returns>
  3489. [HttpPost]
  3490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3491. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3492. {
  3493. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3494. if (groupData.Code != 200)
  3495. {
  3496. return Ok(JsonView(false, groupData.Msg));
  3497. }
  3498. #region 应用推送
  3499. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3500. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3501. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3502. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3503. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3504. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3505. //自动审核
  3506. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3507. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3508. //2024-10-21 新增LZ UID
  3509. var userIds = new List<int>() { 21 };
  3510. string title = $"系统通知";
  3511. string content = "";
  3512. var diId = dto.DiId;
  3513. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3514. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3515. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3516. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3517. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3518. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3519. #endregion
  3520. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3521. }
  3522. /// <summary>
  3523. /// 团组增减款项操作 删除
  3524. /// </summary>
  3525. /// <param name="dto"></param>
  3526. /// <returns></returns>
  3527. [HttpPost]
  3528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3529. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3530. {
  3531. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3532. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3533. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3534. if (res.Code == 0)
  3535. {
  3536. return Ok(JsonView(true, "删除成功!"));
  3537. }
  3538. return Ok(JsonView(false, "删除失败!"));
  3539. }
  3540. /// <summary>
  3541. /// 根据团组增减款项Id查询
  3542. /// </summary>
  3543. /// <param name="dto"></param>
  3544. /// <returns></returns>
  3545. [HttpPost]
  3546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3547. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3548. {
  3549. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3550. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3551. }
  3552. /// <summary>
  3553. /// 查询供应商名称
  3554. /// </summary>
  3555. /// <param name="dto"></param>
  3556. /// <returns></returns>
  3557. [HttpPost]
  3558. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3559. {
  3560. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3561. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3562. ?? new List<Grp_DecreasePayments>();
  3563. dbResult = dbResult.Distinct(new
  3564. ProductComparer()).ToList();
  3565. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3566. {
  3567. x.Id,
  3568. x.SupplierAddress,
  3569. x.SupplierArea,
  3570. x.SupplierContact,
  3571. x.SupplierContactNumber,
  3572. x.SupplierEmail,
  3573. x.SupplierName,
  3574. x.SupplierSocialAccount,
  3575. x.SupplierTypeId,
  3576. }).ToList());
  3577. return Ok(jw);
  3578. }
  3579. /// <summary>
  3580. /// 团组增减款项 OTA匹配
  3581. /// </summary>
  3582. /// <param name="file"></param>
  3583. /// <returns></returns>
  3584. [HttpPost]
  3585. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3586. {
  3587. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3588. string fileName = file.FileName;
  3589. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3590. {
  3591. return Ok(JsonView(false, "请上传Excel文件!"));
  3592. }
  3593. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3594. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3595. if (!Directory.Exists(path))
  3596. {
  3597. Directory.CreateDirectory(path);
  3598. }
  3599. var filePath = @$"{path}/{fileName}";
  3600. //保存文件
  3601. using (FileStream fs = System.IO.File.Create(filePath))
  3602. {
  3603. file.CopyTo(fs);
  3604. fs.Flush();
  3605. }
  3606. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3607. //读取ExcelFile
  3608. DataTable dt = ConvertExcelToDataTable(filePath);
  3609. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3610. dt.TableName = "TB";
  3611. //修改table列名
  3612. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3613. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3614. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3615. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3616. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3617. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3618. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3619. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3620. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3621. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3622. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3623. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3624. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3625. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3626. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3627. var otaOrderNos = new List<string>();
  3628. foreach (DataRow item in dt.Rows)
  3629. {
  3630. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3631. }
  3632. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3633. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3634. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3635. .Select((dp, di) => new
  3636. {
  3637. dp.PriceName,
  3638. dp.OTAOrderNo,
  3639. dp.FeeTotal,
  3640. di.TeamName,
  3641. })
  3642. .ToListAsync();
  3643. foreach (DataRow item in dt.Rows)
  3644. {
  3645. var otaOrderNo = item["OTAOrderNo"].ToString();
  3646. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3647. if (oaData == null) continue;
  3648. item["GroupName"] = oaData.TeamName;
  3649. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3650. }
  3651. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3652. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3653. List<DataTable> datas = new List<DataTable>();
  3654. datas.Add(dt);
  3655. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3656. return Ok(JsonView(true, "操作成功", new { url = url }));
  3657. }
  3658. #region
  3659. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3660. {
  3661. // 创建Workbook对象
  3662. Workbook workbook = new Workbook(excelFilePath);
  3663. // 获取第一个工作表
  3664. Worksheet worksheet = workbook.Worksheets[0];
  3665. // 将工作表转换为DataTable
  3666. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3667. return dataTable;
  3668. }
  3669. #endregion
  3670. #endregion
  3671. #region 文件上传、删除
  3672. /// <summary>
  3673. /// region 文件上传 可以带参数
  3674. /// </summary>
  3675. /// <param name="file"></param>
  3676. /// <returns></returns>
  3677. [HttpPost]
  3678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3679. public async Task<IActionResult> UploadProject(IFormFile file)
  3680. {
  3681. //var TypeName = Request.Headers["TypeName"].ToString();
  3682. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3683. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3684. ////文件名称
  3685. //string projectFileName = file.FileName;
  3686. ////上传的文件的路径
  3687. //string filePath = $"{fileDir}/{projectFileName}";
  3688. //if (TypeName == "A")//A代表团组增减款项
  3689. //{
  3690. // filePath = fileDir + $@"\团组增减款项相关文件";
  3691. // if (!Directory.Exists(filePath))
  3692. // {
  3693. // Directory.CreateDirectory(filePath);
  3694. // }
  3695. // //上传的文件的路径
  3696. // filePath += $@"\{projectFileName}";
  3697. //}
  3698. //else if (TypeName == "B")//B代表商邀相关文件
  3699. //{
  3700. // //上传的文件的路径
  3701. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3702. // if (!Directory.Exists(filePath))
  3703. // {
  3704. // Directory.CreateDirectory(filePath);
  3705. // }
  3706. // //上传的文件的路径
  3707. // filePath = $@"\{projectFileName}";
  3708. //}
  3709. //try
  3710. //{
  3711. // using (FileStream fs = System.IO.File.Create(filePath))
  3712. // {
  3713. // file.CopyTo(fs);
  3714. // fs.Flush();
  3715. // }
  3716. //}
  3717. //catch (Exception ex)
  3718. //{
  3719. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3720. //}
  3721. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3722. try
  3723. {
  3724. var TypeName = Request.Headers["TypeName"].ToString();
  3725. if (file != null)
  3726. {
  3727. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3728. //文件名称
  3729. string projectFileName = file.FileName;
  3730. //上传的文件的路径
  3731. string filePath = $"{fileDir}/{projectFileName}";
  3732. if (TypeName == "A")//A代表团组增减款项
  3733. {
  3734. if (!Directory.Exists(fileDir))
  3735. {
  3736. Directory.CreateDirectory(fileDir);
  3737. }
  3738. //上传的文件的路径
  3739. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3740. }
  3741. else if (TypeName == "B")//B代表商邀相关文件
  3742. {
  3743. if (!Directory.Exists(fileDir))
  3744. {
  3745. Directory.CreateDirectory(fileDir);
  3746. }
  3747. //上传的文件的路径
  3748. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3749. }
  3750. using (FileStream fs = System.IO.File.Create(filePath))
  3751. {
  3752. file.CopyTo(fs);
  3753. fs.Flush();
  3754. }
  3755. return Ok(JsonView(true, "上传成功!", projectFileName));
  3756. }
  3757. else
  3758. {
  3759. return Ok(JsonView(false, "上传失败!"));
  3760. }
  3761. }
  3762. catch (Exception ex)
  3763. {
  3764. return Ok(JsonView(false, "程序错误!"));
  3765. }
  3766. }
  3767. /// <summary>
  3768. /// 删除指定文件
  3769. /// </summary>
  3770. /// <param name="dto"></param>
  3771. /// <returns></returns>
  3772. [HttpPost]
  3773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3774. public async Task<IActionResult> DelFile(DelFileDto dto)
  3775. {
  3776. try
  3777. {
  3778. var TypeName = Request.Headers["TypeName"].ToString();
  3779. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3780. string filePath = "";
  3781. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3782. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3783. int id = 0;
  3784. if (TypeName == "A")
  3785. {
  3786. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3787. // 删除该文件
  3788. System.IO.File.Delete(filePath);
  3789. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3790. .Where(a => a.Id == dto.Id)
  3791. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3792. .ExecuteCommandAsync();
  3793. }
  3794. else if (TypeName == "B")
  3795. {
  3796. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3797. // 删除该文件
  3798. System.IO.File.Delete(filePath);
  3799. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3800. if (info != null)
  3801. {
  3802. string[] files = new string[] { };
  3803. if (!string.IsNullOrEmpty(info.Attachment))
  3804. {
  3805. try
  3806. {
  3807. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3808. }
  3809. catch (Exception)
  3810. {
  3811. files = new List<string>() { info.Attachment }.ToArray();
  3812. }
  3813. }
  3814. if (files.Length > 0)
  3815. {
  3816. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3817. string filePath2 = string.Empty;
  3818. if (files1.Length > 0)
  3819. {
  3820. filePath2 = JsonConvert.SerializeObject(files1);
  3821. }
  3822. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3823. .Where(a => a.Id == dto.Id)
  3824. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3825. .ExecuteCommandAsync();
  3826. }
  3827. }
  3828. }
  3829. if (id != 0)
  3830. {
  3831. return Ok(JsonView(true, "成功!"));
  3832. }
  3833. else
  3834. {
  3835. return Ok(JsonView(false, "失败!"));
  3836. }
  3837. }
  3838. catch (Exception ex)
  3839. {
  3840. return Ok(JsonView(false, "程序错误!"));
  3841. throw;
  3842. }
  3843. }
  3844. /// <summary>
  3845. /// 文件上传多个文件 可以带参数
  3846. /// </summary>
  3847. /// <param name="files"></param>
  3848. /// <returns></returns>
  3849. [HttpPost]
  3850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3851. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3852. {
  3853. try
  3854. {
  3855. var TypeName = Request.Headers["TypeName"].ToString();
  3856. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3857. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3858. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3859. var filePahts = new List<string>();
  3860. foreach (var file in files)
  3861. {
  3862. //文件名称
  3863. string projectFileName = file.FileName;
  3864. //上传的文件的路径
  3865. string filePath = $"{fileDir}/{projectFileName}";
  3866. if (TypeName == "A")//A代表团组增减款项
  3867. {
  3868. if (!Directory.Exists(fileDir))
  3869. {
  3870. Directory.CreateDirectory(fileDir);
  3871. }
  3872. //上传的文件的路径
  3873. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3874. }
  3875. else if (TypeName == "B")//B代表商邀相关文件
  3876. {
  3877. if (!Directory.Exists(fileDir))
  3878. {
  3879. Directory.CreateDirectory(fileDir);
  3880. }
  3881. //上传的文件的路径
  3882. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3883. }
  3884. using (FileStream fs = System.IO.File.Create(filePath))
  3885. {
  3886. file.CopyTo(fs);
  3887. fs.Flush();
  3888. }
  3889. filePahts.Add(projectFileName);
  3890. }
  3891. return Ok(JsonView(true, "上传成功!", filePahts));
  3892. }
  3893. catch (Exception ex)
  3894. {
  3895. return Ok(JsonView(false, "程序错误!"));
  3896. }
  3897. }
  3898. #endregion
  3899. #region 商邀费用录入
  3900. /// <summary>
  3901. /// 根据团组Id查询商邀费用列表
  3902. /// </summary>
  3903. /// <param name="dto"></param>
  3904. /// <returns></returns>
  3905. [HttpPost]
  3906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3907. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3908. {
  3909. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3910. if (groupData.Code != 0)
  3911. {
  3912. return Ok(JsonView(false, groupData.Msg));
  3913. }
  3914. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3915. }
  3916. /// <summary>
  3917. /// 商邀费用列表
  3918. /// 下载文件
  3919. /// </summary>
  3920. /// <param name="id"></param>
  3921. /// <returns></returns>
  3922. [HttpGet("{id}")]
  3923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3924. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3925. {
  3926. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3927. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3928. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3929. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3930. var filePaths = new List<string>();
  3931. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3932. try
  3933. {
  3934. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3935. }
  3936. catch (Exception ex)
  3937. {
  3938. filePaths.Add(info.Attachment);
  3939. }
  3940. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3941. for (int i = 0; i < filePaths.Count; i++)
  3942. {
  3943. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3944. }
  3945. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3946. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3947. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3948. {
  3949. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3950. {
  3951. foreach (string filePath in filePaths)
  3952. {
  3953. if (System.IO.File.Exists(filePath))
  3954. {
  3955. // 获取文件名
  3956. string fileName = Path.GetFileName(filePath);
  3957. // 将文件添加到ZIP归档中
  3958. zipArchive.CreateEntryFromFile(filePath, fileName);
  3959. }
  3960. }
  3961. }
  3962. }
  3963. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3964. }
  3965. /// <summary>
  3966. /// 商邀费用 Info Page 基础数据源
  3967. /// </summary>
  3968. /// <returns></returns>
  3969. [HttpPost]
  3970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3971. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3972. {
  3973. try
  3974. {
  3975. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3976. if (groupData.Code != 0)
  3977. {
  3978. return Ok(JsonView(false, groupData.Msg));
  3979. }
  3980. return Ok(JsonView(true, "操作成功", groupData.Data));
  3981. }
  3982. catch (Exception ex)
  3983. {
  3984. return Ok(JsonView(false, ex.Message));
  3985. throw;
  3986. }
  3987. }
  3988. /// <summary>
  3989. /// 根据商邀费用ID查询C表和商邀费用数据
  3990. /// </summary>
  3991. /// <param name="dto"></param>
  3992. /// <returns></returns>
  3993. [HttpPost]
  3994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3995. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3996. {
  3997. try
  3998. {
  3999. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4000. if (groupData.Code != 0)
  4001. {
  4002. return Ok(JsonView(false, groupData.Msg));
  4003. }
  4004. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4005. }
  4006. catch (Exception ex)
  4007. {
  4008. return Ok(JsonView(false, ex.Message));
  4009. throw;
  4010. }
  4011. }
  4012. /// <summary>
  4013. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4014. /// </summary>
  4015. /// <param name="dto"></param>
  4016. /// <returns></returns>
  4017. [HttpPost]
  4018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4019. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4020. {
  4021. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4022. if (groupData.Code != 0)
  4023. {
  4024. return Ok(JsonView(false, groupData.Msg));
  4025. }
  4026. #region 应用推送
  4027. try
  4028. {
  4029. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4030. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4031. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4032. //2024-10-21 新增LZ UID
  4033. var userIds = new List<int>() { 21 };
  4034. string title = $"系统通知";
  4035. string content = "";
  4036. var diId = dto.DiId;
  4037. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4038. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4039. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4040. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4041. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4042. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4043. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4044. }
  4045. catch (Exception ex)
  4046. {
  4047. }
  4048. #endregion
  4049. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4050. }
  4051. /// <summary>
  4052. /// 商邀删除
  4053. /// </summary>
  4054. /// <param name="dto"></param>
  4055. /// <returns></returns>
  4056. [HttpPost]
  4057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4058. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4059. {
  4060. try
  4061. {
  4062. _sqlSugar.BeginTran();
  4063. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4064. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4065. {
  4066. IsDel = 1,
  4067. DeleteUserId = dto.DeleteUserId,
  4068. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4069. })
  4070. .Where(it => it.Id == dto.Id)
  4071. .ExecuteCommand();
  4072. if (res1 > 0)
  4073. {
  4074. int _diId = 0;
  4075. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4076. if (_ioaInfo != null)
  4077. {
  4078. _diId = _ioaInfo.DiId;
  4079. }
  4080. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4081. .SetColumns(a => new Grp_CreditCardPayment()
  4082. {
  4083. IsDel = 1,
  4084. DeleteUserId = dto.DeleteUserId,
  4085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4086. })
  4087. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4088. .ExecuteCommand();
  4089. if (res2 > 0)
  4090. {
  4091. _sqlSugar.CommitTran();
  4092. return Ok(JsonView(true, "删除成功!"));
  4093. }
  4094. }
  4095. _sqlSugar.RollbackTran();
  4096. return Ok(JsonView(false, "删除失败"));
  4097. }
  4098. catch (Exception ex)
  4099. {
  4100. _sqlSugar.RollbackTran();
  4101. return Ok(JsonView(false, ex.Message));
  4102. }
  4103. }
  4104. /// <summary>
  4105. /// 团组模块文件上传
  4106. /// </summary>
  4107. /// <param name="dto"></param>
  4108. /// <returns></returns>
  4109. [HttpPost]
  4110. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4111. {
  4112. var jw = JsonView(false);
  4113. long M = 1024 * 1024;
  4114. if (dto.Files == null || dto.Files.Count == 0)
  4115. {
  4116. jw.Msg = "无文件信息!";
  4117. return Ok(jw);
  4118. }
  4119. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4120. {
  4121. jw.Msg = "文件大小超过20M!";
  4122. return Ok(jw);
  4123. }
  4124. //var nameSp = dto.File.FileName.Split(".");
  4125. //if (nameSp.Length < 2)
  4126. //{
  4127. // jw.Msg = "拓展名称有误!";
  4128. // return Ok(jw);
  4129. //}
  4130. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4131. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4132. //{
  4133. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4134. // return Ok(jw);
  4135. //}
  4136. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4137. if (Ctable == null)
  4138. {
  4139. jw.Msg = "Ctable指向有误!";
  4140. return Ok(jw);
  4141. }
  4142. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4143. if (groupInfo == null)
  4144. {
  4145. jw.Msg = "团组信息不存在!";
  4146. return Ok(jw);
  4147. }
  4148. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4149. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4150. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4151. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4152. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4153. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4154. try
  4155. {
  4156. if (!Directory.Exists(fileBase))
  4157. {
  4158. Directory.CreateDirectory(fileBase);
  4159. }
  4160. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4161. foreach (var fileStream in dto.Files)
  4162. {
  4163. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4164. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4165. {
  4166. Cid = dto.Cid,
  4167. CreateTime = DateTime.Now,
  4168. CreateUserId = dto.Userid,
  4169. Ctable = dto.Ctable,
  4170. Diid = dto.Diid,
  4171. IsDel = 0,
  4172. FilePath = saveFilePath,
  4173. FileName = fileStream.FileName
  4174. };
  4175. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4176. {
  4177. fileStream.CopyTo(fs);
  4178. fs.Flush();
  4179. }
  4180. saveArr.Add(file);
  4181. }
  4182. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4183. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4184. jw = JsonView(true, "保存成功!", new
  4185. {
  4186. count = addResult,
  4187. filesName = saveArr.Select(x => x.FileName)
  4188. });
  4189. }
  4190. catch (Exception ex)
  4191. {
  4192. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4193. {
  4194. count = 0,
  4195. filesName = new string[0],
  4196. });
  4197. }
  4198. return Ok(jw);
  4199. }
  4200. /// <summary>
  4201. /// 查询各模块已保存文件
  4202. /// </summary>
  4203. /// <param name="dto"></param>
  4204. /// <returns></returns>
  4205. [HttpPost]
  4206. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4207. {
  4208. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4209. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4210. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4211. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4212. {
  4213. expression = Expressionable.Create<Grp_GroupModelFile>()
  4214. .And(x => visaIds.Contains(x.CreateUserId));
  4215. }
  4216. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4217. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4218. .Where(expression.ToExpression())
  4219. .ToList();
  4220. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4221. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4222. {
  4223. x.FileName,
  4224. x.Id,
  4225. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4226. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4227. })));
  4228. }
  4229. /// <summary>
  4230. /// 下载该团组下的所有文件
  4231. /// </summary>
  4232. /// <param name="dto"></param>
  4233. /// <returns></returns>
  4234. [HttpPost]
  4235. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4236. {
  4237. var jw = JsonView(false);
  4238. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4239. if (groupInfo == null)
  4240. {
  4241. jw.Msg = "团组信息不存在!";
  4242. return Ok(jw);
  4243. }
  4244. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4245. var isModule = Convert.ToBoolean(dto.isModule);
  4246. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4247. IOOperatorHelper io = new IOOperatorHelper();
  4248. if (isModule)
  4249. {
  4250. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4251. foreach (var moduleArr in moduleGroup)
  4252. {
  4253. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4254. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4255. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4256. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4257. foreach (var item in moduleArr)
  4258. {
  4259. if (System.IO.File.Exists(item.FilePath))
  4260. {
  4261. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4262. {
  4263. byte[] bytes = new byte[fileStream.Length];
  4264. fileStream.Read(bytes, 0, bytes.Length);
  4265. fileStream.Close();
  4266. Stream stream = new MemoryStream(bytes);
  4267. chiZips.Add(item.FileName, stream);
  4268. }
  4269. }
  4270. }
  4271. if (chiZips.Count > 0)
  4272. {
  4273. var byts = io.ConvertZipStream(chiZips);
  4274. Stream stream = new MemoryStream(byts);
  4275. Zips.Add(key.Name + "_.zip", stream);
  4276. }
  4277. }
  4278. }
  4279. else
  4280. {
  4281. foreach (var item in dbQuery)
  4282. {
  4283. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4284. {
  4285. byte[] bytes = new byte[fileStream.Length];
  4286. fileStream.Read(bytes, 0, bytes.Length);
  4287. fileStream.Close();
  4288. Stream stream = new MemoryStream(bytes);
  4289. while (Zips.Keys.Contains(item.FileName))
  4290. {
  4291. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4292. }
  4293. Zips.Add(item.FileName, stream);
  4294. }
  4295. }
  4296. }
  4297. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4298. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4299. if (Zips.Count > 0)
  4300. {
  4301. var byts = io.ConvertZipStream(Zips);
  4302. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4303. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4304. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4305. }
  4306. else
  4307. {
  4308. jw.Msg = "暂无生成文件!";
  4309. }
  4310. return Ok(jw);
  4311. }
  4312. /// <summary>
  4313. /// 下载该团组下此模块的所有文件
  4314. /// </summary>
  4315. /// <param name="dto"></param>
  4316. /// <returns></returns>
  4317. [HttpPost]
  4318. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4319. {
  4320. var jw = JsonView(false);
  4321. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4322. if (groupInfo == null)
  4323. {
  4324. jw.Msg = "团组信息不存在!";
  4325. return Ok(jw);
  4326. }
  4327. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4328. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4329. && x.IsDel == 0);
  4330. if (key == null)
  4331. {
  4332. jw.Msg = "Ctable指向错误!";
  4333. return Ok(jw);
  4334. }
  4335. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4336. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4337. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4338. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4339. IOOperatorHelper io = new IOOperatorHelper();
  4340. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4341. foreach (var item in dbQuery)
  4342. {
  4343. if (System.IO.File.Exists(item.FilePath))
  4344. {
  4345. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4346. {
  4347. byte[] bytes = new byte[fileStream.Length];
  4348. fileStream.Read(bytes, 0, bytes.Length);
  4349. fileStream.Close();
  4350. Stream stream = new MemoryStream(bytes);
  4351. while (Zips.Keys.Contains(item.FileName))
  4352. {
  4353. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4354. }
  4355. Zips.Add(item.FileName, stream);
  4356. }
  4357. }
  4358. }
  4359. if (Zips.Count > 0)
  4360. {
  4361. var byts = io.ConvertZipStream(Zips);
  4362. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4363. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4364. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4365. }
  4366. else
  4367. {
  4368. jw.Msg = "暂无生成文件!";
  4369. }
  4370. return Ok(jw);
  4371. }
  4372. /// <summary>
  4373. /// 删除该团组下的指定文件
  4374. /// </summary>
  4375. /// <param name="dto"></param>
  4376. /// <returns></returns>
  4377. [HttpPost]
  4378. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4379. {
  4380. var jw = JsonView(false);
  4381. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4382. if (sing == null)
  4383. {
  4384. jw.Msg = "暂无";
  4385. return Ok(jw);
  4386. }
  4387. if (System.IO.File.Exists(sing.FilePath))
  4388. {
  4389. try
  4390. {
  4391. System.IO.File.Delete(sing.FilePath);
  4392. }
  4393. catch (Exception ex)
  4394. {
  4395. jw.Msg = "删除失败!" + ex.Message;
  4396. return Ok(jw);
  4397. }
  4398. }
  4399. sing.IsDel = 1;
  4400. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4401. sing.DeleteUserId = dto.UserId;
  4402. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4403. jw = JsonView(true, "删除成功!");
  4404. return Ok(jw);
  4405. }
  4406. #endregion
  4407. #region 团组英文资料
  4408. /// <summary>
  4409. /// 查询团组英文所有资料
  4410. /// </summary>
  4411. /// <param name="dto"></param>
  4412. /// <returns></returns>
  4413. [HttpPost]
  4414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4415. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4416. {
  4417. try
  4418. {
  4419. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4420. if (groupData.Code != 0)
  4421. {
  4422. return Ok(JsonView(false, groupData.Msg));
  4423. }
  4424. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4425. }
  4426. catch (Exception ex)
  4427. {
  4428. return Ok(JsonView(false, "程序错误!"));
  4429. throw;
  4430. }
  4431. }
  4432. /// <summary>
  4433. /// 团组英文资料操作(Status:1.新增,2.修改)
  4434. /// </summary>
  4435. /// <param name="dto"></param>
  4436. /// <returns></returns>
  4437. [HttpPost]
  4438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4439. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4440. {
  4441. try
  4442. {
  4443. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4444. if (groupData.Code != 0)
  4445. {
  4446. return Ok(JsonView(false, groupData.Msg));
  4447. }
  4448. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4449. }
  4450. catch (Exception ex)
  4451. {
  4452. return Ok(JsonView(false, "程序错误!"));
  4453. throw;
  4454. }
  4455. }
  4456. /// <summary>
  4457. /// 团组英文资料Id查询数据
  4458. /// </summary>
  4459. /// <param name="dto"></param>
  4460. /// <returns></returns>
  4461. [HttpPost]
  4462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4463. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4464. {
  4465. try
  4466. {
  4467. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4468. if (_DelegationEnData != null)
  4469. {
  4470. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4471. }
  4472. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4473. }
  4474. catch (Exception ex)
  4475. {
  4476. return Ok(JsonView(false, "程序错误!"));
  4477. throw;
  4478. }
  4479. }
  4480. /// <summary>
  4481. /// 团组英文资料删除
  4482. /// </summary>
  4483. /// <param name="dto"></param>
  4484. /// <returns></returns>
  4485. [HttpPost]
  4486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4487. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4488. {
  4489. try
  4490. {
  4491. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4492. if (!res)
  4493. {
  4494. return Ok(JsonView(false, "删除失败"));
  4495. }
  4496. return Ok(JsonView(true, "删除成功!"));
  4497. }
  4498. catch (Exception ex)
  4499. {
  4500. return Ok(JsonView(false, "程序错误!"));
  4501. throw;
  4502. }
  4503. }
  4504. #endregion
  4505. #region 导出邀请函
  4506. /// <summary>
  4507. /// 导出邀请函页面初始化
  4508. /// </summary>
  4509. /// <param name="dto"></param>
  4510. /// <returns></returns>
  4511. [HttpPost]
  4512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4513. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4514. {
  4515. try
  4516. {
  4517. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4518. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4519. if (dto.DiId == 0)
  4520. {
  4521. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4522. }
  4523. else
  4524. {
  4525. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4526. }
  4527. return Ok(JsonView(true, "查询成功!", new
  4528. {
  4529. deleClient = crm_Deles,
  4530. delegations = grp_Delegations
  4531. }));
  4532. }
  4533. catch (Exception ex)
  4534. {
  4535. return Ok(JsonView(false, "程序错误!"));
  4536. throw;
  4537. }
  4538. }
  4539. /// <summary>
  4540. /// 导出邀请函
  4541. /// </summary>
  4542. /// <param name="dto"></param>
  4543. /// <returns></returns>
  4544. [HttpPost]
  4545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4546. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4547. {
  4548. #region 参数验证
  4549. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4550. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4551. #endregion
  4552. try
  4553. {
  4554. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4555. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4556. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4557. From Grp_TourClientList tcl
  4558. Left Join
  4559. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4560. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4561. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4562. From Crm_DeleClient dc
  4563. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4564. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4565. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4566. Where dc.IsDel = 0) temp
  4567. On temp.DcId =tcl.ClientId
  4568. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4569. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4570. List<string> texts = new List<string>();
  4571. if (datas.Count != 0)
  4572. {
  4573. foreach (TourClientListDetailsView item in datas)
  4574. {
  4575. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4576. {
  4577. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4578. }
  4579. else
  4580. {
  4581. string name = item.LastName + item.FirstName;
  4582. texts.Add(name);
  4583. }
  4584. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4585. {
  4586. if (!transDic.ContainsKey(item.Job))
  4587. {
  4588. texts.Add(item.Job);
  4589. }
  4590. }
  4591. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4592. {
  4593. texts.Add(item.CompanyFullName);
  4594. }
  4595. }
  4596. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4597. if (transData.Count > 0)
  4598. {
  4599. foreach (TranslateResult item in transData)
  4600. {
  4601. if (!transDic.ContainsKey(item.Query))
  4602. {
  4603. transDic.Add(item.Query, item.Translation);
  4604. }
  4605. }
  4606. }
  4607. List<GuestList> list = new List<GuestList>();
  4608. foreach (TourClientListDetailsView dele in datas)
  4609. {
  4610. GuestList guestList = new GuestList();
  4611. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4612. {
  4613. guestList.Name = dele.Pinyin;
  4614. }
  4615. else
  4616. {
  4617. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4618. guestList.Name = Name;
  4619. }
  4620. if (dele.Sex == 0)
  4621. {
  4622. guestList.Sex = "Male";
  4623. }
  4624. else if (dele.Sex == 1)
  4625. {
  4626. guestList.Sex = "Female";
  4627. }
  4628. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4629. if (!string.IsNullOrEmpty(dele.Job))
  4630. {
  4631. guestList.Job = dele.Job;
  4632. }
  4633. list.Add(guestList);
  4634. }
  4635. //载入模板
  4636. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4637. DocumentBuilder builder = new DocumentBuilder(doc);
  4638. //获取word里所有表格
  4639. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4640. //获取所填表格的序数
  4641. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4642. var rowStart = tableOne.Rows[0]; //获取第1行
  4643. //循环赋值
  4644. for (int i = 0; i < list.Count; i++)
  4645. {
  4646. builder.MoveToCell(0, i + 1, 0, 0);
  4647. builder.Write(list[i].Name.ToString());
  4648. builder.MoveToCell(0, i + 1, 1, 0);
  4649. builder.Write(list[i].Sex.ToString());
  4650. builder.MoveToCell(0, i + 1, 2, 0);
  4651. builder.Write(list[i].DOB.ToString());
  4652. builder.MoveToCell(0, i + 1, 3, 0);
  4653. builder.Write(list[i].Job.ToString());
  4654. }
  4655. //删除多余行
  4656. while (tableOne.Rows.Count > list.Count + 1)
  4657. {
  4658. tableOne.Rows.RemoveAt(list.Count + 1);
  4659. }
  4660. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4661. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4662. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4663. doc.Save(filePath);
  4664. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4665. return Ok(JsonView(true, "操作成功!", Url));
  4666. }
  4667. else
  4668. {
  4669. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4670. }
  4671. }
  4672. catch (Exception ex)
  4673. {
  4674. return Ok(JsonView(false, ex.Message));
  4675. throw;
  4676. }
  4677. }
  4678. #endregion
  4679. #region 团组经理模块 出入境费用
  4680. /// <summary>
  4681. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4682. /// </summary>
  4683. /// <returns></returns>
  4684. [HttpPost]
  4685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4686. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4687. {
  4688. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4689. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4690. //SetDataInfoView
  4691. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4692. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4693. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4694. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4695. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4696. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4697. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4698. //默认币种显示
  4699. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4700. {
  4701. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4702. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4703. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4704. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4705. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4706. };
  4707. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4708. if (_currencyRate.Count > 0)
  4709. {
  4710. foreach (var item in _currencyInfos)
  4711. {
  4712. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4713. if (rateInfo != null)
  4714. {
  4715. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4716. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  4717. else rate1 *= 1.035M;
  4718. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4719. }
  4720. }
  4721. }
  4722. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4723. return Ok(JsonView(true, "查询成功!", new
  4724. {
  4725. GroupNameData = groupNameData.Data,
  4726. CurrencyData = _CurrencyData,
  4727. WordTypeData = _WordTypeData,
  4728. ExcelTypeData = _ExcelTypeData,
  4729. CurrencyInit = _currencyInfos,
  4730. ViewPermissionData = viewPermissionData
  4731. }));
  4732. }
  4733. /// <summary>
  4734. /// 团组模块 - 出入境费用
  4735. /// 实时汇率 tips
  4736. /// 签证费用 tips
  4737. /// 机票费用 tips
  4738. /// </summary>
  4739. /// <returns></returns>
  4740. [HttpPost]
  4741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4742. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4743. {
  4744. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4745. //默认币种显示
  4746. var _currencyInfos = _currencyInit;
  4747. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  4748. List<dynamic> reteInfos = new List<dynamic>();
  4749. if (_currencyRate.Count > 0)
  4750. {
  4751. foreach (var item in _currencyInfos)
  4752. {
  4753. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4754. if (rateInfo != null)
  4755. {
  4756. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4757. decimal rate1 = item.Rate;
  4758. rate1 *= 1.03M;
  4759. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4760. reteInfos.Add(new
  4761. {
  4762. currCode = item.CurrencyCode,
  4763. currName = item.CurrencyName,
  4764. rate = rate2,
  4765. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4766. });
  4767. }
  4768. }
  4769. }
  4770. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4771. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4772. return Ok(JsonView(true, "查询成功!", new
  4773. {
  4774. //GroupNameData = groupNameData.Data,
  4775. visaData = visaData.Data,
  4776. airData = airData.Data,
  4777. reteInfos = reteInfos
  4778. }));
  4779. }
  4780. /// <summary>
  4781. /// 团组模块 - 出入境费用 - Info
  4782. /// </summary>
  4783. /// <returns></returns>
  4784. [HttpPost]
  4785. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4787. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4788. {
  4789. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4790. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4791. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4792. }
  4793. /// <summary>
  4794. /// 团组模块 - 出入境费用 - 设置view权限
  4795. /// </summary>
  4796. /// <returns></returns>
  4797. [HttpPost]
  4798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4799. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4800. {
  4801. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4802. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4803. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4804. var permissions = new List<Grp_EnterExitCostPermission>();
  4805. foreach (var userId in dto.UserIds)
  4806. {
  4807. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4808. }
  4809. if (permissions.Any())
  4810. {
  4811. _sqlSugar.BeginTran();
  4812. try
  4813. {
  4814. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4815. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4816. if (result < 1)
  4817. {
  4818. _sqlSugar.RollbackTran();
  4819. return Ok(JsonView(false));
  4820. }
  4821. }
  4822. catch (Exception ex)
  4823. {
  4824. _sqlSugar.RollbackTran();
  4825. return Ok(JsonView(false, ex.Message));
  4826. }
  4827. _sqlSugar.CommitTran();
  4828. return Ok(JsonView(true));
  4829. }
  4830. return Ok(JsonView(false));
  4831. }
  4832. /// <summary>
  4833. /// 团组模块 - 出入境费用 - Add And Update
  4834. /// </summary>
  4835. /// <returns></returns>
  4836. [HttpPost]
  4837. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  4838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4839. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4840. {
  4841. try
  4842. {
  4843. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4844. if (dto.DayOtherPriceData.Any())
  4845. {
  4846. var inserList = dto.DayOtherPriceData
  4847. .Where(x => x.Id == 0)
  4848. .Select(x => new Grp_DayOtherPrice
  4849. {
  4850. Cost = x.Cost,
  4851. Id = x.Id,
  4852. CreateTime = DateTime.Now,
  4853. CreateUserId = dto.UserId,
  4854. Currency = x.Currency,
  4855. Diid = x.DiId,
  4856. Index = x.Index,
  4857. IsDel = 0,
  4858. SetDataId = x.SetDataId,
  4859. SubTotal = x.SubTotal,
  4860. Remark = x.Remark
  4861. })
  4862. .ToList();
  4863. var updateList = dto.DayOtherPriceData
  4864. .Where(x => x.Id != 0)
  4865. .Select(x => new Grp_DayOtherPrice
  4866. {
  4867. Cost = x.Cost,
  4868. Id = x.Id,
  4869. CreateTime = DateTime.Now,
  4870. CreateUserId = dto.UserId,
  4871. Currency = x.Currency,
  4872. Diid = x.DiId,
  4873. Index = x.Index,
  4874. IsDel = 0,
  4875. SetDataId = x.SetDataId,
  4876. SubTotal = x.SubTotal,
  4877. Remark = x.Remark
  4878. })
  4879. .ToList();
  4880. //添加
  4881. _sqlSugar.BeginTran();
  4882. if (inserList.Any())
  4883. {
  4884. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4885. }
  4886. if (updateList.Any())
  4887. {
  4888. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4889. }
  4890. _sqlSugar.CommitTran();
  4891. }
  4892. if (data.Code != 0)
  4893. {
  4894. return Ok(JsonView(false, data.Msg));
  4895. }
  4896. //生成默认文件pdf并且通知人员
  4897. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4898. {
  4899. DiId = dto.DiId,
  4900. ExportType = 1,
  4901. SubTypeId = 1005
  4902. }, "pdf");
  4903. //发送通知
  4904. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4905. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4906. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4907. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4908. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4909. //汇率信息记录
  4910. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4911. return Ok(JsonView(true, data.Msg, data.Data));
  4912. }
  4913. catch (Exception ex)
  4914. {
  4915. return Ok(JsonView(false, ex.Message));
  4916. }
  4917. }
  4918. /// <summary>
  4919. /// 团组模块 - 出入境费用 - Confirm 费用
  4920. /// </summary>
  4921. /// <returns></returns>
  4922. [HttpPost]
  4923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4924. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4925. {
  4926. //TODO:测试完毕需把对应的用户ID更改
  4927. //1、数据表添加字段
  4928. //2、更改字段接口()
  4929. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4930. //3、确认成功 给财务发送消息
  4931. if (_view.Code == 200)
  4932. {
  4933. if (dto.Type == 1)
  4934. {
  4935. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4936. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4937. }
  4938. }
  4939. return Ok(_view);
  4940. }
  4941. /// <summary>
  4942. /// 团组模块 - 出入境费用 - File download
  4943. /// </summary>
  4944. /// <param name="dto"></param>
  4945. /// <returns></returns>
  4946. [HttpPost]
  4947. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  4948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4949. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4950. {
  4951. try
  4952. {
  4953. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4954. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4955. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4956. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4957. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4958. 3 团组成员名单 1 团组成员名单", ""));
  4959. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4960. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4961. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4962. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4963. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4964. //数据源
  4965. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4966. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4967. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4968. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4969. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4970. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4971. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4972. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4973. .Select((x, a, b) => new
  4974. {
  4975. x.Index,
  4976. itemName = a.Name,
  4977. CurrencyStr = b.Name,
  4978. x.Cost,
  4979. x.SubTotal,
  4980. x.Remark
  4981. })
  4982. .OrderBy((x) => x.Index)
  4983. .ToList(); //其他款项费用
  4984. var peiceItemCurrencys = new List<string>();
  4985. if (_DayAndCosts.Any())
  4986. {
  4987. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  4988. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  4989. }
  4990. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  4991. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  4992. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  4993. {
  4994. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  4995. }
  4996. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4997. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4998. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4999. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5000. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5001. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5002. .Select((tcl, dc, cc) => new ClientInfo
  5003. {
  5004. LastName = dc.LastName,
  5005. FirstName = dc.FirstName,
  5006. Sex = dc.Sex,
  5007. Birthday = dc.BirthDay,
  5008. Company = cc.CompanyFullName,
  5009. Job = dc.Job
  5010. })
  5011. .ToList();
  5012. foreach (var item in DeleClientList)
  5013. {
  5014. EncryptionProcessor.DecryptProperties(item);
  5015. }
  5016. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5017. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5018. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5019. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5020. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5021. if (dto.ExportType == 1) //明细表
  5022. {
  5023. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5024. {
  5025. //获取模板
  5026. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5027. //载入模板
  5028. Document doc = new Document(tempPath);
  5029. DocumentBuilder builder = new DocumentBuilder(doc);
  5030. //利用键值对存放数据
  5031. Dictionary<string, string> dic = new Dictionary<string, string>();
  5032. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5033. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5034. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5035. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5036. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5037. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5038. //境内费用(其他费用)
  5039. if (_EnterExitCosts.ChoiceOne == 1)
  5040. {
  5041. string row1_1 = "";
  5042. if (_EnterExitCosts.Visa > 0)
  5043. {
  5044. //insidePayTotal += _EnterExitCosts.Visa;
  5045. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5046. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5047. {
  5048. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5049. }
  5050. }
  5051. string row1_2 = "";
  5052. if (_EnterExitCosts.YiMiao > 0)
  5053. {
  5054. //insidePayTotal += _EnterExitCosts.YiMiao;
  5055. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5056. }
  5057. if (_EnterExitCosts.HeSuan > 0)
  5058. {
  5059. //insidePayTotal += _EnterExitCosts.HeSuan;
  5060. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5061. }
  5062. if (_EnterExitCosts.Service > 0)
  5063. {
  5064. //insidePayTotal += _EnterExitCosts.Service;
  5065. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5066. }
  5067. string row1_3 = "";
  5068. if (_EnterExitCosts.Safe > 0)
  5069. {
  5070. //insidePayTotal += _EnterExitCosts.Safe;
  5071. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5072. }
  5073. if (_EnterExitCosts.Ticket > 0)
  5074. {
  5075. //insidePayTotal += _EnterExitCosts.Ticket;
  5076. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5077. }
  5078. string row1 = "";
  5079. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5080. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5081. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5082. row1 += $"备注:{_EnterExitCosts.Remark}";
  5083. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5084. dic.Add("Row1Str", row1);
  5085. }
  5086. string airTotalStr = string.Empty,
  5087. airPriceStr = string.Empty;
  5088. //经济舱
  5089. if (_EnterExitCosts.SumJJC == 1)
  5090. {
  5091. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5092. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5093. }
  5094. //公务舱
  5095. if (_EnterExitCosts.SumGWC == 1)
  5096. {
  5097. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5098. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5099. }
  5100. //头等舱
  5101. if (_EnterExitCosts.SumTDC == 1)
  5102. {
  5103. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5104. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5105. }
  5106. //汇率描述
  5107. string rateStr = "";
  5108. if (peiceItemCurrencyInfos.Any())
  5109. {
  5110. rateStr = "\r\n汇率描述:";
  5111. foreach (var item in peiceItemCurrencyInfos)
  5112. {
  5113. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5114. }
  5115. }
  5116. string twoItemRemark = "备注:";
  5117. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5118. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5119. dic.Add("AirTotalStr", airTotalStr);
  5120. dic.Add("AirPriceStr", airPriceStr);
  5121. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5122. dic.Add("TwoItemRemark", twoItemRemark);
  5123. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5124. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5125. int table1Row = 0,
  5126. table2Row = 0,
  5127. table3Row = 0,
  5128. table4Row = 0,
  5129. table5Row = 0;
  5130. //住宿费
  5131. if (_EnterExitCosts.ChoiceThree == 1)
  5132. {
  5133. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5134. table1Row = dac1.Count;
  5135. #region 填充word表格内容
  5136. for (int i = 0; i < dac1.Count; i++)
  5137. {
  5138. Grp_DayAndCost dac = dac1[i];
  5139. if (dac == null) continue;
  5140. builder.MoveToCell(0, i, 0, 0);
  5141. builder.Write("第" + dac.Days.ToString() + "晚:");
  5142. builder.MoveToCell(0, i, 1, 0);
  5143. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5144. //builder.Write(dac.Place == null ? "" : dac.Place);
  5145. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5146. builder.MoveToCell(0, i, 2, 0);
  5147. builder.Write("费用标准:");
  5148. string curr = "";
  5149. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5150. if (currData != null)
  5151. {
  5152. curr = currData.Name;
  5153. }
  5154. builder.MoveToCell(0, i, 3, 0);
  5155. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5156. builder.MoveToCell(0, i, 4, 0);
  5157. builder.Write("费用小计:");
  5158. builder.MoveToCell(0, i, 5, 0);
  5159. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5160. }
  5161. #endregion
  5162. }
  5163. else dic.Add("SubZS", "0.00");
  5164. //删除多余行
  5165. while (table1.Rows.Count > table1Row)
  5166. {
  5167. table1.Rows.RemoveAt(table1Row);
  5168. }
  5169. //伙食费
  5170. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5171. if (_EnterExitCosts.ChoiceFour == 1)
  5172. {
  5173. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5174. table2Row = dac2.Count;
  5175. #region 填充word表格内容
  5176. for (int i = 0; i < dac2.Count; i++)
  5177. {
  5178. Grp_DayAndCost dac = dac2[i];
  5179. if (dac == null) continue;
  5180. builder.MoveToCell(1, i, 0, 0);
  5181. builder.Write("第" + dac.Days.ToString() + "天:");
  5182. builder.MoveToCell(1, i, 1, 0);
  5183. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5184. builder.MoveToCell(1, i, 2, 0);
  5185. builder.Write("费用标准:");
  5186. string curr = "";
  5187. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5188. if (currData != null)
  5189. {
  5190. curr = currData.Name;
  5191. }
  5192. builder.MoveToCell(1, i, 3, 0);
  5193. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5194. builder.MoveToCell(1, i, 4, 0);
  5195. builder.Write("费用小计:");
  5196. builder.MoveToCell(1, i, 5, 0);
  5197. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5198. }
  5199. #endregion
  5200. }
  5201. else dic.Add("SubHS", "0.00");
  5202. //删除多余行
  5203. while (table2.Rows.Count > table2Row)
  5204. {
  5205. table2.Rows.RemoveAt(table2Row);
  5206. }
  5207. //公杂费
  5208. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5209. if (_EnterExitCosts.ChoiceFive == 1)
  5210. {
  5211. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5212. table3Row = dac3.Count;
  5213. #region 填充word表格内容
  5214. for (int i = 0; i < dac3.Count; i++)
  5215. {
  5216. Grp_DayAndCost dac = dac3[i];
  5217. if (dac == null) continue;
  5218. builder.MoveToCell(2, i, 0, 0);
  5219. builder.Write("第" + dac.Days.ToString() + "天:");
  5220. builder.MoveToCell(2, i, 1, 0);
  5221. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5222. builder.MoveToCell(2, i, 2, 0);
  5223. builder.Write("费用标准:");
  5224. string curr = "";
  5225. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5226. if (currData != null)
  5227. {
  5228. curr = currData.Name;
  5229. }
  5230. builder.MoveToCell(2, i, 3, 0);
  5231. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5232. builder.MoveToCell(2, i, 4, 0);
  5233. builder.Write("费用小计:");
  5234. builder.MoveToCell(2, i, 5, 0);
  5235. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5236. }
  5237. //删除多余行
  5238. while (table3.Rows.Count > table3Row)
  5239. {
  5240. table3.Rows.RemoveAt(table3Row);
  5241. }
  5242. #endregion
  5243. }
  5244. else dic.Add("SubGZF", "0.00");
  5245. //删除多余行
  5246. while (table3.Rows.Count > table3Row)
  5247. {
  5248. table3.Rows.RemoveAt(table3Row);
  5249. }
  5250. //培训费
  5251. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5252. if (_EnterExitCosts.ChoiceSix == 1)
  5253. {
  5254. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5255. dic.Add("SubPX", pxStr);
  5256. table4Row = dac4.Count;
  5257. #region 填充word表格内容
  5258. for (int i = 0; i < dac4.Count; i++)
  5259. {
  5260. Grp_DayAndCost dac = dac4[i];
  5261. if (dac == null) continue;
  5262. builder.MoveToCell(3, i, 0, 0);
  5263. builder.Write("第" + dac.Days.ToString() + "天:");
  5264. builder.MoveToCell(3, i, 1, 0);
  5265. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5266. builder.MoveToCell(3, i, 2, 0);
  5267. builder.Write("费用标准:");
  5268. string curr = "";
  5269. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5270. if (currData != null)
  5271. {
  5272. curr = currData.Name;
  5273. }
  5274. builder.MoveToCell(3, i, 3, 0);
  5275. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5276. builder.MoveToCell(3, i, 4, 0);
  5277. builder.Write("费用小计:");
  5278. builder.MoveToCell(3, i, 5, 0);
  5279. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5280. }
  5281. #endregion
  5282. }
  5283. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5284. //删除多余行
  5285. while (table4.Rows.Count > table4Row)
  5286. {
  5287. table4.Rows.RemoveAt(table4Row);
  5288. }
  5289. //其他费用
  5290. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5291. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5292. {
  5293. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5294. dic.Add("titleQi", qtStr);
  5295. table5Row = dac5.Count;
  5296. #region 填充word表格内容
  5297. for (int i = 0; i < dac5.Count; i++)
  5298. {
  5299. var dac = dac5[i];
  5300. if (dac == null) continue;
  5301. builder.MoveToCell(4, i, 0, 0);
  5302. builder.Write("第" + dac.Index.ToString() + "项:");
  5303. builder.MoveToCell(4, i, 1, 0);
  5304. builder.Write(dac.itemName);
  5305. builder.MoveToCell(4, i, 2, 0);
  5306. builder.Write("费用标准:");
  5307. builder.MoveToCell(4, i, 3, 0);
  5308. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5309. builder.MoveToCell(4, i, 4, 0);
  5310. builder.Write("费用小计:");
  5311. builder.MoveToCell(4, i, 5, 0);
  5312. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5313. builder.MoveToCell(4, i, 6, 0);
  5314. builder.Write("备注:");
  5315. builder.MoveToCell(4, i, 7, 0);
  5316. builder.Write(dac.Remark);
  5317. }
  5318. #endregion
  5319. }
  5320. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5321. //删除多余行
  5322. while (table5.Rows.Count > table5Row)
  5323. {
  5324. table5.Rows.RemoveAt(table5Row);
  5325. }
  5326. //加上其他费用
  5327. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5328. decimal subJJC = 0.00M,
  5329. subGWC = 0.00M,
  5330. subTDC = 0.00M;
  5331. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5332. string totalLabel = string.Format("全部费用总计:");
  5333. //经济舱
  5334. if (_EnterExitCosts.SumJJC == 1)
  5335. {
  5336. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5337. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5338. }
  5339. //公务舱
  5340. if (_EnterExitCosts.SumGWC == 1) {
  5341. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5342. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5343. }
  5344. //头等舱
  5345. if (_EnterExitCosts.SumTDC == 1)
  5346. {
  5347. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5348. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5349. }
  5350. //TotalLabel
  5351. dic.Add("TotalLabel", totalLabel);
  5352. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5353. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5354. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5355. #region 填充word模板书签内容
  5356. foreach (var key in dic.Keys)
  5357. {
  5358. Bookmark bookmark = doc.Range.Bookmarks[key];
  5359. if (bookmark != null)
  5360. {
  5361. builder.MoveToBookmark(key);
  5362. builder.Write(dic[key]);
  5363. }
  5364. }
  5365. #endregion
  5366. #region 设置页眉
  5367. string userLabel = string.Empty;
  5368. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5369. if (currUserInfo != null)
  5370. {
  5371. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5372. if (userInfo != null)
  5373. {
  5374. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5375. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5376. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5377. }
  5378. }
  5379. //设置页脚
  5380. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5381. #endregion
  5382. //文件名
  5383. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5384. AsposeHelper.removewatermark_v2180();
  5385. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5386. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5387. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5388. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5389. }
  5390. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5391. {
  5392. //获取模板
  5393. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5394. //载入模板
  5395. Document doc = new Document(tempPath);
  5396. DocumentBuilder builder = new DocumentBuilder(doc);
  5397. Dictionary<string, string> dic = new Dictionary<string, string>();
  5398. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5399. {
  5400. List<string> list = new List<string>();
  5401. try
  5402. {
  5403. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5404. foreach (var item in spilitArr)
  5405. {
  5406. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5407. var depCode = spDotandEmpty[2].Substring(0, 3);
  5408. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5409. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5410. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5411. list.Add(depName);
  5412. list.Add(arrName);
  5413. }
  5414. list = list.Distinct().ToList();
  5415. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5416. }
  5417. catch (Exception)
  5418. {
  5419. dic.Add("ReturnCode", "行程录入不正确!");
  5420. }
  5421. }
  5422. else
  5423. {
  5424. dic.Add("ReturnCode", "未录入行程!");
  5425. }
  5426. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5427. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5428. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5429. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5430. {
  5431. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5432. dic.Add("Day", sp.Days.ToString());
  5433. }
  5434. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5435. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5436. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5437. //dic.Add("Names", Names);
  5438. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5439. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5440. decimal dac1totalPrice = 0.00M;
  5441. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5442. foreach (var dac in dac1)
  5443. {
  5444. if (dac.SubTotal == 0.00M)
  5445. {
  5446. continue;
  5447. }
  5448. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5449. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5450. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5451. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5452. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5453. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5454. builder.Write(currency);//币种
  5455. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5456. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5457. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5458. builder.Write("");//人数
  5459. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5460. builder.Write("");//天数
  5461. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5462. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5463. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5464. decimal rate = 0.00M;
  5465. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5466. builder.Write(rate.ToString("#0.0000"));//汇率
  5467. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5468. decimal rbmPrice = dac.SubTotal;
  5469. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5470. accommodationStartIndex++;
  5471. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5472. }
  5473. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5474. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5475. {
  5476. table1.Rows.RemoveAt(i - 1);
  5477. foodandotherStartIndex--;
  5478. }
  5479. if (dac2.Count == dac3.Count)//国家 币种 金额
  5480. {
  5481. for (int i = 0; i < dac2.Count; i++)
  5482. {
  5483. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5484. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5485. }
  5486. }
  5487. decimal dac2totalPrice = 0.00M;
  5488. foreach (var dac in dac2)
  5489. {
  5490. if (dac.SubTotal == 0)
  5491. {
  5492. continue;
  5493. }
  5494. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5495. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5496. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5497. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5498. builder.Write(currency);//币种
  5499. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5500. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5501. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5502. builder.Write("");//人数
  5503. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5504. builder.Write("");//天数
  5505. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5506. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5507. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5508. decimal rate = 0.00M;
  5509. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5510. builder.Write(rate.ToString("#0.0000"));//汇率
  5511. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5512. decimal rbmPrice = dac.SubTotal;
  5513. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5514. foodandotherStartIndex++;
  5515. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5516. }
  5517. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5518. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5519. {
  5520. table1.Rows.RemoveAt(i - 1);
  5521. }
  5522. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5523. string otherFeeStr = "";
  5524. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5525. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5526. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5527. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5528. foreach (var otherInfo in dac5)
  5529. {
  5530. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5531. }
  5532. #endregion
  5533. if (otherFeeStr.Length > 0)
  5534. {
  5535. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5536. otherFeeStr = $"({otherFeeStr})";
  5537. dic.Add("OtherFeeStr", otherFeeStr);
  5538. }
  5539. //总计
  5540. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5541. //国际旅费
  5542. string outsideAir = string.Empty;
  5543. string allPriceAir = string.Empty;
  5544. if (_EnterExitCosts.SumJJC == 1)
  5545. {
  5546. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5547. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5548. }
  5549. if (_EnterExitCosts.SumGWC == 1)
  5550. {
  5551. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5552. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5553. }
  5554. if (_EnterExitCosts.SumTDC == 1)
  5555. {
  5556. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5557. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5558. }
  5559. dic.Add("InTravelPrice", $"({outsideAir})");
  5560. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5561. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5562. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5563. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5564. foreach (var key in dic.Keys)
  5565. {
  5566. builder.MoveToBookmark(key);
  5567. builder.Write(dic[key]);
  5568. }
  5569. //模板文件名
  5570. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5571. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5572. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5573. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5574. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5575. }
  5576. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5577. {
  5578. //获取模板
  5579. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5580. //载入模板
  5581. WorkbookDesigner designer = new WorkbookDesigner();
  5582. designer.Workbook = new Workbook(tempPath);
  5583. Dictionary<string, string> dic = new Dictionary<string, string>();
  5584. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5585. {
  5586. List<string> list = new List<string>();
  5587. try
  5588. {
  5589. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5590. foreach (var item in spilitArr)
  5591. {
  5592. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5593. var depCode = spDotandEmpty[2].Substring(0, 3);
  5594. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5595. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5596. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5597. list.Add(depName);
  5598. list.Add(arrName);
  5599. }
  5600. list = list.Distinct().ToList();
  5601. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5602. }
  5603. catch (Exception)
  5604. {
  5605. dic.Add("ReturnCode", "行程录入不正确!");
  5606. }
  5607. }
  5608. else
  5609. {
  5610. dic.Add("ReturnCode", "未录入行程!");
  5611. }
  5612. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5613. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5614. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5615. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5616. {
  5617. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5618. dic.Add("Day", sp.Days.ToString());
  5619. }
  5620. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5621. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5622. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5623. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5624. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5625. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5626. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5627. designer.SetDataSource("Name", Names);
  5628. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5629. designer.SetDataSource("Day", dic["Day"] + "天");
  5630. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5631. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5632. int startIndex = 10;
  5633. const int startIndexcopy = 10;
  5634. if (dac2.Count == dac3.Count)//国家 币种 金额
  5635. {
  5636. for (int i = 0; i < dac2.Count; i++)
  5637. {
  5638. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5639. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5640. }
  5641. }
  5642. DataTable dtdac1 = new DataTable();
  5643. List<string> place = new List<string>();
  5644. dtdac1.Columns.AddRange(new DataColumn[] {
  5645. new DataColumn(){ ColumnName = "city"},
  5646. new DataColumn(){ ColumnName = "curr"},
  5647. new DataColumn(){ ColumnName = "criterion"},
  5648. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5649. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5650. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5651. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5652. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5653. });
  5654. DataTable dtdac2 = new DataTable();
  5655. dtdac2.Columns.AddRange(new DataColumn[] {
  5656. new DataColumn(){ ColumnName = "city"},
  5657. new DataColumn(){ ColumnName = "curr"},
  5658. new DataColumn(){ ColumnName = "criterion"},
  5659. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5660. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5661. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5662. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5663. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5664. });
  5665. dtdac1.TableName = "tb1";
  5666. dtdac2.TableName = "tb2";
  5667. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5668. foreach (var item in dac1)
  5669. {
  5670. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5671. if (place.Contains(item.Place))
  5672. {
  5673. continue;
  5674. }
  5675. DataRow row = dtdac1.NewRow();
  5676. row["city"] = item.Place;
  5677. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5678. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5679. row["curr"] = currency;
  5680. row["rate"] = rate.ToString("#0.0000");
  5681. row["criterion"] = item.Cost.ToString("#0.00");
  5682. row["number"] = 1;
  5683. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5684. //row["costRMB"] = rbmPrice;
  5685. dtdac1.Rows.Add(row);
  5686. place.Add(item.Place);
  5687. }
  5688. place = new List<string>();
  5689. foreach (var item in dac2)
  5690. {
  5691. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5692. if (place.Contains(item.Place))
  5693. {
  5694. continue;
  5695. }
  5696. DataRow row = dtdac2.NewRow();
  5697. row["city"] = item.Place;
  5698. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5699. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5700. row["curr"] = currency;
  5701. row["rate"] = rate.ToString("#0.0000");
  5702. row["criterion"] = item.Cost.ToString("#0.00");
  5703. row["number"] = 1;
  5704. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5705. //row["cost"] = item.SubTotal;
  5706. //row["costRMB"] = rbmPrice;
  5707. dtdac2.Rows.Add(row);
  5708. place.Add(item.Place);
  5709. //dac2totalPrice += rbmPrice;
  5710. }
  5711. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5712. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5713. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5714. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5715. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5716. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5717. string cell4Str1 = string.Empty;
  5718. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5719. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5720. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5721. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5722. string cellStr = $" 5.其他费用(";
  5723. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5724. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5725. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5726. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5727. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5728. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5729. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5730. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5731. foreach (var otherInfo in dac5)
  5732. {
  5733. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5734. }
  5735. #endregion
  5736. if (cellStr.Length > 8)
  5737. {
  5738. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5739. }
  5740. cellStr += ")";
  5741. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5742. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5743. decimal pxFee = dac4.Sum(it => it.Cost);
  5744. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5745. string celllastStr1 = "";
  5746. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5747. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5748. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5749. celllastStr1 += $",国际旅费 元";
  5750. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5751. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5752. designer.SetDataSource("cell4Str", cell4Str);
  5753. designer.SetDataSource("cellStr", cellStr);
  5754. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5755. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5756. designer.SetDataSource("celllastStr", celllastStr);
  5757. Workbook wb = designer.Workbook;
  5758. var sheet = wb.Worksheets[0];
  5759. //绑定datatable数据集
  5760. designer.SetDataSource(dtdac1);
  5761. designer.SetDataSource(dtdac2);
  5762. designer.Process();
  5763. var rowStart = dtdac1.Rows.Count;
  5764. while (rowStart > 0)
  5765. {
  5766. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5767. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5768. startIndex++;
  5769. rowStart--;
  5770. }
  5771. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5772. startIndex += 1; //总计行
  5773. rowStart = dtdac2.Rows.Count;
  5774. while (rowStart > 0)
  5775. {
  5776. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5777. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5778. startIndex++;
  5779. rowStart--;
  5780. }
  5781. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5782. wb.CalculateFormula(true);
  5783. //模板文件名
  5784. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5785. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5786. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5787. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5788. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5789. }
  5790. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5791. {
  5792. //获取模板
  5793. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5794. //载入模板
  5795. Document doc = new Document(tempPath);
  5796. DocumentBuilder builder = new DocumentBuilder(doc);
  5797. Dictionary<string, string> dic = new Dictionary<string, string>();
  5798. dic.Add("GroupName", _DelegationInfo.TeamName);
  5799. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5800. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5801. string missionLeaderJob = "";//负责人job
  5802. //int groupNumber = 0; //团人数
  5803. if (DeleClientList.Count > 0)
  5804. {
  5805. missionLeader = DeleClientList[0]?.Name ?? "";
  5806. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5807. }
  5808. dic.Add("MissionLeader", missionLeader); //团负责人
  5809. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5810. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5811. #region MyRegion
  5812. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5813. //{
  5814. // List<string> list = new List<string>();
  5815. // try
  5816. // {
  5817. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5818. // foreach (var item in spilitArr)
  5819. // {
  5820. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5821. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5822. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5823. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5824. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5825. // list.Add(depName);
  5826. // list.Add(arrName);
  5827. // }
  5828. // list = list.Distinct().ToList();
  5829. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5830. // }
  5831. // catch (Exception)
  5832. // {
  5833. // dic.Add("ReturnCode", "行程录入不正确!");
  5834. // }
  5835. //}
  5836. //else
  5837. //{
  5838. // dic.Add("ReturnCode", "未录入行程!");
  5839. //}
  5840. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5841. dic.Add("ReturnCode", string.Join("、", countrys));
  5842. #endregion
  5843. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5844. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5845. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5846. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5847. //{
  5848. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5849. // dic.Add("Day", sp.Days.ToString());
  5850. //}
  5851. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5852. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5853. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5854. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5855. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5856. //培训人员名单
  5857. int cultivateRowIndex = 7;
  5858. foreach (var item in DeleClientList)
  5859. {
  5860. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5861. builder.Write(item.Name);
  5862. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5863. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5864. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5865. string birthDay = "";
  5866. if (item.Birthday != null)
  5867. {
  5868. DateTime dt = Convert.ToDateTime(item.Birthday);
  5869. birthDay = $"{dt.Year}.{dt.Month}";
  5870. }
  5871. builder.Write(birthDay);
  5872. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5873. builder.Write(item.Company);
  5874. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5875. builder.Write(item.Job);
  5876. cultivateRowIndex++;
  5877. }
  5878. //删除多余行
  5879. //cultivateRowIndex -= 2;
  5880. int delRows = 10 + 7 - cultivateRowIndex;
  5881. if (delRows > 0)
  5882. {
  5883. for (int i = 0; i < delRows; i++)
  5884. {
  5885. table1.Rows.RemoveAt(cultivateRowIndex);
  5886. //cultivateRowIndex++;
  5887. }
  5888. }
  5889. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5890. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5891. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5892. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5893. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5894. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5895. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5896. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5897. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5898. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5899. //其他费用
  5900. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5901. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5902. //其他费用合计
  5903. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5904. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5905. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5906. //公务舱合计
  5907. //国际旅费
  5908. //string outsideJJ = "";
  5909. //string allPriceJJ = "";
  5910. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5911. {
  5912. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5913. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5914. }
  5915. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5916. {
  5917. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5918. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5919. }
  5920. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5921. {
  5922. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5923. dic.Add("AirFeeTotal", airFeeTotalStr);
  5924. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5925. dic.Add("FeeTotal", feeTotalStr);
  5926. }
  5927. foreach (var key in dic.Keys)
  5928. {
  5929. builder.MoveToBookmark(key);
  5930. builder.Write(dic[key]);
  5931. }
  5932. //模板文件名
  5933. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5934. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5935. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5936. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5937. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5938. }
  5939. }
  5940. else if (dto.ExportType == 2) //表格
  5941. {
  5942. //利用键值对存放数据
  5943. Dictionary<string, string> dic = new Dictionary<string, string>();
  5944. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5945. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5946. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5947. dic.Add("Day", sp.Days.ToString());
  5948. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5949. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5950. {
  5951. //获取模板
  5952. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5953. //载入模板
  5954. Document doc = new Document(tempPath);
  5955. DocumentBuilder builder = new DocumentBuilder(doc);
  5956. dic.Add("TeamName", _DelegationInfo.TeamName);
  5957. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5958. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5959. string missionLeaderName = "",
  5960. missionLeaderJob = "";
  5961. if (DeleClientList.Count > 0)
  5962. {
  5963. missionLeaderName = DeleClientList[0].Name;
  5964. missionLeaderJob = DeleClientList[0].Job;
  5965. }
  5966. dic.Add("MissionLeaderName", missionLeaderName);
  5967. dic.Add("MissionLeaderJob", missionLeaderJob);
  5968. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5969. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5970. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5971. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5972. int rowCount = 10;//总人数行
  5973. int startRowIndex = 7; //起始行
  5974. for (int i = 0; i < DeleClientList.Count; i++)
  5975. {
  5976. builder.MoveToCell(0, startRowIndex, 0, 0);
  5977. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5978. builder.MoveToCell(0, startRowIndex, 1, 0);
  5979. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5980. builder.Write(sex);//性别
  5981. builder.MoveToCell(0, startRowIndex, 2, 0);
  5982. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5983. builder.MoveToCell(0, startRowIndex, 3, 0);
  5984. builder.Write(DeleClientList[i].Company);//工作单位
  5985. builder.MoveToCell(0, startRowIndex, 4, 0);
  5986. builder.Write(DeleClientList[i].Job);//职务及级别
  5987. builder.MoveToCell(0, startRowIndex, 5, 0);
  5988. builder.Write("");//人员属性
  5989. builder.MoveToCell(0, startRowIndex, 6, 0);
  5990. builder.Write("");//上次出国时间
  5991. startRowIndex++;
  5992. }
  5993. int nullRow = rowCount - DeleClientList.Count;//空行
  5994. for (int i = 0; i < nullRow; i++)
  5995. {
  5996. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5997. }
  5998. foreach (var key in dic.Keys)
  5999. {
  6000. builder.MoveToBookmark(key);
  6001. builder.Write(dic[key]);
  6002. }
  6003. //模板文件名
  6004. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6005. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6006. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6007. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6008. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6009. }
  6010. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6011. {
  6012. //获取模板
  6013. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6014. //载入模板
  6015. Document doc = new Document(tempPath);
  6016. DocumentBuilder builder = new DocumentBuilder(doc);
  6017. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6018. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6019. dic.Add("Names", Names);
  6020. int accommodationRows = 12;
  6021. //int foodandotherRows = 12;
  6022. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6023. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6024. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6025. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6026. int accommodationStartIndex = 6;
  6027. decimal dac1totalPrice = 0.00M;
  6028. foreach (var dac in dac1)
  6029. {
  6030. if (dac.SubTotal == 0)
  6031. {
  6032. continue;
  6033. }
  6034. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6035. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6036. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6037. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6038. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6039. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6040. builder.Write(currency);//币种
  6041. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6042. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6043. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6044. builder.Write("");//人数
  6045. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6046. builder.Write("");//天数
  6047. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6048. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6049. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6050. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6051. builder.Write(rate.ToString("#0.0000"));//汇率
  6052. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6053. decimal rbmPrice = rate * dac.SubTotal;
  6054. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6055. accommodationStartIndex++;
  6056. dac1totalPrice += rbmPrice;
  6057. }
  6058. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6059. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6060. builder.Write("小计");
  6061. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6062. builder.Write(dac1totalPrice.ToString("#0.00"));
  6063. accommodationStartIndex++;
  6064. int nullRow = accommodationRows - dac1.Count;
  6065. //删除空行
  6066. //if (nullRow > 0)
  6067. //{
  6068. // int rowIndex = accommodationStartIndex;
  6069. // for (int i = 0; i < nullRow; i++)
  6070. // {
  6071. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6072. // row.Remove();
  6073. // rowIndex++;
  6074. // }
  6075. //}
  6076. if (dac2.Count == dac3.Count)//国家 币种 金额
  6077. {
  6078. for (int i = 0; i < dac2.Count; i++)
  6079. {
  6080. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6081. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6082. }
  6083. }
  6084. int foodandotherStartIndex = 19;//
  6085. decimal dac2totalPrice = 0.00M;
  6086. foreach (var dac in dac2)
  6087. {
  6088. if (dac.SubTotal == 0)
  6089. {
  6090. continue;
  6091. }
  6092. //foodandotherStartIndex = 12;
  6093. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6094. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6095. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6096. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6097. builder.Write(currency);//币种
  6098. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6099. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6100. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6101. builder.Write("");//人数
  6102. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6103. builder.Write("");//天数
  6104. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6105. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6106. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6107. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6108. builder.Write(rate.ToString("#0.0000"));//汇率
  6109. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6110. decimal rbmPrice = rate * dac.SubTotal;
  6111. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6112. foodandotherStartIndex++;
  6113. dac2totalPrice += rbmPrice;
  6114. }
  6115. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6116. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6117. //删除空行
  6118. //if (dac2.Count < foodandotherRows)
  6119. //{
  6120. // while (table2.Rows.Count > dac2.Count)
  6121. // {
  6122. // table2.Rows.RemoveAt(dac2.Count);
  6123. // }
  6124. //}
  6125. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6126. string otherFeeStr = "";
  6127. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6128. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6129. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6130. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6131. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6132. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6133. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6134. foreach (var otherInfo in dac5)
  6135. {
  6136. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6137. }
  6138. #endregion
  6139. if (otherFeeStr.Length > 0)
  6140. {
  6141. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6142. otherFeeStr = $"({otherFeeStr})";
  6143. dic.Add("OtherFeeStr", otherFeeStr);
  6144. }
  6145. foreach (var key in dic.Keys)
  6146. {
  6147. builder.MoveToBookmark(key);
  6148. builder.Write(dic[key]);
  6149. }
  6150. //模板文件名
  6151. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6152. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6153. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6154. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6155. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6156. }
  6157. }
  6158. else if (dto.ExportType == 3)
  6159. {
  6160. if (dto.SubTypeId == 1) //团组成员名单
  6161. {
  6162. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6163. //获取模板
  6164. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6165. //载入模板
  6166. Document doc = new Document(tempPath);
  6167. DocumentBuilder builder = new DocumentBuilder(doc);
  6168. //获取word里所有表格
  6169. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6170. //获取所填表格的序数
  6171. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6172. var rowStart = tableOne.Rows[0]; //获取第1行
  6173. //循环赋值
  6174. for (int i = 0; i < DeleClientList.Count; i++)
  6175. {
  6176. builder.MoveToCell(0, i + 1, 0, 0);
  6177. builder.Write(DeleClientList[i].Name);
  6178. builder.MoveToCell(0, i + 1, 1, 0);
  6179. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6180. builder.Write(sex);
  6181. builder.MoveToCell(0, i + 1, 2, 0);
  6182. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6183. builder.MoveToCell(0, i + 1, 3, 0);
  6184. builder.Write(DeleClientList[i].Company);
  6185. builder.MoveToCell(0, i + 1, 4, 0);
  6186. builder.Write(DeleClientList[i].Job);
  6187. }
  6188. //删除多余行
  6189. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6190. {
  6191. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6192. }
  6193. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6194. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6195. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6196. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6197. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6198. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6199. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6200. }
  6201. }
  6202. return Ok(JsonView(400, "操作失败!", ""));
  6203. }
  6204. catch (Exception ex)
  6205. {
  6206. return Ok(JsonView(400, ex.Message, ""));
  6207. }
  6208. }
  6209. /// <summary>
  6210. /// 获取三公费用标准city
  6211. /// </summary>
  6212. /// <param name="placeData"></param>
  6213. /// <param name="nationalTravelFeeId"></param>
  6214. /// <returns></returns>
  6215. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6216. {
  6217. string _city = string.Empty;
  6218. if (placeData.Count < 1) return _city;
  6219. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6220. if (data == null) return _city;
  6221. string country = data.Country;
  6222. string city = data.City;
  6223. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6224. else _city = city;
  6225. return _city;
  6226. }
  6227. /// <summary>
  6228. /// 团组模块 - 出入境费用 - 明细表导出
  6229. /// </summary>
  6230. /// <returns></returns>
  6231. [HttpPost]
  6232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6233. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6234. {
  6235. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6236. if (data.Code != 0)
  6237. {
  6238. return Ok(JsonView(false, data.Msg));
  6239. }
  6240. return Ok(JsonView(true, data.Msg, data.Data));
  6241. }
  6242. /// <summary>
  6243. /// 团组模块 - 出入境费用 - 一键清空
  6244. /// </summary>
  6245. /// <returns></returns>
  6246. [HttpPost]
  6247. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6249. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6250. {
  6251. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6252. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6253. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6254. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6255. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6256. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6257. .SetColumns(x => new Grp_DayOtherPrice
  6258. {
  6259. IsDel = 1,
  6260. DeleteUserId = dto.UserId,
  6261. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6262. })
  6263. .ExecuteCommandAsync();
  6264. if (_view.Code == 0)
  6265. {
  6266. return Ok(JsonView(true, "操作成功"));
  6267. }
  6268. return Ok(JsonView(false, "操作失败"));
  6269. }
  6270. /// <summary>
  6271. /// 团组模块 - 出入境费用 - 子项删除
  6272. /// </summary>
  6273. /// <returns></returns>
  6274. [HttpPost]
  6275. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6277. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6278. {
  6279. try
  6280. {
  6281. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6282. if (data.Code != 0)
  6283. {
  6284. return Ok(JsonView(false, data.Msg));
  6285. }
  6286. return Ok(JsonView(true, "操作成功!", data.Data));
  6287. }
  6288. catch (Exception ex)
  6289. {
  6290. return Ok(JsonView(false, ex.Message));
  6291. }
  6292. }
  6293. /// <summary>
  6294. /// 删除三公其他费用
  6295. /// </summary>
  6296. /// <param name="dto"></param>
  6297. /// <returns></returns>
  6298. [HttpPost]
  6299. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6300. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6301. {
  6302. var jw = JsonView(false, "删除失败!");
  6303. var data = new Grp_DayOtherPrice()
  6304. {
  6305. Id = dto.Id,
  6306. IsDel = 1,
  6307. DeleteUserId = dto.DeleteUserId,
  6308. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6309. };
  6310. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6311. if (del > 0)
  6312. {
  6313. jw.Code = 200;
  6314. jw.Msg = "删除成功!";
  6315. }
  6316. return Ok(jw);
  6317. }
  6318. /// <summary>
  6319. /// 团组模块 - 出入境国家费用标准 List
  6320. /// </summary>
  6321. /// <returns></returns>
  6322. [HttpPost]
  6323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6324. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6325. {
  6326. try
  6327. {
  6328. Stopwatch sw = new Stopwatch();
  6329. sw.Start();
  6330. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6331. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6332. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6333. Where gntf.Isdel = 0");
  6334. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6335. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6336. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6337. //foreach (var item in nationalTravel)
  6338. //{
  6339. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6340. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6341. // if (otherData != null)
  6342. // {
  6343. // cityData.Remove(otherData);
  6344. // cityData.Add(otherData);
  6345. // }
  6346. // nationalTravelFeeData1.Add(new
  6347. // {
  6348. // Country = item.Country,
  6349. // CityData = cityData
  6350. // });
  6351. //}
  6352. sw.Stop();
  6353. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6354. }
  6355. catch (Exception ex)
  6356. {
  6357. return Ok(JsonView(false, ex.Message));
  6358. throw;
  6359. }
  6360. }
  6361. /// <summary>
  6362. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6363. /// </summary>
  6364. /// <returns></returns>
  6365. [HttpPost]
  6366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6367. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6368. {
  6369. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6370. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6371. List<string> countryData = new List<string>();
  6372. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6373. countryData = countryData.Distinct().ToList();
  6374. List<dynamic> dataSource = new List<dynamic>();
  6375. foreach (var item in countryData)
  6376. {
  6377. var cityData1 = new List<string>();
  6378. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6379. var countryData2 = new
  6380. {
  6381. CountryName = item,
  6382. CityData = cityData1
  6383. };
  6384. dataSource.Add(countryData2);
  6385. }
  6386. return Ok(JsonView(true, "查询成功!", dataSource));
  6387. }
  6388. /// <summary>
  6389. /// 团组模块 - 出入境国家费用标准 Page List
  6390. /// </summary>
  6391. /// <returns></returns>
  6392. [HttpPost]
  6393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6394. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6395. {
  6396. int portId = dto.PortType;
  6397. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6398. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6399. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6400. string whereSql = string.Empty;
  6401. if (!string.IsNullOrEmpty(dto.Country))
  6402. {
  6403. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6404. }
  6405. if (!string.IsNullOrEmpty(dto.City))
  6406. {
  6407. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6408. }
  6409. string pageSql = string.Format(@"Select * From (
  6410. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6411. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6412. From Grp_NationalTravelFee gntf
  6413. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6414. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6415. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6416. RefAsync<int> total = 0;
  6417. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6418. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6419. }
  6420. /// <summary>
  6421. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6422. /// </summary>
  6423. /// <returns></returns>
  6424. [HttpPost]
  6425. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6426. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6427. {
  6428. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6429. int portId = dto.PortType;
  6430. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6431. string whereSql = string.Empty;
  6432. if (!string.IsNullOrEmpty(dto.Country))
  6433. {
  6434. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6435. }
  6436. if (!string.IsNullOrEmpty(dto.City))
  6437. {
  6438. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6439. }
  6440. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6441. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6442. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6443. From Grp_NationalTravelFee gntf
  6444. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6445. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6446. Where gntf.Isdel = 0 {0} ", whereSql);
  6447. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6448. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6449. }
  6450. /// <summary>
  6451. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6452. /// </summary>
  6453. /// <returns></returns>
  6454. [HttpPost]
  6455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6456. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6457. {
  6458. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6459. if (data.Code != 0)
  6460. {
  6461. return Ok(JsonView(false, data.Msg));
  6462. }
  6463. return Ok(JsonView(true, "操作成功!", data.Data));
  6464. }
  6465. /// <summary>
  6466. /// 团组模块 - 出入境国家费用标准 - Del
  6467. /// </summary>
  6468. /// <returns></returns>
  6469. [HttpPost]
  6470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6471. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6472. {
  6473. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6474. {
  6475. Id = dto.Id,
  6476. DeleteUserId = dto.DeleteUserId,
  6477. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6478. IsDel = 1
  6479. };
  6480. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6481. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6482. .WhereColumns(it => new { it.Id })
  6483. .ExecuteCommandAsync();
  6484. if (delStatus <= 0)
  6485. {
  6486. return Ok(JsonView(false, "删除失败!"));
  6487. }
  6488. return Ok(JsonView(true, "操作成功!"));
  6489. }
  6490. /// <summary>
  6491. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6492. /// 注:Get 请求Headers 加 Token
  6493. /// </summary>
  6494. /// <param name="groupId"></param>
  6495. /// <returns></returns>
  6496. [HttpGet("{groupId}")]
  6497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6498. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6499. {
  6500. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6501. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6502. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6503. data.ForEach(x =>
  6504. {
  6505. x.CreateUserId = _currUserInfo.UserId;
  6506. });
  6507. if (data.Any())
  6508. {
  6509. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6510. if (add > 0)
  6511. {
  6512. return Ok(JsonView(true, "操作成功!"));
  6513. }
  6514. }
  6515. return Ok(JsonView(false, "未操作!"));
  6516. }
  6517. #endregion
  6518. #region 团组经理模块 出入境费用-草稿
  6519. /// <summary>
  6520. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6521. /// </summary>
  6522. /// <returns></returns>
  6523. [HttpPost]
  6524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6525. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6526. {
  6527. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6528. .Where(x => x.IsDel == 0)
  6529. .OrderByDescending(x => x.CreateTime)
  6530. .Select(x => new { x.Id, x.DraftName })
  6531. .ToListAsync();
  6532. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6533. //SetDataInfoView
  6534. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6535. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6536. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6537. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6538. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6539. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6540. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6541. //默认币种显示
  6542. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6543. {
  6544. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6545. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6546. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6547. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6548. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6549. };
  6550. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  6551. if (_currencyRate.Count > 0)
  6552. {
  6553. foreach (var item in _currencyInfos)
  6554. {
  6555. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6556. if (rateInfo != null)
  6557. {
  6558. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6559. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  6560. else rate1 *= 1.035M;
  6561. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6562. }
  6563. }
  6564. }
  6565. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6566. return Ok(JsonView(true, "查询成功!", new
  6567. {
  6568. DraftNameDatas = draftNameDatas,
  6569. CurrencyData = _CurrencyData,
  6570. WordTypeData = _WordTypeData,
  6571. ExcelTypeData = _ExcelTypeData,
  6572. CurrencyInit = _currencyInfos,
  6573. ViewPermissionData = viewPermissionData
  6574. }));
  6575. }
  6576. /// <summary>
  6577. /// 团组模块 - 出入境费用-草稿
  6578. /// 实时汇率 tips
  6579. /// 签证费用 tips
  6580. /// 机票费用 tips
  6581. /// </summary>
  6582. /// <returns></returns>
  6583. [HttpPost]
  6584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6585. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6586. {
  6587. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6588. //默认币种显示
  6589. var _currencyInfos = _currencyInit;
  6590. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  6591. List<dynamic> reteInfos = new List<dynamic>();
  6592. if (_currencyRate.Count > 0)
  6593. {
  6594. foreach (var item in _currencyInfos)
  6595. {
  6596. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6597. if (rateInfo != null)
  6598. {
  6599. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6600. decimal rate1 = item.Rate;
  6601. rate1 *= 1.03M;
  6602. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6603. reteInfos.Add(new
  6604. {
  6605. currCode = item.CurrencyCode,
  6606. currName = item.CurrencyName,
  6607. rate = rate2,
  6608. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6609. });
  6610. }
  6611. }
  6612. }
  6613. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6614. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6615. return Ok(JsonView(true, "查询成功!", new
  6616. {
  6617. //GroupNameData = groupNameData.Data,
  6618. //visaData = visaData.Data,
  6619. //airData = airData.Data,
  6620. reteInfos = reteInfos
  6621. }));
  6622. }
  6623. /// <summary>
  6624. /// 团组模块 - 出入境费用-草稿 - Info
  6625. /// </summary>
  6626. /// <returns></returns>
  6627. [HttpPost]
  6628. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6630. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6631. {
  6632. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6633. }
  6634. /// <summary>
  6635. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6636. /// </summary>
  6637. /// <returns></returns>
  6638. [HttpPost]
  6639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6640. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6641. {
  6642. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6643. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6644. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6645. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6646. foreach (var userId in dto.UserIds)
  6647. {
  6648. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6649. }
  6650. if (permissions.Any())
  6651. {
  6652. _sqlSugar.BeginTran();
  6653. try
  6654. {
  6655. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6656. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6657. if (result < 1)
  6658. {
  6659. _sqlSugar.RollbackTran();
  6660. return Ok(JsonView(false));
  6661. }
  6662. }
  6663. catch (Exception ex)
  6664. {
  6665. _sqlSugar.RollbackTran();
  6666. return Ok(JsonView(false, ex.Message));
  6667. }
  6668. _sqlSugar.CommitTran();
  6669. return Ok(JsonView(true));
  6670. }
  6671. return Ok(JsonView(false));
  6672. }
  6673. /// <summary>
  6674. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6675. /// </summary>
  6676. /// <returns></returns>
  6677. [HttpPost]
  6678. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6680. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6681. {
  6682. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6683. if (data.Code != 0)
  6684. {
  6685. return Ok(JsonView(false, data.Msg));
  6686. }
  6687. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6688. //汇率信息记录
  6689. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6690. return Ok(JsonView(true, data.Msg, data.Data));
  6691. }
  6692. /// <summary>
  6693. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6694. /// </summary>
  6695. /// <param name="dto"></param>
  6696. /// <returns></returns>
  6697. [HttpPost]
  6698. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6700. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6701. {
  6702. try
  6703. {
  6704. var id = dto.Id;
  6705. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6706. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6707. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6708. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6709. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6710. 3 团组成员名单 1 团组成员名单", ""));
  6711. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6712. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6713. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6714. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6715. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6716. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6717. //数据源
  6718. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6719. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6720. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6721. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6722. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6723. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6724. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6725. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6726. .Select((x, a, b) => new
  6727. {
  6728. x.Index,
  6729. itemName = a.Name,
  6730. CurrencyStr = b.Name,
  6731. x.Cost,
  6732. x.SubTotal,
  6733. x.Remark
  6734. })
  6735. .OrderBy((x) => x.Index)
  6736. .ToList(); //其他款项费用
  6737. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6738. var peiceItemCurrencys = new List<string>();
  6739. if (_DayAndCosts.Any())
  6740. {
  6741. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6742. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6743. }
  6744. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6745. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6746. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6747. {
  6748. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6749. }
  6750. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6751. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6752. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6753. if (dto.ExportType == 1) //明细表
  6754. {
  6755. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6756. {
  6757. //获取模板
  6758. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6759. //载入模板
  6760. Document doc = new Document(tempPath);
  6761. DocumentBuilder builder = new DocumentBuilder(doc);
  6762. //利用键值对存放数据
  6763. Dictionary<string, string> dic = new Dictionary<string, string>();
  6764. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6765. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6766. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6767. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6768. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6769. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6770. //境内费用(其他费用)
  6771. if (_EnterExitCosts.ChoiceOne == 1)
  6772. {
  6773. string row1_1 = "";
  6774. if (_EnterExitCosts.Visa > 0)
  6775. {
  6776. //insidePayTotal += _EnterExitCosts.Visa;
  6777. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6778. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6779. {
  6780. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6781. }
  6782. }
  6783. string row1_2 = "";
  6784. if (_EnterExitCosts.YiMiao > 0)
  6785. {
  6786. //insidePayTotal += _EnterExitCosts.YiMiao;
  6787. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6788. }
  6789. if (_EnterExitCosts.HeSuan > 0)
  6790. {
  6791. //insidePayTotal += _EnterExitCosts.HeSuan;
  6792. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6793. }
  6794. if (_EnterExitCosts.Service > 0)
  6795. {
  6796. //insidePayTotal += _EnterExitCosts.Service;
  6797. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6798. }
  6799. string row1_3 = "";
  6800. if (_EnterExitCosts.Safe > 0)
  6801. {
  6802. //insidePayTotal += _EnterExitCosts.Safe;
  6803. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6804. }
  6805. if (_EnterExitCosts.Ticket > 0)
  6806. {
  6807. //insidePayTotal += _EnterExitCosts.Ticket;
  6808. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6809. }
  6810. string row1 = "";
  6811. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6812. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6813. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6814. row1 += $"备注:{_EnterExitCosts.Remark}";
  6815. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6816. dic.Add("Row1Str", row1);
  6817. }
  6818. string airTotalStr = string.Empty,
  6819. airPriceStr = string.Empty;
  6820. //经济舱
  6821. if (_EnterExitCosts.SumJJC == 1)
  6822. {
  6823. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6824. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6825. }
  6826. //公务舱
  6827. if (_EnterExitCosts.SumGWC == 1)
  6828. {
  6829. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6830. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6831. }
  6832. //头等舱
  6833. if (_EnterExitCosts.SumTDC == 1)
  6834. {
  6835. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6836. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6837. }
  6838. //汇率描述
  6839. string rateStr = "";
  6840. if (peiceItemCurrencyInfos.Any())
  6841. {
  6842. rateStr = "\r\n汇率描述:";
  6843. foreach (var item in peiceItemCurrencyInfos)
  6844. {
  6845. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6846. }
  6847. }
  6848. string twoItemRemark = "备注:";
  6849. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6850. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6851. dic.Add("AirTotalStr", airTotalStr);
  6852. dic.Add("AirPriceStr", airPriceStr);
  6853. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6854. dic.Add("TwoItemRemark", twoItemRemark);
  6855. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6856. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6857. int table1Row = 0,
  6858. table2Row = 0,
  6859. table3Row = 0,
  6860. table4Row = 0,
  6861. table5Row = 0;
  6862. //住宿费
  6863. if (_EnterExitCosts.ChoiceThree == 1)
  6864. {
  6865. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6866. table1Row = dac1.Count;
  6867. #region 填充word表格内容
  6868. for (int i = 0; i < dac1.Count; i++)
  6869. {
  6870. var dac = dac1[i];
  6871. if (dac == null) continue;
  6872. builder.MoveToCell(0, i, 0, 0);
  6873. builder.Write("第" + dac.Days.ToString() + "晚:");
  6874. builder.MoveToCell(0, i, 1, 0);
  6875. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6876. //builder.Write(dac.Place == null ? "" : dac.Place);
  6877. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6878. builder.MoveToCell(0, i, 2, 0);
  6879. builder.Write("费用标准:");
  6880. string curr = "";
  6881. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6882. if (currData != null)
  6883. {
  6884. curr = currData.Name;
  6885. }
  6886. builder.MoveToCell(0, i, 3, 0);
  6887. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6888. builder.MoveToCell(0, i, 4, 0);
  6889. builder.Write("费用小计:");
  6890. builder.MoveToCell(0, i, 5, 0);
  6891. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6892. }
  6893. #endregion
  6894. }
  6895. else dic.Add("SubZS", "0.00");
  6896. //删除多余行
  6897. while (table1.Rows.Count > table1Row)
  6898. {
  6899. table1.Rows.RemoveAt(table1Row);
  6900. }
  6901. //伙食费
  6902. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6903. if (_EnterExitCosts.ChoiceFour == 1)
  6904. {
  6905. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6906. table2Row = dac2.Count;
  6907. #region 填充word表格内容
  6908. for (int i = 0; i < dac2.Count; i++)
  6909. {
  6910. var dac = dac2[i];
  6911. if (dac == null) continue;
  6912. builder.MoveToCell(1, i, 0, 0);
  6913. builder.Write("第" + dac.Days.ToString() + "天:");
  6914. builder.MoveToCell(1, i, 1, 0);
  6915. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6916. builder.MoveToCell(1, i, 2, 0);
  6917. builder.Write("费用标准:");
  6918. string curr = "";
  6919. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6920. if (currData != null)
  6921. {
  6922. curr = currData.Name;
  6923. }
  6924. builder.MoveToCell(1, i, 3, 0);
  6925. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6926. builder.MoveToCell(1, i, 4, 0);
  6927. builder.Write("费用小计:");
  6928. builder.MoveToCell(1, i, 5, 0);
  6929. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6930. }
  6931. #endregion
  6932. }
  6933. else dic.Add("SubHS", "0.00");
  6934. //删除多余行
  6935. while (table2.Rows.Count > table2Row)
  6936. {
  6937. table2.Rows.RemoveAt(table2Row);
  6938. }
  6939. //公杂费
  6940. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6941. if (_EnterExitCosts.ChoiceFive == 1)
  6942. {
  6943. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6944. table3Row = dac3.Count;
  6945. #region 填充word表格内容
  6946. for (int i = 0; i < dac3.Count; i++)
  6947. {
  6948. var dac = dac3[i];
  6949. if (dac == null) continue;
  6950. builder.MoveToCell(2, i, 0, 0);
  6951. builder.Write("第" + dac.Days.ToString() + "天:");
  6952. builder.MoveToCell(2, i, 1, 0);
  6953. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6954. builder.MoveToCell(2, i, 2, 0);
  6955. builder.Write("费用标准:");
  6956. string curr = "";
  6957. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6958. if (currData != null)
  6959. {
  6960. curr = currData.Name;
  6961. }
  6962. builder.MoveToCell(2, i, 3, 0);
  6963. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6964. builder.MoveToCell(2, i, 4, 0);
  6965. builder.Write("费用小计:");
  6966. builder.MoveToCell(2, i, 5, 0);
  6967. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6968. }
  6969. //删除多余行
  6970. while (table3.Rows.Count > table3Row)
  6971. {
  6972. table3.Rows.RemoveAt(table3Row);
  6973. }
  6974. #endregion
  6975. }
  6976. else dic.Add("SubGZF", "0.00");
  6977. //删除多余行
  6978. while (table3.Rows.Count > table3Row)
  6979. {
  6980. table3.Rows.RemoveAt(table3Row);
  6981. }
  6982. //培训费
  6983. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6984. if (_EnterExitCosts.ChoiceSix == 1)
  6985. {
  6986. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6987. dic.Add("SubPX", pxStr);
  6988. table4Row = dac4.Count;
  6989. #region 填充word表格内容
  6990. for (int i = 0; i < dac4.Count; i++)
  6991. {
  6992. var dac = dac4[i];
  6993. if (dac == null) continue;
  6994. builder.MoveToCell(3, i, 0, 0);
  6995. builder.Write("第" + dac.Days.ToString() + "天:");
  6996. builder.MoveToCell(3, i, 1, 0);
  6997. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6998. builder.MoveToCell(3, i, 2, 0);
  6999. builder.Write("费用标准:");
  7000. string curr = "";
  7001. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7002. if (currData != null)
  7003. {
  7004. curr = currData.Name;
  7005. }
  7006. builder.MoveToCell(3, i, 3, 0);
  7007. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7008. builder.MoveToCell(3, i, 4, 0);
  7009. builder.Write("费用小计:");
  7010. builder.MoveToCell(3, i, 5, 0);
  7011. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7012. }
  7013. #endregion
  7014. }
  7015. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7016. //删除多余行
  7017. while (table4.Rows.Count > table4Row)
  7018. {
  7019. table4.Rows.RemoveAt(table4Row);
  7020. }
  7021. //其他费用
  7022. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7023. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7024. {
  7025. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7026. dic.Add("titleQi", qtStr);
  7027. table5Row = dac5.Count;
  7028. #region 填充word表格内容
  7029. for (int i = 0; i < dac5.Count; i++)
  7030. {
  7031. var dac = dac5[i];
  7032. if (dac == null) continue;
  7033. builder.MoveToCell(4, i, 0, 0);
  7034. builder.Write("第" + dac.Index.ToString() + "项:");
  7035. builder.MoveToCell(4, i, 1, 0);
  7036. builder.Write(dac.itemName);
  7037. builder.MoveToCell(4, i, 2, 0);
  7038. builder.Write("费用标准:");
  7039. builder.MoveToCell(4, i, 3, 0);
  7040. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7041. builder.MoveToCell(4, i, 4, 0);
  7042. builder.Write("费用小计:");
  7043. builder.MoveToCell(4, i, 5, 0);
  7044. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7045. builder.MoveToCell(4, i, 6, 0);
  7046. builder.Write("备注:");
  7047. builder.MoveToCell(4, i, 7, 0);
  7048. builder.Write(dac.Remark);
  7049. }
  7050. #endregion
  7051. }
  7052. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7053. //删除多余行
  7054. while (table5.Rows.Count > table5Row)
  7055. {
  7056. table5.Rows.RemoveAt(table5Row);
  7057. }
  7058. //加上其他费用
  7059. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7060. decimal subJJC = 0.00M,
  7061. subGWC = 0.00M,
  7062. subTDC = 0.00M;
  7063. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7064. string totalLabel = string.Format("全部费用总计:");
  7065. //经济舱
  7066. if (_EnterExitCosts.SumJJC == 1)
  7067. {
  7068. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7069. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7070. }
  7071. //公务舱
  7072. if (_EnterExitCosts.SumGWC == 1)
  7073. {
  7074. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7075. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7076. }
  7077. //头等舱
  7078. if (_EnterExitCosts.SumTDC == 1)
  7079. {
  7080. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7081. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7082. }
  7083. //TotalLabel
  7084. dic.Add("TotalLabel", totalLabel);
  7085. #region 填充word模板书签内容
  7086. foreach (var key in dic.Keys)
  7087. {
  7088. Bookmark bookmark = doc.Range.Bookmarks[key];
  7089. if (bookmark != null)
  7090. {
  7091. builder.MoveToBookmark(key);
  7092. builder.Write(dic[key]);
  7093. }
  7094. }
  7095. #endregion
  7096. //文件名
  7097. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7098. strFileName = CommonFun.ValidFileName(strFileName);
  7099. AsposeHelper.removewatermark_v2180();
  7100. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7101. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7102. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7103. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7104. }
  7105. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7106. {
  7107. //获取模板
  7108. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7109. //载入模板
  7110. Document doc = new Document(tempPath);
  7111. DocumentBuilder builder = new DocumentBuilder(doc);
  7112. Dictionary<string, string> dic = new Dictionary<string, string>();
  7113. string returnCodeLabel = string.Empty;
  7114. if (nationalTravelFeeData.Any())
  7115. {
  7116. List<string> list = new List<string>();
  7117. foreach (var item in nationalTravelFeeData)
  7118. {
  7119. list.Add($"{item.Country}({item.City})");
  7120. }
  7121. list = list.Distinct().ToList();
  7122. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7123. }
  7124. var countryLabel = string.Empty;
  7125. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7126. if (countryData.Any())
  7127. {
  7128. countryLabel = string.Join("、", countryData);
  7129. }
  7130. dic.Add("ReturnCodeAir", returnCodeLabel);
  7131. dic.Add("VisitStartDate", "-");
  7132. dic.Add("VisitEndDate", "-");
  7133. dic.Add("Day", "-");
  7134. dic.Add("VisitCountry", countryLabel);
  7135. dic.Add("ClientUnit", "-");
  7136. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7137. //dic.Add("Names", Names);
  7138. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7139. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7140. decimal dac1totalPrice = 0.00M;
  7141. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7142. foreach (var dac in dac1)
  7143. {
  7144. if (dac.SubTotal == 0.00M)
  7145. {
  7146. continue;
  7147. }
  7148. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7149. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7150. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7151. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7152. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7153. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7154. builder.Write(currency);//币种
  7155. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7156. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7157. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7158. builder.Write("");//人数
  7159. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7160. builder.Write("");//天数
  7161. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7162. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7163. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7164. decimal rate = 0.00M;
  7165. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7166. builder.Write(rate.ToString("#0.0000"));//汇率
  7167. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7168. decimal rbmPrice = dac.SubTotal;
  7169. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7170. accommodationStartIndex++;
  7171. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7172. }
  7173. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7174. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7175. {
  7176. table1.Rows.RemoveAt(i - 1);
  7177. foodandotherStartIndex--;
  7178. }
  7179. if (dac2.Count == dac3.Count)//国家 币种 金额
  7180. {
  7181. for (int i = 0; i < dac2.Count; i++)
  7182. {
  7183. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7184. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7185. }
  7186. }
  7187. decimal dac2totalPrice = 0.00M;
  7188. foreach (var dac in dac2)
  7189. {
  7190. if (dac.SubTotal == 0)
  7191. {
  7192. continue;
  7193. }
  7194. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7195. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7196. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7197. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7198. builder.Write(currency);//币种
  7199. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7200. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7201. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7202. builder.Write("");//人数
  7203. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7204. builder.Write("");//天数
  7205. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7206. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7207. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7208. decimal rate = 0.00M;
  7209. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7210. builder.Write(rate.ToString("#0.0000"));//汇率
  7211. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7212. decimal rbmPrice = dac.SubTotal;
  7213. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7214. foodandotherStartIndex++;
  7215. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7216. }
  7217. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7218. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7219. {
  7220. table1.Rows.RemoveAt(i - 1);
  7221. }
  7222. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7223. string otherFeeStr = "";
  7224. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7225. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7226. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7227. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7228. foreach (var otherInfo in dac5)
  7229. {
  7230. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7231. }
  7232. #endregion
  7233. if (otherFeeStr.Length > 0)
  7234. {
  7235. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7236. otherFeeStr = $"({otherFeeStr})";
  7237. dic.Add("OtherFeeStr", otherFeeStr);
  7238. }
  7239. //总计
  7240. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7241. //国际旅费
  7242. string outsideAir = string.Empty;
  7243. string allPriceAir = string.Empty;
  7244. if (_EnterExitCosts.SumJJC == 1)
  7245. {
  7246. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7247. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7248. }
  7249. if (_EnterExitCosts.SumGWC == 1)
  7250. {
  7251. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7252. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7253. }
  7254. if (_EnterExitCosts.SumTDC == 1)
  7255. {
  7256. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7257. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7258. }
  7259. dic.Add("InTravelPrice", $"({outsideAir})");
  7260. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7261. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7262. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7263. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7264. foreach (var key in dic.Keys)
  7265. {
  7266. builder.MoveToBookmark(key);
  7267. builder.Write(dic[key]);
  7268. }
  7269. //模板文件名
  7270. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7271. strFileName = CommonFun.ValidFileName(strFileName);
  7272. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7273. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7274. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7275. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7276. }
  7277. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7278. {
  7279. //获取模板
  7280. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7281. //载入模板
  7282. WorkbookDesigner designer = new WorkbookDesigner();
  7283. designer.Workbook = new Workbook(tempPath);
  7284. Dictionary<string, string> dic = new Dictionary<string, string>();
  7285. string returnCodeLabel = string.Empty;
  7286. if (nationalTravelFeeData.Any())
  7287. {
  7288. List<string> list = new List<string>();
  7289. foreach (var item in nationalTravelFeeData)
  7290. {
  7291. list.Add($"{item.Country}({item.City})");
  7292. }
  7293. list = list.Distinct().ToList();
  7294. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7295. }
  7296. var countryLabel = string.Empty;
  7297. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7298. if (countryData.Any())
  7299. {
  7300. countryLabel = string.Join("、", countryData);
  7301. }
  7302. dic.Add("ReturnCodeAir", returnCodeLabel);
  7303. dic.Add("VisitStartDate", "-");
  7304. dic.Add("VisitEndDate", "-");
  7305. dic.Add("Day", "0");
  7306. dic.Add("VisitCountry", countryLabel);
  7307. dic.Add("ClientUnit", "-");
  7308. designer.SetDataSource("ClientUnit", "-");
  7309. designer.SetDataSource("VisitCountry", countryLabel);
  7310. designer.SetDataSource("Group", "-");
  7311. designer.SetDataSource("ClientUnitTitle", "-");
  7312. designer.SetDataSource("Name", "-");
  7313. designer.SetDataSource("VisitStartDate", "-");
  7314. designer.SetDataSource("Day", "0");
  7315. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7316. designer.SetDataSource("ReturnCodeAir", "-");
  7317. int startIndex = 10;
  7318. const int startIndexcopy = 10;
  7319. if (dac2.Count == dac3.Count)//国家 币种 金额
  7320. {
  7321. for (int i = 0; i < dac2.Count; i++)
  7322. {
  7323. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7324. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7325. }
  7326. }
  7327. DataTable dtdac1 = new DataTable();
  7328. List<string> place = new List<string>();
  7329. dtdac1.Columns.AddRange(new DataColumn[] {
  7330. new DataColumn(){ ColumnName = "city"},
  7331. new DataColumn(){ ColumnName = "curr"},
  7332. new DataColumn(){ ColumnName = "criterion"},
  7333. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7334. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7335. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7336. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7337. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7338. });
  7339. DataTable dtdac2 = new DataTable();
  7340. dtdac2.Columns.AddRange(new DataColumn[] {
  7341. new DataColumn(){ ColumnName = "city"},
  7342. new DataColumn(){ ColumnName = "curr"},
  7343. new DataColumn(){ ColumnName = "criterion"},
  7344. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7345. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7346. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7347. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7348. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7349. });
  7350. dtdac1.TableName = "tb1";
  7351. dtdac2.TableName = "tb2";
  7352. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7353. foreach (var item in dac1)
  7354. {
  7355. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7356. if (place.Contains(item.Place))
  7357. {
  7358. continue;
  7359. }
  7360. DataRow row = dtdac1.NewRow();
  7361. row["city"] = item.Place;
  7362. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7363. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7364. row["curr"] = currency;
  7365. row["rate"] = rate.ToString("#0.0000");
  7366. row["criterion"] = item.Cost.ToString("#0.00");
  7367. row["number"] = 1;
  7368. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7369. //row["costRMB"] = rbmPrice;
  7370. dtdac1.Rows.Add(row);
  7371. place.Add(item.Place);
  7372. }
  7373. place = new List<string>();
  7374. foreach (var item in dac2)
  7375. {
  7376. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7377. if (place.Contains(item.Place))
  7378. {
  7379. continue;
  7380. }
  7381. DataRow row = dtdac2.NewRow();
  7382. row["city"] = item.Place;
  7383. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7384. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7385. row["curr"] = currency;
  7386. row["rate"] = rate.ToString("#0.0000");
  7387. row["criterion"] = item.Cost.ToString("#0.00");
  7388. row["number"] = 1;
  7389. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7390. //row["cost"] = item.SubTotal;
  7391. //row["costRMB"] = rbmPrice;
  7392. dtdac2.Rows.Add(row);
  7393. place.Add(item.Place);
  7394. //dac2totalPrice += rbmPrice;
  7395. }
  7396. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7397. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7398. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7399. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7400. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7401. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7402. string cell4Str1 = string.Empty;
  7403. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7404. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7405. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7406. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7407. string cellStr = $" 5.其他费用(";
  7408. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7409. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7410. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7411. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7412. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7413. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7414. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7415. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7416. foreach (var otherInfo in dac5)
  7417. {
  7418. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7419. }
  7420. #endregion
  7421. if (cellStr.Length > 8)
  7422. {
  7423. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7424. }
  7425. cellStr += ")";
  7426. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7427. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7428. decimal pxFee = dac4.Sum(it => it.Cost);
  7429. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7430. string celllastStr1 = "";
  7431. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7432. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7433. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7434. celllastStr1 += $",国际旅费 元";
  7435. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7436. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7437. designer.SetDataSource("cell4Str", cell4Str);
  7438. designer.SetDataSource("cellStr", cellStr);
  7439. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7440. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7441. designer.SetDataSource("celllastStr", celllastStr);
  7442. Workbook wb = designer.Workbook;
  7443. var sheet = wb.Worksheets[0];
  7444. //绑定datatable数据集
  7445. designer.SetDataSource(dtdac1);
  7446. designer.SetDataSource(dtdac2);
  7447. designer.Process();
  7448. var rowStart = dtdac1.Rows.Count;
  7449. while (rowStart > 0)
  7450. {
  7451. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7452. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7453. startIndex++;
  7454. rowStart--;
  7455. }
  7456. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7457. startIndex += 1; //总计行
  7458. rowStart = dtdac2.Rows.Count;
  7459. while (rowStart > 0)
  7460. {
  7461. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7462. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7463. startIndex++;
  7464. rowStart--;
  7465. }
  7466. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7467. wb.CalculateFormula(true);
  7468. //模板文件名
  7469. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7470. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7471. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7472. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7473. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7474. }
  7475. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7476. {
  7477. //获取模板
  7478. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7479. //载入模板
  7480. Document doc = new Document(tempPath);
  7481. DocumentBuilder builder = new DocumentBuilder(doc);
  7482. Dictionary<string, string> dic = new Dictionary<string, string>();
  7483. dic.Add("GroupName", "-");
  7484. dic.Add("ClientUnit", "-");
  7485. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7486. //string missionLeaderJob = "";//负责人job
  7487. //int groupNumber = 0; //团人数
  7488. dic.Add("MissionLeader", "-"); //团负责人
  7489. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7490. dic.Add("GroupNumber", "0"); //团人数
  7491. dic.Add("Day", "0");
  7492. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7493. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7494. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7495. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7496. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7497. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7498. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7499. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7500. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7501. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7502. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7503. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7504. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7505. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7506. //其他费用
  7507. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7508. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7509. //其他费用合计
  7510. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7511. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7512. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7513. //公务舱合计
  7514. //国际旅费
  7515. //string outsideJJ = "";
  7516. //string allPriceJJ = "";
  7517. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7518. {
  7519. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7520. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7521. }
  7522. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7523. {
  7524. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7525. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7526. }
  7527. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7528. {
  7529. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7530. dic.Add("AirFeeTotal", airFeeTotalStr);
  7531. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7532. dic.Add("FeeTotal", feeTotalStr);
  7533. }
  7534. foreach (var key in dic.Keys)
  7535. {
  7536. builder.MoveToBookmark(key);
  7537. builder.Write(dic[key]);
  7538. }
  7539. //模板文件名
  7540. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7541. strFileName = CommonFun.ValidFileName(strFileName);
  7542. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7543. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7544. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7545. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7546. }
  7547. }
  7548. else if (dto.ExportType == 2) //表格
  7549. {
  7550. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7551. }
  7552. else if (dto.ExportType == 3)
  7553. {
  7554. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7555. }
  7556. return Ok(JsonView(400, "只可导出明细表!", ""));
  7557. }
  7558. catch (Exception ex)
  7559. {
  7560. return Ok(JsonView(400, ex.Message, ""));
  7561. }
  7562. }
  7563. /// <summary>
  7564. /// 获取三公费用标准city
  7565. /// </summary>
  7566. /// <param name="placeData"></param>
  7567. /// <param name="nationalTravelFeeId"></param>
  7568. /// <returns></returns>
  7569. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7570. {
  7571. string _city = string.Empty;
  7572. if (!placeData.Any()) return _city;
  7573. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7574. if (data == null) return _city;
  7575. string country = data.Country;
  7576. string city = data.City;
  7577. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7578. else _city = city;
  7579. return _city;
  7580. }
  7581. /// <summary>
  7582. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7583. /// </summary>
  7584. /// <returns></returns>
  7585. [HttpPost]
  7586. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7588. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7589. {
  7590. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7591. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7592. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7593. if (_view.Code == 0)
  7594. {
  7595. return Ok(JsonView(true, "操作成功"));
  7596. }
  7597. return Ok(JsonView(false, "操作失败"));
  7598. }
  7599. /// <summary>
  7600. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7601. /// </summary>
  7602. /// <returns></returns>
  7603. [HttpPost]
  7604. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7606. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7607. {
  7608. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7609. if (data.Code != 0)
  7610. {
  7611. return Ok(JsonView(false, data.Msg));
  7612. }
  7613. return Ok(JsonView(true, "操作成功!", data.Data));
  7614. }
  7615. /// <summary>
  7616. /// 三公其他费用草稿 删除
  7617. /// </summary>
  7618. /// <param name="dto"></param>
  7619. /// <returns></returns>
  7620. [HttpPost]
  7621. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7622. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7623. {
  7624. var jw = JsonView(false, "删除失败!");
  7625. var data = new Grp_DayOtherPriceDraft()
  7626. {
  7627. Id = dto.Id,
  7628. IsDel = 1,
  7629. DeleteUserId = dto.DeleteUserId,
  7630. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7631. };
  7632. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7633. if (del > 0)
  7634. {
  7635. jw.Code = 200;
  7636. jw.Msg = "删除成功!";
  7637. }
  7638. return Ok(jw);
  7639. }
  7640. /// <summary>
  7641. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7642. /// </summary>
  7643. /// <returns></returns>
  7644. [HttpPost]
  7645. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7646. {
  7647. var jw = JsonView(false);
  7648. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7649. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7650. jw.Code = StatusCodes.Status200OK;
  7651. jw.Msg = "操作成功!";
  7652. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7653. return Ok(jw);
  7654. }
  7655. /// <summary>
  7656. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7657. /// </summary>
  7658. /// <param name="dto"></param>
  7659. /// <returns></returns>
  7660. [HttpPost]
  7661. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7662. {
  7663. int userId = dto.UserId,
  7664. portId = dto.PortType,
  7665. groupId = dto.GroupId,
  7666. draftId = dto.DraftId;
  7667. _portTypeData.Add(1);
  7668. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7669. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7670. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7671. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7672. _sqlSugar.BeginTran();
  7673. try
  7674. {
  7675. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7676. if (draftDatas == null)
  7677. {
  7678. _sqlSugar.RollbackTran();
  7679. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7680. }
  7681. //验证可覆盖已有数据 两边创建人需为同一人;
  7682. int draftCreateUserId = draftDatas.CreateUserId,
  7683. formalCreateUserId = 0;
  7684. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7685. if (formalData != null)
  7686. {
  7687. formalCreateUserId = formalData.CreateUserId;
  7688. if (draftCreateUserId != formalCreateUserId)
  7689. {
  7690. _sqlSugar.RollbackTran();
  7691. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7692. }
  7693. }
  7694. //默认添加查看、编辑权限(创建人、自己)
  7695. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7696. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7697. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7698. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7699. newExterData.DiId = groupId;
  7700. newExterData.CreateUserId = userId;
  7701. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7702. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7703. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7704. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7705. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7706. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7707. //数据如果存在执行删除
  7708. if (enterExitCostInfo != null)
  7709. {
  7710. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7711. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7712. .Where(x => x.Id == enterExitCostInfo.Id)
  7713. .ExecuteCommand();
  7714. _sqlSugar.Updateable<Grp_DayAndCost>()
  7715. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7716. .Where(x => x.DiId == groupId)
  7717. .ExecuteCommand();
  7718. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7719. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7720. .Where(x => x.Diid == groupId)
  7721. .ExecuteCommand();
  7722. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7723. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7724. .Where(x => x.GroupId == groupId)
  7725. .ExecuteCommand();
  7726. }
  7727. //执行insert
  7728. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7729. if (insertId < 1)
  7730. {
  7731. _sqlSugar.RollbackTran();
  7732. return Ok(JsonView(false, "草稿数据导入失败!"));
  7733. }
  7734. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7735. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7736. #region 默认添加权限
  7737. #endregion
  7738. _sqlSugar.CommitTran();
  7739. //执行操作之后
  7740. //生成默认文件pdf并且通知人员
  7741. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7742. {
  7743. DiId = groupId,
  7744. ExportType = 1,
  7745. SubTypeId = 1005
  7746. }, "pdf");
  7747. //发送通知
  7748. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7749. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7750. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7751. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7752. //汇率信息记录
  7753. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7754. return Ok(JsonView(true));
  7755. }
  7756. catch (Exception ex)
  7757. {
  7758. _sqlSugar.RollbackTran();
  7759. return Ok(JsonView(false, ex.Message));
  7760. }
  7761. }
  7762. #endregion
  7763. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7764. /// <summary>
  7765. /// 获取币种基础数据(含逻辑处理)
  7766. /// </summary>
  7767. /// <returns></returns>
  7768. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7769. {
  7770. //默认币种显示
  7771. var _currencyInfos = _currencyInit;
  7772. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7773. if (_currencyRate.Count > 0)
  7774. {
  7775. foreach (var item in _currencyInfos)
  7776. {
  7777. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7778. if (rateInfo != null)
  7779. {
  7780. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7781. rate1 *= 1.035M;
  7782. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7783. }
  7784. }
  7785. }
  7786. return _currencyInfos;
  7787. }
  7788. /// <summary>
  7789. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7790. /// </summary>
  7791. /// <returns></returns>
  7792. [HttpPost]
  7793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7794. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7795. {
  7796. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7797. //SetDataInfoView
  7798. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7799. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7800. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7801. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7802. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7803. //默认币种显示
  7804. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7805. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7806. return Ok(JsonView(true, "查询成功!", new
  7807. {
  7808. WordTypeData = _WordTypeData,
  7809. ExcelTypeData = _ExcelTypeData,
  7810. CurrencyInit = _currencyInfos,
  7811. viewPermissionData = viewPermissionData
  7812. }));
  7813. }
  7814. /// <summary>
  7815. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7816. /// </summary>
  7817. /// <returns></returns>
  7818. [HttpPost]
  7819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7820. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7821. {
  7822. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7823. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7824. RefAsync<int> total = 0;
  7825. int diId = 0;
  7826. var status = int.TryParse(dto.GroupName, out diId);
  7827. string sql = string.Format(@"SELECT
  7828. Id,
  7829. TeamName GroupName,
  7830. CASE WHEN EXISTS (
  7831. SELECT
  7832. 1
  7833. FROM
  7834. Grp_EnterExitCost
  7835. WHERE
  7836. IsDel = 0
  7837. AND DiId = di.Id
  7838. ) THEN 1 ELSE 0 END AS [IsNull],
  7839. CASE WHEN EXISTS(
  7840. SELECT
  7841. TOP 1 *
  7842. FROM
  7843. Grp_EnterExitCost
  7844. WHERE
  7845. IsDel = 0
  7846. AND DiId = di.Id
  7847. AND CreateUserId = {0}
  7848. ORDER BY
  7849. CreateTime DESC
  7850. ) THEN 1 ELSE 0 END AS [IsEdit],
  7851. CASE WHEN EXISTS(
  7852. SELECT
  7853. TOP 1 *
  7854. FROM
  7855. Grp_EnterExitCost
  7856. WHERE
  7857. IsDel = 0
  7858. AND DiId = di.Id
  7859. AND CreateUserId = {0}
  7860. ORDER BY
  7861. CreateTime DESC
  7862. ) THEN 1 WHEN EXISTS(
  7863. SELECT
  7864. TOP 1 *
  7865. FROM
  7866. Grp_EnterExitCostPermission
  7867. WHERE
  7868. IsDel = 0
  7869. AND GroupId = di.Id
  7870. AND Permission = 1
  7871. AND UserId = {0}
  7872. ORDER BY
  7873. CreateTime DESC
  7874. ) THEN 1 ELSE 0 END AS [IsView]
  7875. FROM
  7876. Grp_DelegationInfo di
  7877. WHERE
  7878. di.Isdel = 0 ", dto.CurrUserId);
  7879. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7880. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7881. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7882. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7883. .OrderByDescending(x => x.Id)
  7884. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7885. return Ok(JsonView(true, "查询成功!", data, total));
  7886. }
  7887. /// <summary>
  7888. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7889. /// </summary>
  7890. /// <returns></returns>
  7891. [HttpPost]
  7892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7893. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7894. {
  7895. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7896. RefAsync<int> total = 0;
  7897. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7898. .Where(x => x.IsDel == 0 && x.STid == 66)
  7899. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7900. .Select(x => new
  7901. {
  7902. id = x.Id,
  7903. name = x.Name,
  7904. remark = x.Remark,
  7905. })
  7906. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7907. return Ok(JsonView(true, "查询成功!", data, total));
  7908. }
  7909. /// <summary>
  7910. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7911. /// </summary>
  7912. /// <returns></returns>
  7913. [HttpPost]
  7914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7915. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7916. {
  7917. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7918. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7919. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7920. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7921. var groupOtherRateData = groupRateData.TeamRates;
  7922. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7923. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7924. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7925. groupOtherRateData = groupOtherRateData
  7926. .Select(x => new TeamRateDescAddCurrencyIdView
  7927. {
  7928. CurrencyId = x.CurrencyId,
  7929. CurrencyName = x.CurrencyName,
  7930. CurrencyCode = x.CurrencyCode,
  7931. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7932. }).ToList();
  7933. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7934. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7935. }
  7936. /// <summary>
  7937. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7938. /// </summary>
  7939. /// <returns></returns>
  7940. [HttpPost]
  7941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7942. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7943. {
  7944. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7945. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7946. var tipsData = new List<int>() { 1, 2, 3 };
  7947. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7948. if (dto.TipsType == 1)
  7949. {
  7950. //默认币种显示
  7951. var _currencyInfos = _currencyInit;
  7952. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  7953. List<dynamic> reteInfos = new List<dynamic>();
  7954. if (_currencyRate.Count > 0)
  7955. {
  7956. foreach (var item in _currencyInfos)
  7957. {
  7958. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7959. if (rateInfo != null)
  7960. {
  7961. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7962. decimal rate1 = item.Rate;
  7963. rate1 *= 1.03M;
  7964. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7965. reteInfos.Add(new
  7966. {
  7967. currCode = item.CurrencyCode,
  7968. currName = item.CurrencyName,
  7969. rate = rate2,
  7970. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7971. });
  7972. }
  7973. }
  7974. }
  7975. return Ok(JsonView(true, "查询成功!", reteInfos));
  7976. }
  7977. else if (dto.TipsType == 2)
  7978. {
  7979. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7980. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7981. }
  7982. else if (dto.TipsType == 3)
  7983. {
  7984. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7985. return Ok(JsonView(true, "查询成功!", airData.Data));
  7986. }
  7987. return Ok(JsonView(false));
  7988. }
  7989. /// <summary>
  7990. /// 团组模块 - 出入境国家费用标准-移动端 List
  7991. /// </summary>
  7992. /// <returns></returns>
  7993. [HttpPost]
  7994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7995. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7996. {
  7997. Stopwatch sw = new Stopwatch();
  7998. sw.Start();
  7999. RefAsync<int> total = 0;
  8000. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8001. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8002. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8003. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8004. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8005. .Select((ntf, sd, u) => new
  8006. {
  8007. Id = ntf.Id,
  8008. Area = $"{ntf.Country}-{ntf.City}",
  8009. Currency = ntf.Currency,
  8010. CurrencyCode = sd.Name,
  8011. CurrencyName = sd.Remark,
  8012. RoomCost = ntf.RoomCost,
  8013. FoodCost = ntf.FoodCost,
  8014. PublicCost = ntf.PublicCost,
  8015. LastUpdateUserId = ntf.LastUpdateUserId,
  8016. LastUpdateUserName = u.CnName,
  8017. LastUpdateTime = ntf.LastUpdateTime,
  8018. })
  8019. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8020. sw.Stop();
  8021. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8022. }
  8023. /// <summary>
  8024. /// 团组模块 - 出入境费用-移动端 - Info
  8025. /// </summary>
  8026. /// <returns></returns>
  8027. [HttpPost]
  8028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8029. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8030. {
  8031. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8032. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8033. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8034. return Ok(data);
  8035. }
  8036. /// <summary>
  8037. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8038. /// </summary>
  8039. /// <returns></returns>
  8040. [HttpPost]
  8041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8042. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8043. {
  8044. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8045. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8046. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8047. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8048. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8049. mobileInfo.DiId = dto.DiId;
  8050. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8051. if (eecInfo == null) return Ok(mobileInfo);
  8052. //验证查看权限
  8053. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8054. //if (!isView) return Ok(JsonView(false, msg));
  8055. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8056. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8057. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8058. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8059. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8060. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8061. {
  8062. SubId = dac.Id,
  8063. DiId = dac.DiId,
  8064. Type = dac.Type,
  8065. Days = dac.Days,
  8066. NationalTravelFeeId = dac.NationalTravelFeeId,
  8067. Arae = $"{ntf.Country}-{ntf.City}",
  8068. Cost = dac.Cost,
  8069. Currency = dac.Currency,
  8070. CurrencyName = sd.Name,
  8071. SubTotal = dac.SubTotal,
  8072. })
  8073. .ToList();
  8074. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8075. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8076. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8077. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8078. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8079. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8080. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8081. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8082. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8083. //其他款项
  8084. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8085. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8086. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8087. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8088. .OrderBy((dop, sd1, sd2) => dop.Index)
  8089. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8090. {
  8091. SubId = dop.Id,
  8092. DiId = dop.Diid,
  8093. Index = dop.Index,
  8094. SetDataId = dop.SetDataId,
  8095. SetDataName = sd1.Name,
  8096. Cost = dop.Cost,
  8097. Currency = dop.Currency,
  8098. CurrencyName = sd2.Remark,
  8099. SubTotal = dop.SubTotal,
  8100. Remark = dop.Remark,
  8101. })
  8102. .ToArray();
  8103. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8104. return Ok(mobileInfo);
  8105. }
  8106. /// <summary>
  8107. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8108. /// </summary>
  8109. /// <returns></returns>
  8110. [HttpPost]
  8111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8112. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8113. {
  8114. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8115. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8116. //验证查看权限
  8117. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8118. if (!isView) return Ok(JsonView(false, msg));
  8119. var userIds = Array.Empty<int>();
  8120. userIds = await _sqlSugar
  8121. .Queryable<Grp_EnterExitCostPermission>()
  8122. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8123. .Select(x => x.UserId)
  8124. .ToArrayAsync();
  8125. return Ok(userIds);
  8126. }
  8127. /// <summary>
  8128. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8129. /// </summary>
  8130. /// <returns></returns>
  8131. [HttpPost]
  8132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8133. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8134. {
  8135. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8136. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8137. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8138. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8139. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8140. //验证查看权限
  8141. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8142. //if (!isView) return Ok(JsonView(false, msg));
  8143. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8144. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8145. var subType = dto.SubType;
  8146. if (subType == 1) //1:境内费用
  8147. {
  8148. var oneData = new ChoiceOneMobileSubInfoView()
  8149. {
  8150. Id = eecInfo.Id,
  8151. ChoiceOne = eecInfo.ChoiceOne,
  8152. ChoiceOneTotalCost = eecInfo.InsidePay,
  8153. Visa = eecInfo.Visa,
  8154. VisaRemark = eecInfo.VisaRemark,
  8155. YiMiao = eecInfo.YiMiao,
  8156. HeSuan = eecInfo.HeSuan,
  8157. Service = eecInfo.Service,
  8158. Ticket = eecInfo.Ticket,
  8159. Safe = eecInfo.Safe,
  8160. FirstItemRemark = eecInfo.FirstItemRemark
  8161. };
  8162. return Ok(JsonView(oneData));
  8163. }
  8164. else if (subType == 2) //2:国际旅费
  8165. {
  8166. var twoData = new ChoiceTwoMobileSubInfoView()
  8167. {
  8168. Id = eecInfo.Id,
  8169. ChoiceTwoJJ = eecInfo.SumJJC,
  8170. OutsideJJPay = eecInfo.OutsideJJPay,
  8171. ChoiceTwoGW = eecInfo.SumGWC,
  8172. OutsideGWPay = eecInfo.OutsideGWPay,
  8173. ChoiceTwoTD = eecInfo.SumTDC,
  8174. OutsideTDPay = eecInfo.OutsideTDPay,
  8175. AirJJ = eecInfo.AirJJ,
  8176. AirGW = eecInfo.AirGW,
  8177. AirTD = eecInfo.AirTD,
  8178. CityTranffic = eecInfo.CityTranffic,
  8179. TwoItemRemark = eecInfo.TwoItemRemark
  8180. };
  8181. return Ok(JsonView(twoData));
  8182. }
  8183. else if (subType == 3) //3:住宿费
  8184. {
  8185. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8186. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8187. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8188. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8189. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8190. {
  8191. SubId = dac.Id,
  8192. DiId = dac.DiId,
  8193. Type = dac.Type,
  8194. Days = dac.Days,
  8195. NationalTravelFeeId = dac.NationalTravelFeeId,
  8196. Arae = $"{ntf.Country}-{ntf.City}",
  8197. Cost = dac.Cost,
  8198. Currency = dac.Currency,
  8199. CurrencyName = sd.Name,
  8200. SubTotal = dac.SubTotal,
  8201. })
  8202. .ToArray();
  8203. var data = new ChoiceMobileSubInfo3To6View()
  8204. {
  8205. ParentId = eecInfo.Id,
  8206. Choice = eecInfo.ChoiceThree,
  8207. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8208. Details = dayAndCostDatas
  8209. };
  8210. return Ok(JsonView(data));
  8211. }
  8212. else if (subType == 4) //4:伙食费
  8213. {
  8214. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8215. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8216. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8217. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8218. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8219. {
  8220. SubId = dac.Id,
  8221. DiId = dac.DiId,
  8222. Type = dac.Type,
  8223. Days = dac.Days,
  8224. NationalTravelFeeId = dac.NationalTravelFeeId,
  8225. Arae = $"{ntf.Country}-{ntf.City}",
  8226. Cost = dac.Cost,
  8227. Currency = dac.Currency,
  8228. CurrencyName = sd.Name,
  8229. SubTotal = dac.SubTotal,
  8230. })
  8231. .ToArray();
  8232. var data = new ChoiceMobileSubInfo3To6View()
  8233. {
  8234. ParentId = eecInfo.Id,
  8235. Choice = eecInfo.ChoiceFour,
  8236. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8237. Details = dayAndCostDatas
  8238. };
  8239. return Ok(JsonView(data));
  8240. }
  8241. else if (subType == 5) //5:公杂费
  8242. {
  8243. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8244. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8245. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8246. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8247. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8248. {
  8249. SubId = dac.Id,
  8250. DiId = dac.DiId,
  8251. Type = dac.Type,
  8252. Days = dac.Days,
  8253. NationalTravelFeeId = dac.NationalTravelFeeId,
  8254. Arae = $"{ntf.Country}-{ntf.City}",
  8255. Cost = dac.Cost,
  8256. Currency = dac.Currency,
  8257. CurrencyName = sd.Name,
  8258. SubTotal = dac.SubTotal,
  8259. })
  8260. .ToArray();
  8261. var data = new ChoiceMobileSubInfo3To6View()
  8262. {
  8263. ParentId = eecInfo.Id,
  8264. Choice = eecInfo.ChoiceFive,
  8265. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8266. Details = dayAndCostDatas
  8267. };
  8268. return Ok(JsonView(data));
  8269. }
  8270. else if (subType == 6) //6:培训费
  8271. {
  8272. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8273. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8274. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8275. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8276. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8277. {
  8278. SubId = dac.Id,
  8279. DiId = dac.DiId,
  8280. Type = dac.Type,
  8281. Days = dac.Days,
  8282. NationalTravelFeeId = dac.NationalTravelFeeId,
  8283. Arae = $"{ntf.Country}-{ntf.City}",
  8284. Cost = dac.Cost,
  8285. Currency = dac.Currency,
  8286. CurrencyName = sd.Name,
  8287. SubTotal = dac.SubTotal,
  8288. })
  8289. .ToArray();
  8290. var data = new ChoiceMobileSubInfo3To6View()
  8291. {
  8292. ParentId = eecInfo.Id,
  8293. Choice = eecInfo.ChoiceSix,
  8294. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8295. Details = dayAndCostDatas
  8296. };
  8297. return Ok(JsonView(data));
  8298. }
  8299. else if (subType == 7) //7:其他
  8300. {
  8301. //其他款项
  8302. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8303. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8304. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8305. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8306. .OrderBy((dop, sd1, sd2) => dop.Index)
  8307. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8308. {
  8309. SubId = dop.Id,
  8310. DiId = dop.Diid,
  8311. Index = dop.Index,
  8312. SetDataId = dop.SetDataId,
  8313. SetDataName = sd1.Name,
  8314. Cost = dop.Cost,
  8315. Currency = dop.Currency,
  8316. CurrencyName = sd2.Name,
  8317. SubTotal = dop.SubTotal,
  8318. Remark = dop.Remark,
  8319. })
  8320. .ToArray();
  8321. var data = new ChoiceSevenMobileSubInfoView()
  8322. {
  8323. ParentId = eecInfo.Id,
  8324. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8325. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8326. Details = otherData
  8327. };
  8328. return Ok(JsonView(data));
  8329. }
  8330. return Ok(JsonView(false));
  8331. }
  8332. #region op
  8333. /// <summary>
  8334. /// 移动端更新费用消息通知
  8335. /// </summary>
  8336. /// <param name="diid"></param>
  8337. /// <param name="id"></param>
  8338. /// <param name="currUserId"></param>
  8339. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8340. {
  8341. try
  8342. {
  8343. ////生成默认文件pdf并且通知人员
  8344. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8345. //{
  8346. // DiId = diid,
  8347. // ExportType = 1,
  8348. // SubTypeId = 1005
  8349. //}, "pdf");
  8350. ////发送通知
  8351. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8352. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8353. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8354. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8355. ////汇率信息记录
  8356. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8357. }
  8358. catch (Exception ex)
  8359. {
  8360. //记录日志
  8361. throw;
  8362. }
  8363. }
  8364. /// <summary>
  8365. /// 验证出入境费用数据是否存在
  8366. /// 不存在添加
  8367. /// </summary>
  8368. /// <param name="diId"></param>
  8369. /// <param name="currUserId"></param>
  8370. /// <returns></returns>
  8371. /// <exception cref="CustomException"></exception>
  8372. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8373. {
  8374. var parentId = 0;
  8375. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8376. if (info != null)
  8377. {
  8378. parentId = info.Id;
  8379. }
  8380. else
  8381. {
  8382. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8383. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8384. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8385. parentId = addId;
  8386. }
  8387. return parentId;
  8388. }
  8389. /// <summary>
  8390. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8391. /// </summary>
  8392. /// <returns></returns>
  8393. [HttpPost]
  8394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8395. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8396. {
  8397. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8398. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8399. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8400. //验证编辑权限
  8401. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8402. //if (!isEdit) return Ok(JsonView(false, msg));
  8403. var permissions = new List<Grp_EnterExitCostPermission>();
  8404. foreach (var userId in dto.UserIds)
  8405. {
  8406. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8407. }
  8408. if (permissions.Any())
  8409. {
  8410. _sqlSugar.BeginTran();
  8411. try
  8412. {
  8413. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8414. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8415. if (result < 1)
  8416. {
  8417. _sqlSugar.RollbackTran();
  8418. return Ok(JsonView(false));
  8419. }
  8420. }
  8421. catch (Exception ex)
  8422. {
  8423. _sqlSugar.RollbackTran();
  8424. return Ok(JsonView(false, ex.Message));
  8425. }
  8426. _sqlSugar.CommitTran();
  8427. return Ok(JsonView(true));
  8428. }
  8429. return Ok(JsonView(false));
  8430. }
  8431. /// <summary>
  8432. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8433. /// </summary>
  8434. /// <returns></returns>
  8435. [HttpPost]
  8436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8437. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8438. {
  8439. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8440. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8441. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8442. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8443. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8444. int id = dto.Id;
  8445. if (id <= 0) //add
  8446. {
  8447. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8448. if (add < 1) return Ok(JsonView(false));
  8449. id = add;
  8450. }
  8451. else //update
  8452. {
  8453. ////验证编辑权限
  8454. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8455. //if (!isEdit) return Ok(JsonView(false, msg));
  8456. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8457. if (upd < 1) return Ok(JsonView(false));
  8458. }
  8459. #region 汇率变更时更改币种相关费用
  8460. var opDayCosts = new List<Grp_DayAndCost>();
  8461. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8462. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8463. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8464. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8465. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8466. .Select((dac, sd) => new
  8467. {
  8468. dac.Id,
  8469. dac.DiId,
  8470. CurrencyCode = sd.Name,
  8471. dac.Cost
  8472. })
  8473. .ToList();
  8474. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8475. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8476. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8477. .Select((dop, sd) => new
  8478. {
  8479. dop.Id,
  8480. dop.Diid,
  8481. CurrencyCode = sd.Name,
  8482. dop.Cost
  8483. })
  8484. .ToList();
  8485. if (dayCosts.Count > 0)
  8486. {
  8487. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8488. foreach (var dc in new_dayCosts)
  8489. {
  8490. var thisCurrency = dc.Key.ToUpper();
  8491. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8492. if (thisRate == 0.00M) continue;
  8493. foreach (var dcSub in dc)
  8494. {
  8495. opDayCosts.Add(new Grp_DayAndCost()
  8496. {
  8497. Id = dcSub.Id,
  8498. DiId = dcSub.DiId,
  8499. Cost = dcSub.Cost,
  8500. SubTotal = dcSub.Cost * thisRate,
  8501. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8502. });
  8503. }
  8504. }
  8505. if (opDayCosts.Count > 0)
  8506. {
  8507. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8508. }
  8509. }
  8510. if (dayOtherCosts.Count > 0)
  8511. {
  8512. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8513. foreach (var dc in new_dayOtherCosts)
  8514. {
  8515. var thisCurrency = dc.Key.ToUpper();
  8516. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8517. if (thisRate == 0.00M) continue;
  8518. foreach (var dcSub in dc)
  8519. {
  8520. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8521. {
  8522. Id = dcSub.Id,
  8523. Diid = dcSub.Diid,
  8524. Cost = dcSub.Cost,
  8525. SubTotal = dcSub.Cost * thisRate,
  8526. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8527. });
  8528. }
  8529. }
  8530. if (opDayOtherCosts.Count > 0)
  8531. {
  8532. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8533. }
  8534. }
  8535. #endregion
  8536. //消息通知
  8537. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8538. //汇率信息记录
  8539. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8540. return Ok(JsonView(new { parentId = id }));
  8541. }
  8542. /// <summary>
  8543. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8544. /// </summary>
  8545. /// <returns></returns>
  8546. [HttpPost]
  8547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8548. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8549. {
  8550. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8551. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8552. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8553. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8554. int id = dto.Id;
  8555. if (id <= 0) //add
  8556. {
  8557. checkboxInfo.CreateUserId = dto.CurrUserId;
  8558. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8559. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8560. if (add < 1) return Ok(JsonView(false));
  8561. }
  8562. else //update
  8563. {
  8564. ////验证编辑权限
  8565. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8566. //if (!isEdit) return Ok(JsonView(false, msg));
  8567. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8568. .UpdateColumns(x => new
  8569. {
  8570. x.ChoiceOne,
  8571. x.ChoiceTwo,
  8572. x.SumJJC,
  8573. x.SumGWC,
  8574. x.SumTDC,
  8575. x.ChoiceThree,
  8576. x.ChoiceFour,
  8577. x.ChoiceFive,
  8578. x.ChoiceSix,
  8579. x.OtherExpenses_Checked
  8580. })
  8581. .Where(x => x.Id == id)
  8582. .ExecuteCommandAsync();
  8583. if (upd < 1) return Ok(JsonView(false));
  8584. }
  8585. return Ok(JsonView(new { parentId = id }));
  8586. }
  8587. /// <summary>
  8588. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8589. /// </summary>
  8590. /// <returns></returns>
  8591. [HttpPost]
  8592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8593. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8594. {
  8595. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8596. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8597. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8598. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8599. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8600. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8601. var checkboxInfo = new Grp_EnterExitCost()
  8602. {
  8603. Id = id,
  8604. DiId = diId,
  8605. CreateUserId = currUserId
  8606. };
  8607. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8608. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8609. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8610. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8611. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8612. if (id <= 0) //add
  8613. {
  8614. checkboxInfo.CreateUserId = dto.CurrUserId;
  8615. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8616. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8617. if (add < 1) return Ok(JsonView(false));
  8618. }
  8619. else //update
  8620. {
  8621. ////验证编辑权限
  8622. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8623. //if (!isEdit) return Ok(JsonView(false, msg));
  8624. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8625. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8626. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8627. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8628. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8629. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8630. .Where(x => x.Id == id)
  8631. .ExecuteCommandAsync();
  8632. if (upd < 1) return Ok(JsonView(false));
  8633. }
  8634. return Ok(JsonView(new { parentId = id }));
  8635. }
  8636. /// <summary>
  8637. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8638. /// </summary>
  8639. /// <returns></returns>
  8640. [HttpPost]
  8641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8642. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8643. {
  8644. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8645. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8646. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8647. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8648. info.FirstItemRemark = dto.FirstItemRemark;
  8649. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8650. int id = dto.Id;
  8651. if (id <= 0) //add
  8652. {
  8653. info.CreateUserId = dto.CurrUserId;
  8654. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8655. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8656. if (add < 1) return Ok(JsonView(false));
  8657. id = add;
  8658. }
  8659. else //update
  8660. {
  8661. ////验证编辑权限
  8662. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8663. //if (!isEdit) return Ok(JsonView(false, msg));
  8664. var upd = await _sqlSugar.Updateable(info)
  8665. .UpdateColumns(x => new
  8666. {
  8667. x.ChoiceOne,
  8668. x.InsidePay,
  8669. x.VisaRemark,
  8670. x.Visa,
  8671. x.Service,
  8672. x.Safe,
  8673. x.Ticket,
  8674. x.HeSuan,
  8675. x.YiMiao,
  8676. x.FirstItemRemark
  8677. })
  8678. .Where(x => x.Id == id)
  8679. .ExecuteCommandAsync();
  8680. if (upd < 1) return Ok(JsonView(false));
  8681. }
  8682. //消息通知
  8683. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8684. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8685. }
  8686. /// <summary>
  8687. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8688. /// </summary>
  8689. /// <returns></returns>
  8690. [HttpPost]
  8691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8692. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8693. {
  8694. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8695. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8696. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8697. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8698. info.OutsideJJPay = dto.OutsideJJPay;
  8699. info.OutsideGWPay = dto.OutsideGWPay;
  8700. info.OutsideTDPay = dto.OutsideTDPay;
  8701. info.AirJJ = dto.AirJJ;
  8702. info.AirGW = dto.AirGW;
  8703. info.AirTD = dto.AirTD;
  8704. info.CityTranffic = dto.CityTranffic;
  8705. info.TwoItemRemark = dto.TwoItemRemark;
  8706. info.SumJJC = dto.ChoiceTwoJJ;
  8707. info.SumGWC = dto.ChoiceTwoGW;
  8708. info.SumTDC = dto.ChoiceTwoTD;
  8709. int id = dto.Id;
  8710. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8711. if (id <= 0) //add
  8712. {
  8713. info.CreateUserId = dto.CurrUserId;
  8714. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8715. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8716. if (addId <= 0) return Ok(JsonView(false));
  8717. id = addId;
  8718. }
  8719. else //update
  8720. {
  8721. ////验证编辑权限
  8722. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8723. //if (!isEdit) return Ok(JsonView(false, msg));
  8724. var upd = await _sqlSugar.Updateable(info)
  8725. .UpdateColumns(x => new
  8726. {
  8727. x.SumJJC,
  8728. x.OutsideJJPay,
  8729. x.SumGWC,
  8730. x.OutsideGWPay,
  8731. x.SumTDC,
  8732. x.OutsideTDPay,
  8733. x.AirJJ,
  8734. x.AirGW,
  8735. x.AirTD,
  8736. x.CityTranffic,
  8737. x.TwoItemRemark
  8738. })
  8739. .Where(x => x.Id == id)
  8740. .ExecuteCommandAsync();
  8741. if (upd < 1) return Ok(JsonView(false));
  8742. }
  8743. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8744. gwcItemTotal = info.AirGW + info.CityTranffic;
  8745. tdcItemTotal = info.AirTD + info.CityTranffic;
  8746. //消息通知
  8747. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8748. return Ok(JsonView(new
  8749. {
  8750. parentId = id,
  8751. choiceTwoJJ = dto.ChoiceTwoJJ,
  8752. jjcItemTotal = jjcItemTotal,
  8753. choiceTwoGW = dto.ChoiceTwoGW,
  8754. gwcItemTotal = gwcItemTotal,
  8755. choiceTwoTD = dto.ChoiceTwoTD,
  8756. tdcItemTotal = tdcItemTotal
  8757. }));
  8758. }
  8759. /// <summary>
  8760. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8761. /// </summary>
  8762. /// <returns></returns>
  8763. [HttpPost]
  8764. [ApiExplorerSettings(IgnoreApi = true)]
  8765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8766. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8767. {
  8768. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8769. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8770. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8771. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8772. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8773. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8774. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8775. var infos = infos1.Select(x => new Grp_DayAndCost
  8776. {
  8777. Id = x.Id,
  8778. DiId = dto.DiId,
  8779. Type = dto.FeeType,
  8780. Days = x.Days,
  8781. NationalTravelFeeId = x.NationalTravelFeeId,
  8782. Cost = x.Cost,
  8783. Currency = x.Currency,
  8784. SubTotal = x.SubTotal,
  8785. CreateUserId = dto.CurrUserId
  8786. })
  8787. .ToList();
  8788. var adds = infos.Where(x => x.Id <= 0).ToList();
  8789. var upds = infos.Where(x => x.Id > 0).ToList();
  8790. if (adds.Count > 0)
  8791. {
  8792. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8793. if (add < 1) return Ok(JsonView(false));
  8794. }
  8795. if (upds.Count > 0)
  8796. {
  8797. var upd = await _sqlSugar.Updateable(adds)
  8798. .UpdateColumns(x => new
  8799. {
  8800. x.Days,
  8801. x.NationalTravelFeeId,
  8802. x.Cost,
  8803. x.Currency,
  8804. x.SubTotal
  8805. })
  8806. .WhereColumns(x => new { x.Id })
  8807. .ExecuteCommandAsync();
  8808. if (upd < 1) return Ok(JsonView(false));
  8809. }
  8810. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8811. //消息通知
  8812. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8813. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8814. return Ok(JsonView(new { itemTotal = itemTotal }));
  8815. }
  8816. /// <summary>
  8817. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8818. /// </summary>
  8819. /// <returns></returns>
  8820. [HttpPost]
  8821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8822. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8823. {
  8824. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8825. int subId = dto.SubId, feeType = dto.FeeType;
  8826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8827. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8828. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8829. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8830. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8831. subInfo.Id = subId;
  8832. subInfo.DiId = dto.DiId;
  8833. if (feeType == 3) subInfo.Type = 1;
  8834. else if (feeType == 4) subInfo.Type = 2;
  8835. else if (feeType == 5) subInfo.Type = 3;
  8836. else if (feeType == 6) subInfo.Type = 4;
  8837. subInfo.CreateUserId = dto.CurrUserId;
  8838. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8839. if (parentId < 1) return Ok(JsonView(false));
  8840. //子表op
  8841. if (subId < 1)
  8842. {
  8843. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8844. if (subAdd < 1) return Ok(JsonView(false));
  8845. }
  8846. else
  8847. {
  8848. ////验证编辑权限
  8849. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8850. //if (!isEdit) return Ok(JsonView(false, msg));
  8851. var subUpd = await _sqlSugar.Updateable(subInfo)
  8852. .UpdateColumns(x => new
  8853. {
  8854. x.Days,
  8855. x.NationalTravelFeeId,
  8856. x.Cost,
  8857. x.Currency,
  8858. x.SubTotal
  8859. })
  8860. .WhereColumns(x => new { x.Id })
  8861. .ExecuteCommandAsync();
  8862. if (subUpd < 1) return Ok(JsonView(false));
  8863. }
  8864. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8865. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8866. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8867. }
  8868. /// <summary>
  8869. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8870. /// </summary>
  8871. /// <returns></returns>
  8872. [HttpPost]
  8873. [ApiExplorerSettings(IgnoreApi = true)]
  8874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8875. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8876. {
  8877. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8878. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8879. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8880. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8881. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8882. {
  8883. Id = x.Id,
  8884. Diid = dto.DiId,
  8885. SetDataId = x.SetDataId,
  8886. Index = x.Index,
  8887. Cost = x.Cost,
  8888. Currency = x.Currency,
  8889. SubTotal = x.SubTotal,
  8890. CreateUserId = dto.CurrUserId,
  8891. Remark = x.Remark
  8892. }).ToList();
  8893. var adds = infos.Where(x => x.Id <= 0).ToList();
  8894. var upds = infos.Where(x => x.Id > 0).ToList();
  8895. if (adds.Count > 0)
  8896. {
  8897. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8898. if (add < 1) return Ok(JsonView(false));
  8899. }
  8900. if (upds.Count > 0)
  8901. {
  8902. var upd = await _sqlSugar.Updateable(adds)
  8903. .UpdateColumns(x => new
  8904. {
  8905. x.Index,
  8906. x.SetDataId,
  8907. x.Cost,
  8908. x.Currency,
  8909. x.SubTotal,
  8910. x.Remark
  8911. })
  8912. .WhereColumns(x => new { x.Id })
  8913. .ExecuteCommandAsync();
  8914. if (upd < 1) return Ok(JsonView(false));
  8915. }
  8916. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8917. //消息通知
  8918. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8919. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8920. return Ok(JsonView(new { itemTotal = itemTotal }));
  8921. }
  8922. /// <summary>
  8923. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8924. /// </summary>
  8925. /// <returns></returns>
  8926. [HttpPost]
  8927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8928. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8929. {
  8930. int subId = dto.SubId;
  8931. int diId = dto.Diid;
  8932. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8933. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8934. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8935. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8936. subInfo.Id = subId;
  8937. subInfo.Diid = dto.Diid;
  8938. subInfo.CreateUserId = dto.CurrUserId;
  8939. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8940. if (parentId < 1) return Ok(JsonView(false));
  8941. #region 子表op
  8942. if (subId < 1)//add
  8943. {
  8944. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8945. if (subAdd < 1) return Ok(JsonView(false));
  8946. }
  8947. else //upd
  8948. {
  8949. ////验证编辑权限
  8950. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8951. //if (!isEdit) return Ok(JsonView(false, msg));
  8952. var subUpd = await _sqlSugar.Updateable(subInfo)
  8953. .UpdateColumns(x => new
  8954. {
  8955. x.Index,
  8956. x.SetDataId,
  8957. x.Cost,
  8958. x.Currency,
  8959. x.SubTotal,
  8960. x.Remark
  8961. })
  8962. .WhereColumns(x => new { x.Id })
  8963. .ExecuteCommandAsync();
  8964. if (subUpd < 1) return Ok(JsonView(false));
  8965. }
  8966. #endregion
  8967. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8968. //消息通知
  8969. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8970. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8971. }
  8972. /// <summary>
  8973. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8974. /// </summary>
  8975. /// <returns></returns>
  8976. [HttpPost]
  8977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8978. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8979. {
  8980. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8981. if (data.Code != 0)
  8982. {
  8983. return Ok(JsonView(false, data.Msg));
  8984. }
  8985. return Ok(JsonView(true, "操作成功!", data.Data));
  8986. }
  8987. /// <summary>
  8988. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8989. /// </summary>
  8990. /// <param name="dto"></param>
  8991. /// <returns></returns>
  8992. [HttpPost]
  8993. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8994. {
  8995. var data = new Grp_DayOtherPrice()
  8996. {
  8997. Id = dto.Id,
  8998. IsDel = 1,
  8999. DeleteUserId = dto.DeleteUserId,
  9000. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9001. };
  9002. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9003. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9004. return Ok(JsonView(false, "删除失败!"));
  9005. }
  9006. #endregion
  9007. #endregion
  9008. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9009. /// <summary>
  9010. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9011. /// </summary>
  9012. /// <returns></returns>
  9013. [HttpPost]
  9014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9015. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9016. {
  9017. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9018. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9019. RefAsync<int> total = 0;
  9020. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9021. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9022. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9023. .Select(x => new
  9024. {
  9025. Id = x.Id,
  9026. DraftName = x.DraftName,
  9027. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9028. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9029. .Any()
  9030. })
  9031. .OrderByDescending(x => x.Id)
  9032. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9033. return Ok(JsonView(true, "查询成功!", data, total));
  9034. }
  9035. /// <summary>
  9036. /// 出入境费用-草稿 移动端
  9037. /// 获取币种基础数据(含逻辑处理)
  9038. /// </summary>
  9039. /// <returns></returns>
  9040. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9041. {
  9042. //默认币种显示
  9043. var _currencyInfos = _currencyInit;
  9044. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9045. if (_currencyRate.Count > 0)
  9046. {
  9047. foreach (var item in _currencyInfos)
  9048. {
  9049. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9050. if (rateInfo != null)
  9051. {
  9052. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  9053. rate1 *= 1.035M;
  9054. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9055. }
  9056. }
  9057. }
  9058. return _currencyInfos;
  9059. }
  9060. /// <summary>
  9061. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9062. /// </summary>
  9063. /// <returns></returns>
  9064. [HttpPost]
  9065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9066. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9067. {
  9068. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9069. //SetDataInfoView
  9070. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9071. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9072. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9073. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9074. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9075. //默认币种显示
  9076. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9077. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9078. return Ok(JsonView(true, "查询成功!", new
  9079. {
  9080. WordTypeData = _WordTypeData,
  9081. ExcelTypeData = _ExcelTypeData,
  9082. CurrencyInit = _currencyInfos,
  9083. viewPermissionData = viewPermissionData
  9084. }));
  9085. }
  9086. /// <summary>
  9087. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9088. /// </summary>
  9089. /// <returns></returns>
  9090. [HttpPost]
  9091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9092. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9093. {
  9094. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9095. RefAsync<int> total = 0;
  9096. int diId = 0;
  9097. var status = int.TryParse(dto.GroupName, out diId);
  9098. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9099. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9100. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9101. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9102. .Select(x => new
  9103. {
  9104. Id = x.Id,
  9105. GroupName = x.TeamName
  9106. })
  9107. .OrderByDescending(x => x.Id)
  9108. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9109. return Ok(JsonView(true, "查询成功!", data, total));
  9110. }
  9111. /// <summary>
  9112. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9113. /// </summary>
  9114. /// <returns></returns>
  9115. [HttpPost]
  9116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9117. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9118. {
  9119. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9120. RefAsync<int> total = 0;
  9121. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9122. .Where(x => x.IsDel == 0 && x.STid == 66)
  9123. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9124. .Select(x => new
  9125. {
  9126. id = x.Id,
  9127. name = x.Name,
  9128. remark = x.Remark,
  9129. })
  9130. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9131. return Ok(JsonView(true, "查询成功!", data, total));
  9132. }
  9133. /// <summary>
  9134. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9135. /// </summary>
  9136. /// <returns></returns>
  9137. [HttpPost]
  9138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9139. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9140. {
  9141. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9142. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9143. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9144. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9145. var groupOtherRateData = groupRateData.TeamRates;
  9146. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9147. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9148. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9149. groupOtherRateData = groupOtherRateData
  9150. .Select(x => new TeamRateDescAddCurrencyIdView
  9151. {
  9152. CurrencyId = x.CurrencyId,
  9153. CurrencyName = x.CurrencyName,
  9154. CurrencyCode = x.CurrencyCode,
  9155. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9156. }).ToList();
  9157. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9158. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9159. }
  9160. /// <summary>
  9161. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9162. /// </summary>
  9163. /// <returns></returns>
  9164. [HttpPost]
  9165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9166. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9167. {
  9168. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9169. var tipsData = new List<int>() { 1, 2, 3 };
  9170. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9171. if (dto.TipsType == 1)
  9172. {
  9173. //默认币种显示
  9174. var _currencyInfos = _currencyInit;
  9175. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  9176. List<dynamic> reteInfos = new List<dynamic>();
  9177. if (_currencyRate.Count > 0)
  9178. {
  9179. foreach (var item in _currencyInfos)
  9180. {
  9181. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9182. if (rateInfo != null)
  9183. {
  9184. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9185. decimal rate1 = item.Rate;
  9186. rate1 *= 1.03M;
  9187. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9188. reteInfos.Add(new
  9189. {
  9190. currCode = item.CurrencyCode,
  9191. currName = item.CurrencyName,
  9192. rate = rate2,
  9193. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9194. });
  9195. }
  9196. }
  9197. }
  9198. return Ok(JsonView(true, "查询成功!", reteInfos));
  9199. }
  9200. else if (dto.TipsType == 2)
  9201. {
  9202. }
  9203. else if (dto.TipsType == 3)
  9204. {
  9205. }
  9206. return Ok(JsonView(false));
  9207. }
  9208. /// <summary>
  9209. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9210. /// </summary>
  9211. /// <returns></returns>
  9212. [HttpPost]
  9213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9214. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9215. {
  9216. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9217. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9218. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9219. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9220. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9221. if (eecInfo == null) return Ok(mobileInfo);
  9222. //验证查看权限
  9223. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9224. if (!isView) return Ok(JsonView(false, msg));
  9225. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9226. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9227. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9228. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9229. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9230. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9231. {
  9232. ParentId = dac.ParentId,
  9233. SubId = dac.Id,
  9234. Type = dac.Type,
  9235. Days = dac.Days,
  9236. NationalTravelFeeId = dac.NationalTravelFeeId,
  9237. Arae = $"{ntf.Country}-{ntf.City}",
  9238. Cost = dac.Cost,
  9239. Currency = dac.Currency,
  9240. CurrencyName = sd.Name,
  9241. SubTotal = dac.SubTotal,
  9242. })
  9243. .ToList();
  9244. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9245. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9246. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9247. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9248. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9249. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9250. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9251. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9252. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9253. //其他款项
  9254. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9255. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9256. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9257. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9258. .OrderBy((dop, sd1, sd2) => dop.Index)
  9259. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9260. {
  9261. ParentId = dop.ParentId,
  9262. SubId = dop.Id,
  9263. Index = dop.Index,
  9264. SetDataId = dop.SetDataId,
  9265. SetDataName = sd1.Name,
  9266. Cost = dop.Cost,
  9267. Currency = dop.Currency,
  9268. CurrencyName = sd2.Remark,
  9269. SubTotal = dop.SubTotal,
  9270. Remark = dop.Remark,
  9271. })
  9272. .ToArray();
  9273. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9274. return Ok(mobileInfo);
  9275. }
  9276. /// <summary>
  9277. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9278. /// </summary>
  9279. /// <returns></returns>
  9280. [HttpPost]
  9281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9282. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9283. {
  9284. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9285. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9286. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9287. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9288. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9289. //验证查看权限
  9290. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9291. if (!isView) return Ok(JsonView(false, msg));
  9292. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9293. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9294. var subType = dto.SubType;
  9295. if (subType == 1) //1:境内费用
  9296. {
  9297. var oneData = new ChoiceOneMobileSubInfoView()
  9298. {
  9299. Id = eecInfo.Id,
  9300. ChoiceOne = eecInfo.ChoiceOne,
  9301. ChoiceOneTotalCost = eecInfo.InsidePay,
  9302. Visa = eecInfo.Visa,
  9303. VisaRemark = eecInfo.VisaRemark,
  9304. YiMiao = eecInfo.YiMiao,
  9305. HeSuan = eecInfo.HeSuan,
  9306. Service = eecInfo.Service,
  9307. Ticket = eecInfo.Ticket,
  9308. Safe = eecInfo.Safe,
  9309. FirstItemRemark = eecInfo.FirstItemRemark
  9310. };
  9311. return Ok(JsonView(oneData));
  9312. }
  9313. else if (subType == 2) //2:国际旅费
  9314. {
  9315. var twoData = new ChoiceTwoMobileSubInfoView()
  9316. {
  9317. Id = eecInfo.Id,
  9318. ChoiceTwoJJ = eecInfo.SumJJC,
  9319. OutsideJJPay = eecInfo.OutsideJJPay,
  9320. ChoiceTwoGW = eecInfo.SumGWC,
  9321. OutsideGWPay = eecInfo.OutsideGWPay,
  9322. ChoiceTwoTD = eecInfo.SumTDC,
  9323. OutsideTDPay = eecInfo.OutsideTDPay,
  9324. AirJJ = eecInfo.AirJJ,
  9325. AirGW = eecInfo.AirGW,
  9326. AirTD = eecInfo.AirTD,
  9327. CityTranffic = eecInfo.CityTranffic,
  9328. TwoItemRemark = eecInfo.TwoItemRemark
  9329. };
  9330. return Ok(JsonView(twoData));
  9331. }
  9332. else if (subType == 3) //3:住宿费
  9333. {
  9334. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9335. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9336. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9337. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9338. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9339. {
  9340. ParentId = dac.ParentId,
  9341. SubId = dac.Id,
  9342. Type = dac.Type,
  9343. Days = dac.Days,
  9344. NationalTravelFeeId = dac.NationalTravelFeeId,
  9345. Arae = $"{ntf.Country}-{ntf.City}",
  9346. Cost = dac.Cost,
  9347. Currency = dac.Currency,
  9348. CurrencyName = sd.Name,
  9349. SubTotal = dac.SubTotal,
  9350. })
  9351. .ToArray();
  9352. var data = new ChoiceDraftMobileSubInfo3To6View()
  9353. {
  9354. ParentId = eecInfo.Id,
  9355. Choice = eecInfo.ChoiceThree,
  9356. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9357. Details = dayAndCostDatas
  9358. };
  9359. return Ok(JsonView(data));
  9360. }
  9361. else if (subType == 4) //4:伙食费
  9362. {
  9363. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9364. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9365. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9366. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9367. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9368. {
  9369. ParentId = dac.ParentId,
  9370. SubId = dac.Id,
  9371. Type = dac.Type,
  9372. Days = dac.Days,
  9373. NationalTravelFeeId = dac.NationalTravelFeeId,
  9374. Arae = $"{ntf.Country}-{ntf.City}",
  9375. Cost = dac.Cost,
  9376. Currency = dac.Currency,
  9377. CurrencyName = sd.Name,
  9378. SubTotal = dac.SubTotal,
  9379. })
  9380. .ToArray();
  9381. var data = new ChoiceDraftMobileSubInfo3To6View()
  9382. {
  9383. ParentId = eecInfo.Id,
  9384. Choice = eecInfo.ChoiceFour,
  9385. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9386. Details = dayAndCostDatas
  9387. };
  9388. return Ok(JsonView(data));
  9389. }
  9390. else if (subType == 5) //5:公杂费
  9391. {
  9392. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9393. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9394. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9395. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9396. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9397. {
  9398. ParentId = dac.ParentId,
  9399. SubId = dac.Id,
  9400. Type = dac.Type,
  9401. Days = dac.Days,
  9402. NationalTravelFeeId = dac.NationalTravelFeeId,
  9403. Arae = $"{ntf.Country}-{ntf.City}",
  9404. Cost = dac.Cost,
  9405. Currency = dac.Currency,
  9406. CurrencyName = sd.Name,
  9407. SubTotal = dac.SubTotal,
  9408. })
  9409. .ToArray();
  9410. var data = new ChoiceDraftMobileSubInfo3To6View()
  9411. {
  9412. ParentId = eecInfo.Id,
  9413. Choice = eecInfo.ChoiceFive,
  9414. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9415. Details = dayAndCostDatas
  9416. };
  9417. return Ok(JsonView(data));
  9418. }
  9419. else if (subType == 6) //6:培训费
  9420. {
  9421. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9422. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9423. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9424. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9425. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9426. {
  9427. ParentId = dac.ParentId,
  9428. SubId = dac.Id,
  9429. Type = dac.Type,
  9430. Days = dac.Days,
  9431. NationalTravelFeeId = dac.NationalTravelFeeId,
  9432. Arae = $"{ntf.Country}-{ntf.City}",
  9433. Cost = dac.Cost,
  9434. Currency = dac.Currency,
  9435. CurrencyName = sd.Name,
  9436. SubTotal = dac.SubTotal,
  9437. })
  9438. .ToArray();
  9439. var data = new ChoiceDraftMobileSubInfo3To6View()
  9440. {
  9441. ParentId = eecInfo.Id,
  9442. Choice = eecInfo.ChoiceSix,
  9443. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9444. Details = dayAndCostDatas
  9445. };
  9446. return Ok(JsonView(data));
  9447. }
  9448. else if (subType == 7) //7:其他
  9449. {
  9450. //其他款项
  9451. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9452. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9453. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9454. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9455. .OrderBy((dop, sd1, sd2) => dop.Index)
  9456. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9457. {
  9458. ParentId = dop.ParentId,
  9459. SubId = dop.Id,
  9460. Index = dop.Index,
  9461. SetDataId = dop.SetDataId,
  9462. SetDataName = sd1.Name,
  9463. Cost = dop.Cost,
  9464. Currency = dop.Currency,
  9465. CurrencyName = sd2.Name,
  9466. SubTotal = dop.SubTotal,
  9467. Remark = dop.Remark,
  9468. })
  9469. .ToArray();
  9470. var data = new ChoiceSevenDraftMobileSubInfoView()
  9471. {
  9472. ParentId = eecInfo.Id,
  9473. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9474. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9475. Details = otherData
  9476. };
  9477. return Ok(JsonView(data));
  9478. }
  9479. return Ok(JsonView(false));
  9480. }
  9481. #region op
  9482. /// <summary>
  9483. /// 移动端更新费用消息通知
  9484. /// </summary>
  9485. /// <param name="draftId"></param>
  9486. /// <param name="id"></param>
  9487. /// <param name="currUserId"></param>
  9488. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9489. {
  9490. try
  9491. {
  9492. ////生成默认文件pdf并且通知人员
  9493. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9494. //{
  9495. // DiId = draftId,
  9496. // ExportType = 1,
  9497. // SubTypeId = 1005
  9498. //}, "pdf");
  9499. ////发送通知
  9500. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9501. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9502. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9503. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9504. ////汇率信息记录
  9505. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9506. }
  9507. catch (Exception ex)
  9508. {
  9509. //记录日志
  9510. throw;
  9511. }
  9512. }
  9513. /// <summary>
  9514. /// 验证出入境费用数据是否存在
  9515. /// 不存在添加
  9516. /// </summary>
  9517. /// <param name="draftId"></param>
  9518. /// <param name="currUserId"></param>
  9519. /// <returns></returns>
  9520. /// <exception cref="CustomException"></exception>
  9521. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9522. {
  9523. var parentId = 0;
  9524. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9525. if (info != null) parentId = info.Id;
  9526. else
  9527. {
  9528. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9529. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9530. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9531. parentId = addId;
  9532. }
  9533. return parentId;
  9534. }
  9535. /// <summary>
  9536. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9537. /// </summary>
  9538. /// <returns></returns>
  9539. [HttpPost]
  9540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9541. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9542. {
  9543. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9544. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9545. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9546. //验证编辑权限
  9547. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9548. if (!isEdit) return Ok(JsonView(false, msg));
  9549. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9550. foreach (var userId in dto.UserIds)
  9551. {
  9552. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9553. }
  9554. if (permissions.Any())
  9555. {
  9556. _sqlSugar.BeginTran();
  9557. try
  9558. {
  9559. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9560. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9561. if (result < 1)
  9562. {
  9563. _sqlSugar.RollbackTran();
  9564. return Ok(JsonView(false));
  9565. }
  9566. }
  9567. catch (Exception ex)
  9568. {
  9569. _sqlSugar.RollbackTran();
  9570. return Ok(JsonView(false, ex.Message));
  9571. }
  9572. _sqlSugar.CommitTran();
  9573. return Ok(JsonView(true));
  9574. }
  9575. return Ok(JsonView(false));
  9576. }
  9577. /// <summary>
  9578. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9579. /// </summary>
  9580. /// <returns></returns>
  9581. [HttpPost]
  9582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9583. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9584. {
  9585. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9586. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9587. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9588. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9589. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9590. int id = dto.DraftId;
  9591. if (id <= 0) //add
  9592. {
  9593. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9594. if (add < 1) return Ok(JsonView(false));
  9595. id = add;
  9596. }
  9597. else //update
  9598. {
  9599. //验证编辑权限
  9600. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9601. if (!isEdit) return Ok(JsonView(false, msg));
  9602. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9603. if (upd < 1) return Ok(JsonView(false));
  9604. }
  9605. #region 汇率变更时更改币种相关费用
  9606. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9607. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9608. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9609. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9610. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9611. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9612. .Select((dac, sd) => new
  9613. {
  9614. dac.Id,
  9615. dac.ParentId,
  9616. CurrencyCode = sd.Name,
  9617. dac.Cost
  9618. })
  9619. .ToList();
  9620. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9621. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9622. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9623. .Select((dop, sd) => new
  9624. {
  9625. dop.Id,
  9626. dop.ParentId,
  9627. CurrencyCode = sd.Name,
  9628. dop.Cost
  9629. })
  9630. .ToList();
  9631. if (dayCosts.Count > 0)
  9632. {
  9633. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9634. foreach (var dc in new_dayCosts)
  9635. {
  9636. var thisCurrency = dc.Key.ToUpper();
  9637. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9638. if (thisRate == 0.00M) continue;
  9639. foreach (var dcSub in dc)
  9640. {
  9641. opDayCosts.Add(new Grp_DayAndCostDraft()
  9642. {
  9643. Id = dcSub.Id,
  9644. ParentId = dcSub.ParentId,
  9645. Cost = dcSub.Cost,
  9646. SubTotal = dcSub.Cost * thisRate,
  9647. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9648. });
  9649. }
  9650. }
  9651. if (opDayCosts.Count > 0)
  9652. {
  9653. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9654. }
  9655. }
  9656. if (dayOtherCosts.Count > 0)
  9657. {
  9658. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9659. foreach (var dc in new_dayOtherCosts)
  9660. {
  9661. var thisCurrency = dc.Key.ToUpper();
  9662. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9663. if (thisRate == 0.00M) continue;
  9664. foreach (var dcSub in dc)
  9665. {
  9666. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9667. {
  9668. Id = dcSub.Id,
  9669. ParentId = dcSub.ParentId,
  9670. Cost = dcSub.Cost,
  9671. SubTotal = dcSub.Cost * thisRate,
  9672. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9673. });
  9674. }
  9675. }
  9676. if (opDayOtherCosts.Count > 0)
  9677. {
  9678. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9679. }
  9680. }
  9681. #endregion
  9682. ////消息通知
  9683. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9684. ////汇率信息记录
  9685. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9686. return Ok(JsonView(new { parentId = id }));
  9687. }
  9688. /// <summary>
  9689. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9690. /// </summary>
  9691. /// <returns></returns>
  9692. [HttpPost]
  9693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9694. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9695. {
  9696. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9697. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9698. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9699. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9700. int id = dto.DraftId;
  9701. if (id <= 0) //add
  9702. {
  9703. checkboxInfo.CreateUserId = dto.CurrUserId;
  9704. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9705. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9706. if (add < 1) return Ok(JsonView(false));
  9707. }
  9708. else //update
  9709. {
  9710. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9711. .UpdateColumns(x => new
  9712. {
  9713. x.ChoiceOne,
  9714. x.ChoiceTwo,
  9715. x.SumJJC,
  9716. x.SumGWC,
  9717. x.SumTDC,
  9718. x.ChoiceThree,
  9719. x.ChoiceFour,
  9720. x.ChoiceFive,
  9721. x.ChoiceSix,
  9722. x.OtherExpenses_Checked
  9723. })
  9724. .Where(x => x.Id == id)
  9725. .ExecuteCommandAsync();
  9726. if (upd < 1) return Ok(JsonView(false));
  9727. }
  9728. return Ok(JsonView(new { parentId = id }));
  9729. }
  9730. /// <summary>
  9731. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9732. /// </summary>
  9733. /// <returns></returns>
  9734. [HttpPost]
  9735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9736. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9737. {
  9738. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9739. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9740. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9741. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9742. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9743. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9744. var checkboxInfo = new Grp_EnterExitCostDraft()
  9745. {
  9746. Id = draftId,
  9747. CreateUserId = currUserId
  9748. };
  9749. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9750. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9751. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9752. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9753. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9754. if (draftId <= 0) //add
  9755. {
  9756. checkboxInfo.CreateUserId = dto.CurrUserId;
  9757. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9758. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9759. if (add < 1) return Ok(JsonView(false));
  9760. }
  9761. else //update
  9762. {
  9763. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9764. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9765. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9766. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9767. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9768. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9769. .Where(x => x.Id == draftId)
  9770. .ExecuteCommandAsync();
  9771. if (upd < 1) return Ok(JsonView(false));
  9772. }
  9773. return Ok(JsonView(new { parentId = draftId }));
  9774. }
  9775. /// <summary>
  9776. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9777. /// </summary>
  9778. /// <returns></returns>
  9779. [HttpPost]
  9780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9781. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9782. {
  9783. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9784. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9785. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9786. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9787. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9788. info.FirstItemRemark = dto.FirstItemRemark;
  9789. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9790. if (id <= 0) //add
  9791. {
  9792. info.CreateUserId = dto.CurrUserId;
  9793. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9794. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9795. if (add < 1) return Ok(JsonView(false));
  9796. id = add;
  9797. }
  9798. else //update
  9799. {
  9800. var upd = await _sqlSugar.Updateable(info)
  9801. .UpdateColumns(x => new
  9802. {
  9803. x.ChoiceOne,
  9804. x.InsidePay,
  9805. x.VisaRemark,
  9806. x.Visa,
  9807. x.Service,
  9808. x.Safe,
  9809. x.Ticket,
  9810. x.HeSuan,
  9811. x.YiMiao,
  9812. x.FirstItemRemark
  9813. })
  9814. .Where(x => x.Id == id)
  9815. .ExecuteCommandAsync();
  9816. if (upd < 1) return Ok(JsonView(false));
  9817. }
  9818. ////消息通知
  9819. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9820. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9821. }
  9822. /// <summary>
  9823. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9824. /// </summary>
  9825. /// <returns></returns>
  9826. [HttpPost]
  9827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9828. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9829. {
  9830. int id = dto.DraftId;
  9831. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9832. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9833. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9834. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9835. info.OutsideJJPay = dto.OutsideJJPay;
  9836. info.OutsideGWPay = dto.OutsideGWPay;
  9837. info.OutsideTDPay = dto.OutsideTDPay;
  9838. info.AirJJ = dto.AirJJ;
  9839. info.AirGW = dto.AirGW;
  9840. info.AirTD = dto.AirTD;
  9841. info.CityTranffic = dto.CityTranffic;
  9842. info.TwoItemRemark = dto.TwoItemRemark;
  9843. info.SumJJC = dto.ChoiceTwoJJ;
  9844. info.SumGWC = dto.ChoiceTwoGW;
  9845. info.SumTDC = dto.ChoiceTwoTD;
  9846. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9847. if (id <= 0) //add
  9848. {
  9849. info.CreateUserId = dto.CurrUserId;
  9850. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9851. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9852. if (addId <= 0) return Ok(JsonView(false));
  9853. id = addId;
  9854. }
  9855. else //update
  9856. {
  9857. var upd = await _sqlSugar.Updateable(info)
  9858. .UpdateColumns(x => new
  9859. {
  9860. x.SumJJC,
  9861. x.OutsideJJPay,
  9862. x.SumGWC,
  9863. x.OutsideGWPay,
  9864. x.SumTDC,
  9865. x.OutsideTDPay,
  9866. x.AirJJ,
  9867. x.AirGW,
  9868. x.AirTD,
  9869. x.CityTranffic,
  9870. x.TwoItemRemark
  9871. })
  9872. .Where(x => x.Id == id)
  9873. .ExecuteCommandAsync();
  9874. if (upd < 1) return Ok(JsonView(false));
  9875. }
  9876. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9877. gwcItemTotal = info.AirGW + info.CityTranffic;
  9878. tdcItemTotal = info.AirTD + info.CityTranffic;
  9879. ////消息通知
  9880. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9881. return Ok(JsonView(new
  9882. {
  9883. parentId = id,
  9884. choiceTwoJJ = dto.ChoiceTwoJJ,
  9885. jjcItemTotal = jjcItemTotal,
  9886. choiceTwoGW = dto.ChoiceTwoGW,
  9887. gwcItemTotal = gwcItemTotal,
  9888. choiceTwoTD = dto.ChoiceTwoTD,
  9889. tdcItemTotal = tdcItemTotal
  9890. }));
  9891. }
  9892. /// <summary>
  9893. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9894. /// </summary>
  9895. /// <returns></returns>
  9896. [HttpPost]
  9897. [ApiExplorerSettings(IgnoreApi = true)]
  9898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9899. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9900. {
  9901. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9902. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9903. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9904. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9905. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9906. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9907. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9908. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9909. {
  9910. Id = x.Id,
  9911. ParentId = dto.DraftId,
  9912. Type = dto.FeeType,
  9913. Days = x.Days,
  9914. NationalTravelFeeId = x.NationalTravelFeeId,
  9915. Cost = x.Cost,
  9916. Currency = x.Currency,
  9917. SubTotal = x.SubTotal,
  9918. CreateUserId = dto.CurrUserId
  9919. })
  9920. .ToList();
  9921. var adds = infos.Where(x => x.Id <= 0).ToList();
  9922. var upds = infos.Where(x => x.Id > 0).ToList();
  9923. if (adds.Count > 0)
  9924. {
  9925. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9926. if (add < 1) return Ok(JsonView(false));
  9927. }
  9928. if (upds.Count > 0)
  9929. {
  9930. var upd = await _sqlSugar.Updateable(adds)
  9931. .UpdateColumns(x => new
  9932. {
  9933. x.Days,
  9934. x.NationalTravelFeeId,
  9935. x.Cost,
  9936. x.Currency,
  9937. x.SubTotal
  9938. })
  9939. .WhereColumns(x => new { x.Id })
  9940. .ExecuteCommandAsync();
  9941. if (upd < 1) return Ok(JsonView(false));
  9942. }
  9943. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9944. ////消息通知
  9945. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9946. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9947. return Ok(JsonView(new { itemTotal = itemTotal }));
  9948. }
  9949. /// <summary>
  9950. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9951. /// </summary>
  9952. /// <returns></returns>
  9953. [HttpPost]
  9954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9955. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9956. {
  9957. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9958. int subId = dto.SubId, feeType = dto.FeeType;
  9959. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9960. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9961. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9962. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9963. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9964. subInfo.Id = subId;
  9965. subInfo.ParentId = dto.DraftId;
  9966. if (feeType == 3) subInfo.Type = 1;
  9967. else if (feeType == 4) subInfo.Type = 2;
  9968. else if (feeType == 5) subInfo.Type = 3;
  9969. else if (feeType == 6) subInfo.Type = 4;
  9970. subInfo.CreateUserId = dto.CurrUserId;
  9971. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9972. if (parentId < 1) return Ok(JsonView(false));
  9973. //子表op
  9974. if (subId < 1)
  9975. {
  9976. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9977. if (subAdd < 1) return Ok(JsonView(false));
  9978. }
  9979. else
  9980. {
  9981. var subUpd = await _sqlSugar.Updateable(subInfo)
  9982. .UpdateColumns(x => new
  9983. {
  9984. x.Days,
  9985. x.NationalTravelFeeId,
  9986. x.Cost,
  9987. x.Currency,
  9988. x.SubTotal
  9989. })
  9990. .WhereColumns(x => new { x.Id })
  9991. .ExecuteCommandAsync();
  9992. if (subUpd < 1) return Ok(JsonView(false));
  9993. }
  9994. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9995. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9996. }
  9997. /// <summary>
  9998. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9999. /// </summary>
  10000. /// <returns></returns>
  10001. [HttpPost]
  10002. [ApiExplorerSettings(IgnoreApi = true)]
  10003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10004. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10005. {
  10006. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10007. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10008. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10009. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10010. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10011. {
  10012. Id = x.Id,
  10013. ParentId = dto.DraftId,
  10014. SetDataId = x.SetDataId,
  10015. Index = x.Index,
  10016. Cost = x.Cost,
  10017. Currency = x.Currency,
  10018. SubTotal = x.SubTotal,
  10019. CreateUserId = dto.CurrUserId,
  10020. Remark = x.Remark
  10021. }).ToList();
  10022. var adds = infos.Where(x => x.Id <= 0).ToList();
  10023. var upds = infos.Where(x => x.Id > 0).ToList();
  10024. if (adds.Count > 0)
  10025. {
  10026. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10027. if (add < 1) return Ok(JsonView(false));
  10028. }
  10029. if (upds.Count > 0)
  10030. {
  10031. var upd = await _sqlSugar.Updateable(adds)
  10032. .UpdateColumns(x => new
  10033. {
  10034. x.Index,
  10035. x.SetDataId,
  10036. x.Cost,
  10037. x.Currency,
  10038. x.SubTotal,
  10039. x.Remark
  10040. })
  10041. .WhereColumns(x => new { x.Id })
  10042. .ExecuteCommandAsync();
  10043. if (upd < 1) return Ok(JsonView(false));
  10044. }
  10045. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10046. //消息通知
  10047. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10048. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10049. return Ok(JsonView(new { itemTotal = itemTotal }));
  10050. }
  10051. /// <summary>
  10052. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10053. /// </summary>
  10054. /// <returns></returns>
  10055. [HttpPost]
  10056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10057. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10058. {
  10059. int subId = dto.SubId, id = dto.DarftId;
  10060. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10061. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10062. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10063. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10064. subInfo.Id = subId;
  10065. subInfo.ParentId = dto.DarftId;
  10066. subInfo.CreateUserId = dto.CurrUserId;
  10067. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10068. if (parentId < 1) return Ok(JsonView(false));
  10069. #region 子表op
  10070. if (subId < 1)//add
  10071. {
  10072. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10073. if (subAdd < 1) return Ok(JsonView(false));
  10074. }
  10075. else //upd
  10076. {
  10077. var subUpd = await _sqlSugar.Updateable(subInfo)
  10078. .UpdateColumns(x => new
  10079. {
  10080. x.Index,
  10081. x.SetDataId,
  10082. x.Cost,
  10083. x.Currency,
  10084. x.SubTotal,
  10085. x.Remark
  10086. })
  10087. .WhereColumns(x => new { x.Id })
  10088. .ExecuteCommandAsync();
  10089. if (subUpd < 1) return Ok(JsonView(false));
  10090. }
  10091. #endregion
  10092. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10093. ////消息通知
  10094. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10095. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10096. }
  10097. /// <summary>
  10098. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10099. /// </summary>
  10100. /// <returns></returns>
  10101. [HttpPost]
  10102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10103. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10104. {
  10105. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10106. if (data.Code != 0)
  10107. {
  10108. return Ok(JsonView(false, data.Msg));
  10109. }
  10110. return Ok(JsonView(true, "操作成功!", data.Data));
  10111. }
  10112. /// <summary>
  10113. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10114. /// </summary>
  10115. /// <param name="dto"></param>
  10116. /// <returns></returns>
  10117. [HttpPost]
  10118. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10119. {
  10120. var data = new Grp_DayOtherPriceDraft()
  10121. {
  10122. Id = dto.Id,
  10123. IsDel = 1,
  10124. DeleteUserId = dto.DeleteUserId,
  10125. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10126. };
  10127. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10128. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10129. return Ok(JsonView(false, "删除失败!"));
  10130. }
  10131. #endregion
  10132. #endregion
  10133. #region 团组经理模块 出入境费用报价表
  10134. /// <summary>
  10135. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10136. /// </summary>
  10137. /// <returns></returns>
  10138. [HttpPost]
  10139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10140. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10141. {
  10142. //默认币种显示
  10143. var currencyInfos = new List<CurrencyInfo>()
  10144. {
  10145. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  10146. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  10147. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  10148. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  10149. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  10150. };
  10151. var liveRateInfos = new List<LiveRateInfo>();
  10152. var currencyRate = await _juHeApi.PostItemRateAsync(currencyInfos.Select(it => it.CurrencyCode!).ToArray());
  10153. if (currencyRate.Any())
  10154. {
  10155. foreach (var item in currencyInfos)
  10156. {
  10157. var rateInfo = currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  10158. if (rateInfo != null)
  10159. {
  10160. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  10161. if (rateInfo.Name.Equals("日元")) rate1 *= 1.3700M;
  10162. else rate1 *= 1.035M;
  10163. liveRateInfos.Add(new LiveRateInfo() {
  10164. CurrencyCode = item.CurrencyCode,
  10165. CurrencyName = item.CurrencyName,
  10166. Rate = rate1.TruncDecimals(4),
  10167. LastUpdTime = $"{rateInfo.Date} {rateInfo.Time}",
  10168. });
  10169. }
  10170. }
  10171. }
  10172. return Ok(JsonView(true, "查询成功!", new
  10173. {
  10174. DefualtRates = currencyInfos,
  10175. LiveRates = liveRateInfos
  10176. }));
  10177. }
  10178. /// <summary>
  10179. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10180. /// </summary>
  10181. /// <returns></returns>
  10182. [HttpPost]
  10183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10184. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10185. {
  10186. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10187. }
  10188. /// <summary>
  10189. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10190. /// </summary>
  10191. /// <returns></returns>
  10192. [HttpPost]
  10193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10194. public async Task<IActionResult> EnterExitCostGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10195. {
  10196. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10197. }
  10198. #endregion
  10199. #region 签证费用录入
  10200. /// <summary>
  10201. /// 根据diid查询签证费用列表
  10202. /// </summary>
  10203. /// <param name="dto"></param>
  10204. /// <returns></returns>
  10205. [HttpPost]
  10206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10207. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10208. {
  10209. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10210. if (groupData.Code != 0)
  10211. {
  10212. return Ok(JsonView(false, groupData.Msg));
  10213. }
  10214. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10215. }
  10216. /// <summary>
  10217. /// 根据签证费用Id查询单条数据及c表数据
  10218. /// </summary>
  10219. /// <param name="dto"></param>
  10220. /// <returns></returns>
  10221. [HttpPost]
  10222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10223. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10224. {
  10225. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10226. if (groupData.Code != 0)
  10227. {
  10228. return Ok(JsonView(false, groupData.Msg));
  10229. }
  10230. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10231. }
  10232. /// <summary>
  10233. /// 签证费用删除
  10234. /// </summary>
  10235. /// <param name="dto"></param>
  10236. /// <returns></returns>
  10237. [HttpPost]
  10238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10239. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10240. {
  10241. _sqlSugar.BeginTran();
  10242. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10243. if (!res)
  10244. {
  10245. _sqlSugar.RollbackTran();
  10246. return Ok(JsonView(false, "删除失败"));
  10247. }
  10248. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10249. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10250. .SetColumns(a => new Grp_CreditCardPayment()
  10251. {
  10252. IsDel = 1,
  10253. DeleteUserId = dto.DeleteUserId,
  10254. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10255. })
  10256. .ExecuteCommand();
  10257. if (resSub < 1)
  10258. {
  10259. _sqlSugar.RollbackTran();
  10260. return Ok(JsonView(false, "删除失败"));
  10261. }
  10262. _sqlSugar.CommitTran();
  10263. return Ok(JsonView(true, "删除成功!"));
  10264. }
  10265. /// <summary>
  10266. /// 签证费用录入下拉框初始化
  10267. /// </summary>
  10268. /// <returns></returns>
  10269. [HttpPost]
  10270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10271. public async Task<IActionResult> VisaPriceAddSelect()
  10272. {
  10273. //支付方式
  10274. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10275. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10276. //币种
  10277. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10278. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10279. //乘客类型
  10280. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10281. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10282. //卡类型
  10283. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10284. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10285. //代办费类型
  10286. var agencyFeeTypeData = new List<dynamic>() {
  10287. new { id = 0 , Text = "未选择" },
  10288. new { id = 1 , Text = "小公务" },
  10289. new { id = 2 , Text = "大公务" },
  10290. };
  10291. //签证费用标准国家Data
  10292. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10293. var data = new
  10294. {
  10295. Payment = _Payment,
  10296. CurrencyList = _CurrencyList,
  10297. PassengerType = _PassengerType,
  10298. BankCard = _BankCard,
  10299. AgencyFeeType = agencyFeeTypeData,
  10300. CountryFeeData = visaCountryFeeData
  10301. };
  10302. return Ok(JsonView(true, "查询成功!", data));
  10303. }
  10304. /// <summary>
  10305. /// 签证费用录入操作(Status:1.新增,2.修改)
  10306. /// </summary>
  10307. /// <param name="dto"></param>
  10308. /// <returns></returns>
  10309. [HttpPost]
  10310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10311. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10312. {
  10313. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10314. if (groupData.Code != 0)
  10315. {
  10316. return Ok(JsonView(false, groupData.Msg));
  10317. }
  10318. #region 应用推送
  10319. try
  10320. {
  10321. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10322. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10323. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10324. //2024-10-21 新增LZ UID
  10325. var userIds = new List<int>() { 21 };
  10326. string title = $"系统通知";
  10327. string content = "";
  10328. var diId = dto.DiId;
  10329. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10330. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10331. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10332. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10333. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10334. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10335. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10336. }
  10337. catch (Exception ex)
  10338. {
  10339. }
  10340. #endregion
  10341. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10342. }
  10343. #endregion
  10344. #region 签证提成录入
  10345. /// <summary>
  10346. /// 签证提成录入
  10347. /// 基础数据
  10348. /// </summary>
  10349. /// <returns></returns>
  10350. [HttpGet]
  10351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10352. public async Task<IActionResult> VisaCommissionInit()
  10353. {
  10354. return Ok(await _visaCommissionRep.Init());
  10355. }
  10356. /// <summary>
  10357. /// 签证提成录入
  10358. /// Item
  10359. /// </summary>
  10360. /// <param name="_dto"></param>
  10361. /// <returns></returns>
  10362. [HttpPost]
  10363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10364. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10365. {
  10366. var validator = new VisaCommissionItemDtoValidator();
  10367. var validatorRes = await validator.ValidateAsync(_dto);
  10368. if (!validatorRes.IsValid)
  10369. {
  10370. StringBuilder sb = new StringBuilder();
  10371. foreach (var item in validatorRes.Errors)
  10372. {
  10373. sb.AppendLine(item.ErrorMessage);
  10374. }
  10375. return Ok(JsonView(false, sb.ToString()));
  10376. }
  10377. return Ok(await _visaCommissionRep.Item(_dto));
  10378. }
  10379. /// <summary>
  10380. /// 签证提成录入
  10381. /// Save
  10382. /// </summary>
  10383. /// <param name="_dto"></param>
  10384. /// <returns></returns>
  10385. [HttpPost]
  10386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10387. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10388. {
  10389. //参数验证
  10390. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10391. foreach (var item in _dto.Items)
  10392. {
  10393. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10394. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10395. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10396. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10397. }
  10398. return Ok(await _visaCommissionRep.Save(_dto));
  10399. }
  10400. /// <summary>
  10401. /// 签证提成录入
  10402. /// Create
  10403. /// </summary>
  10404. /// <param name="_dto"></param>
  10405. /// <returns></returns>
  10406. [HttpPost]
  10407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10408. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10409. {
  10410. var validator = new VisaCommissionCreateDtoValidator();
  10411. var validatorRes = await validator.ValidateAsync(_dto);
  10412. if (!validatorRes.IsValid)
  10413. {
  10414. StringBuilder sb = new StringBuilder();
  10415. foreach (var item in validatorRes.Errors)
  10416. {
  10417. sb.AppendLine(item.ErrorMessage);
  10418. }
  10419. return Ok(JsonView(false, sb.ToString()));
  10420. }
  10421. return Ok(await _visaCommissionRep.Create(_dto));
  10422. }
  10423. /// <summary>
  10424. /// 签证提成录入
  10425. /// Put(编辑)
  10426. /// </summary>
  10427. /// <param name="id"></param>
  10428. /// <param name="_dto"></param>
  10429. /// <returns></returns>
  10430. [HttpPut]
  10431. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10432. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10433. {
  10434. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10435. var validator = new VisaCommissionCreateDtoValidator();
  10436. var validatorRes = await validator.ValidateAsync(_dto);
  10437. if (!validatorRes.IsValid)
  10438. {
  10439. StringBuilder sb = new StringBuilder();
  10440. foreach (var item in validatorRes.Errors)
  10441. {
  10442. sb.AppendLine(item.ErrorMessage);
  10443. }
  10444. return Ok(JsonView(false, sb.ToString()));
  10445. }
  10446. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10447. }
  10448. /// <summary>
  10449. /// 签证提成录入
  10450. /// Del
  10451. /// </summary>
  10452. /// <param name="id"></param>
  10453. /// <param name="currUserId"></param>
  10454. /// <returns></returns>
  10455. [HttpPost]
  10456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10457. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10458. {
  10459. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10460. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10461. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10462. }
  10463. #endregion
  10464. #region op费用录入
  10465. /// <summary>
  10466. /// 根据diid查询op费用列表
  10467. /// </summary>
  10468. /// <param name="dto"></param>
  10469. /// <returns></returns>
  10470. [HttpPost]
  10471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10472. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10473. {
  10474. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10475. if (groupData.Code != 0)
  10476. {
  10477. return Ok(JsonView(false, groupData.Msg));
  10478. }
  10479. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10480. }
  10481. /// <summary>
  10482. /// 根据op费用Id查询单条数据及c表数据
  10483. /// </summary>
  10484. /// <param name="dto"></param>
  10485. /// <returns></returns>
  10486. [HttpPost]
  10487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10488. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10489. {
  10490. try
  10491. {
  10492. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10493. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10494. var data = new
  10495. {
  10496. CarTouristGuideGround = _groupData,
  10497. CreditCardPayment = _creditCardPayment
  10498. };
  10499. return Ok(JsonView(true, "查询成功!", data));
  10500. }
  10501. catch (Exception ex)
  10502. {
  10503. return Ok(JsonView(false, "程序错误!"));
  10504. }
  10505. }
  10506. /// <summary>
  10507. /// op费用删除
  10508. /// </summary>
  10509. /// <param name="dto"></param>
  10510. /// <returns></returns>
  10511. [HttpPost]
  10512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10513. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10514. {
  10515. try
  10516. {
  10517. _sqlSugar.BeginTran();
  10518. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10519. if (!res)
  10520. {
  10521. return Ok(JsonView(false, "删除失败"));
  10522. }
  10523. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10524. {
  10525. IsDel = 1,
  10526. DeleteUserId = dto.DeleteUserId,
  10527. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10528. }).ExecuteCommandAsync();
  10529. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10530. {
  10531. IsDel = 1,
  10532. DeleteUserId = dto.DeleteUserId,
  10533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10534. }).ExecuteCommandAsync();
  10535. #region 删除超支相关数据
  10536. //删除导入的超支数据
  10537. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10538. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10539. {
  10540. IsDel = 1,
  10541. DeleteUserId = dto.DeleteUserId,
  10542. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10543. }).ExecuteCommand();
  10544. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10545. {
  10546. IsDel = 1,
  10547. DeleteUserId = dto.DeleteUserId,
  10548. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10549. }).ExecuteCommand();
  10550. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10551. {
  10552. IsDel = 1,
  10553. DeleteUserId = dto.DeleteUserId,
  10554. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10555. }).ExecuteCommand();
  10556. #endregion
  10557. _sqlSugar.CommitTran();
  10558. return Ok(JsonView(true, "删除成功!"));
  10559. }
  10560. catch (Exception ex)
  10561. {
  10562. _sqlSugar.RollbackTran();
  10563. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10564. }
  10565. }
  10566. /// <summary>
  10567. /// op费用录入操作(Status:1.新增,2.修改)
  10568. /// </summary>
  10569. /// <param name="dto"></param>
  10570. /// <returns></returns>
  10571. [HttpPost]
  10572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10573. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10574. {
  10575. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10576. if (groupData.Code != 0)
  10577. {
  10578. return Ok(JsonView(false, groupData.Msg));
  10579. }
  10580. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10581. }
  10582. /// <summary>
  10583. /// 填写费用详细页面初始化绑定
  10584. /// </summary>
  10585. /// <param name="dto"></param>
  10586. /// <returns></returns>
  10587. [HttpPost]
  10588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10589. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10590. {
  10591. try
  10592. {
  10593. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10594. if (groupData.Code != 0)
  10595. {
  10596. return Ok(JsonView(false, groupData.Msg));
  10597. }
  10598. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10599. }
  10600. catch (Exception ex)
  10601. {
  10602. return Ok(JsonView(false, ex.Message));
  10603. }
  10604. }
  10605. /// <summary>
  10606. /// 根据op费用Id查询详细数据
  10607. /// </summary>
  10608. /// <param name="dto"></param>
  10609. /// <returns></returns>
  10610. [HttpPost]
  10611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10612. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10613. {
  10614. try
  10615. {
  10616. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10617. if (groupData.Code != 0)
  10618. {
  10619. return Ok(JsonView(false, groupData.Msg));
  10620. }
  10621. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10622. }
  10623. catch (Exception ex)
  10624. {
  10625. return Ok(JsonView(false, ex.Message));
  10626. }
  10627. }
  10628. /// <summary>
  10629. /// OP费用录入填写详情
  10630. /// </summary>
  10631. /// <param name="dto"></param>
  10632. /// <returns></returns>
  10633. [HttpPost]
  10634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10635. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10636. {
  10637. try
  10638. {
  10639. #region 参数校验
  10640. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10641. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10642. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10643. #endregion
  10644. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10645. if (groupData.Code != 0)
  10646. {
  10647. return Ok(JsonView(false, groupData.Msg));
  10648. }
  10649. //自动审核
  10650. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10651. #region 应用推送
  10652. try
  10653. {
  10654. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10655. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10656. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10657. //2024-10-21 新增LZ UID
  10658. var userIds = new List<int>() { 21 };
  10659. string title = $"系统通知";
  10660. var diId = dto.DiId;
  10661. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10662. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10663. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  10664. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10665. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10666. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10667. }
  10668. catch (Exception ex)
  10669. {
  10670. }
  10671. #endregion
  10672. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10673. }
  10674. catch (Exception ex)
  10675. {
  10676. return Ok(JsonView(false, ex.Message));
  10677. }
  10678. }
  10679. /// <summary>
  10680. /// 获取三公详细所有城市
  10681. /// </summary>
  10682. /// <returns></returns>
  10683. [HttpGet]
  10684. public IActionResult OpCarCityResult()
  10685. {
  10686. var jw = JsonView(false);
  10687. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10688. {
  10689. x.Id,
  10690. x.Country,
  10691. x.City,
  10692. }).ToList();
  10693. if (data.Count > 0)
  10694. {
  10695. jw = JsonView(true, "获取成功!", data);
  10696. }
  10697. else
  10698. {
  10699. jw.Msg = "城市数据为空!";
  10700. jw.Data = new string[0];
  10701. }
  10702. return Ok(jw);
  10703. }
  10704. /// <summary>
  10705. /// 导出地接费用明细
  10706. /// </summary>
  10707. /// <param name="dto"></param>
  10708. /// <returns></returns>
  10709. [HttpPost]
  10710. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10711. {
  10712. var jw = JsonView(false);
  10713. if (dto.Diid < 1)
  10714. {
  10715. jw.Msg = "请输入正确的diid!";
  10716. return Ok(jw);
  10717. }
  10718. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10719. if (group == null)
  10720. {
  10721. jw.Msg = "未找到团组信息!";
  10722. return Ok(jw);
  10723. }
  10724. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10725. if (localGuideArr.Count == 0)
  10726. {
  10727. jw.Msg = "该团组暂无地接信息!";
  10728. return Ok(jw);
  10729. }
  10730. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10731. var overspendSoure = new Dictionary<int, int>
  10732. {
  10733. { 91, 982 }, //车
  10734. { 92 , 1059} ,//导游
  10735. { 994 , 1073}, //翻译
  10736. { 988 , 1074 }, //早餐
  10737. { 93 , 1075 }, //午餐
  10738. { 989 , 1076 }, //晚餐
  10739. };
  10740. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10741. foreach (var groupArr in localGroup)
  10742. {
  10743. var keyValue = groupArr.Key;
  10744. if (int.TryParse(keyValue, out int cityid))
  10745. {
  10746. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10747. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10748. }
  10749. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10750. foreach (var item in groupArr)
  10751. {
  10752. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10753. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10754. new Grp_CarTouristGuideGroundReservationsContentExtend
  10755. {
  10756. Count = a.Count,
  10757. CreateTime = a.CreateTime,
  10758. CreateUserId = a.CreateUserId,
  10759. CTGGRId = a.CTGGRId,
  10760. Currency = a.Currency,
  10761. DatePrice = a.DatePrice,
  10762. DeleteTime = a.DeleteTime,
  10763. DeleteUserId = a.DeleteUserId,
  10764. DiId = a.DiId,
  10765. Id = a.Id,
  10766. IsDel = a.IsDel,
  10767. Price = a.Price,
  10768. PriceContent = a.PriceContent,
  10769. Remark = a.Remark,
  10770. SId = a.SId,
  10771. SidName = b.Name,
  10772. Units = a.Units,
  10773. }
  10774. ).ToList();
  10775. if (content.Count > 0)
  10776. {
  10777. contentArr.Add(content);
  10778. }
  10779. }
  10780. //open excel
  10781. //set excel
  10782. //save excel
  10783. try
  10784. {
  10785. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10786. IWorkbook workbook;
  10787. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10788. {
  10789. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10790. }
  10791. else
  10792. {
  10793. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10794. }
  10795. ISheet sheet = workbook.GetSheetAt(0);
  10796. var rowStartIndex = 2;
  10797. var clounmCount = 10;
  10798. var initStyleRow = sheet.GetRow(2);
  10799. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10800. //var overspendArrDetail =
  10801. var existsId = new List<CarCompare>();
  10802. var lastElem = arr.Last();
  10803. var thisSid = -1;
  10804. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10805. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10806. {
  10807. Name = "未知币种!",
  10808. Remark = "未知币种!",
  10809. };
  10810. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10811. Action cloneRowFn = () =>
  10812. {
  10813. rowStartIndex++;
  10814. var cloneRow = sheet.CreateRow(rowStartIndex);
  10815. // 复制样式
  10816. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10817. {
  10818. ICell sourceCell = initStyleRow.GetCell(i);
  10819. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10820. // 确保单元格存在样式
  10821. if (sourceCell.CellStyle != null)
  10822. {
  10823. targetCell.CellStyle = sourceCell.CellStyle;
  10824. }
  10825. }
  10826. };
  10827. var mergeRow = () =>
  10828. {
  10829. for (int i = 2; i < sheet.LastRowNum; i++)
  10830. {
  10831. var row = sheet.GetRow(i);
  10832. var cellFirst = row.GetCell(0);
  10833. var thisIndex = i + 1;
  10834. while (thisIndex < sheet.LastRowNum)
  10835. {
  10836. var nextRow = sheet.GetRow(thisIndex);
  10837. var nextCellFirst = nextRow.GetCell(0);
  10838. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10839. {
  10840. thisIndex++;
  10841. }
  10842. else
  10843. {
  10844. break;
  10845. }
  10846. }
  10847. thisIndex--;
  10848. if (thisIndex != i)
  10849. {
  10850. //合并row
  10851. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10852. i, // 起始行索引(0-based)
  10853. thisIndex, // 结束行索引(0-based)
  10854. 0, // 起始列索引(0-based)
  10855. 0 // 结束列索引(0-based)
  10856. );
  10857. sheet.AddMergedRegion(cellRangeAddress);
  10858. i = thisIndex;
  10859. }
  10860. }
  10861. };
  10862. var chaoshiNumber = 0;
  10863. var totalNumber = 0.00M;
  10864. string lastStr = "";
  10865. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10866. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10867. {
  10868. b.IsAuditGM,
  10869. x.Id,
  10870. x.Area,
  10871. b.PayPercentage,
  10872. b.PayMoney,
  10873. }).ToList();
  10874. string yesPayment = "", noPayment = "";
  10875. foreach (var item in queryCarArrByCityAndDiid)
  10876. {
  10877. if (item.IsAuditGM == 1)
  10878. {
  10879. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10880. }
  10881. else
  10882. {
  10883. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10884. }
  10885. }
  10886. lastStr = yesPayment + noPayment;
  10887. foreach (var item in arr)
  10888. {
  10889. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10890. {
  10891. if (thisSid != item.SId)
  10892. {
  10893. if (thisSid == -1)
  10894. {
  10895. thisSid = item.SId;
  10896. }
  10897. else
  10898. {
  10899. //合并小计行
  10900. //创建合并区域的实例
  10901. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10902. rowStartIndex, // 起始行索引(0-based)
  10903. rowStartIndex, // 结束行索引(0-based)
  10904. 0, // 起始列索引(0-based)
  10905. 3 // 结束列索引(0-based)
  10906. );
  10907. sheet.AddMergedRegion(cellRangeAddress);
  10908. var CellStyle = workbook.CreateCellStyle();
  10909. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10910. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10911. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10912. for (int i = 0; i <= clounmCount; i++)
  10913. {
  10914. if (i > 6)
  10915. {
  10916. var CellStyle1 = workbook.CreateCellStyle();
  10917. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10918. IFont Font = workbook.CreateFont(); // 创建字体
  10919. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10920. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10921. CellStyle1.SetFont(Font);
  10922. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10923. }
  10924. else
  10925. {
  10926. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10927. }
  10928. }
  10929. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10930. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10931. //超时合计
  10932. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10933. //超时数
  10934. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10935. //超时合计费用
  10936. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10937. thisSid = item.SId;
  10938. cloneRowFn();
  10939. chaoshiNumber = 0;
  10940. totalNumber = 0;
  10941. }
  10942. }
  10943. IRow row = sheet.GetRow(rowStartIndex);
  10944. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10945. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10946. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10947. if (isOpenOverspendSoure)
  10948. {
  10949. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10950. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10951. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10952. }
  10953. for (int i = 0; i <= clounmCount; i++)
  10954. {
  10955. var cell = row.GetCell(i);
  10956. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10957. if (cell == null)
  10958. {
  10959. cell = row.CreateCell(i);
  10960. }
  10961. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10962. fontRed.CloneStyleFrom(cell.CellStyle);
  10963. IFont Font = workbook.CreateFont(); // 创建字体
  10964. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10965. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10966. fontRed.SetFont(Font);
  10967. byte[] rgb = new byte[3] { 255, 242, 204 };
  10968. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10969. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10970. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10971. if (workbook is XSSFWorkbook)
  10972. {
  10973. BackgroundColor255_242_204.FillForegroundColor = 0;
  10974. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10975. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10976. }
  10977. else
  10978. {
  10979. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10980. }
  10981. if (i == 1 || i > 6)
  10982. {
  10983. if (i > 6)
  10984. {
  10985. fontRed.FillForegroundColor = 0;
  10986. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10987. fontRed.FillPattern = FillPattern.SolidForeground;
  10988. }
  10989. cell.CellStyle = fontRed;
  10990. }
  10991. if (i > 2 && i < 7)
  10992. {
  10993. cell.CellStyle = BackgroundColor255_242_204;
  10994. }
  10995. cell.SetCellValue(setCellValue); //写入单元格
  10996. }
  10997. if (overspendSoure.ContainsKey(thisSid))
  10998. {
  10999. var overspendId = overspendSoure[thisSid];
  11000. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11001. }
  11002. cloneRowFn();
  11003. existsId.Add(new CarCompare
  11004. {
  11005. DataPrice = item.DatePrice.ObjToDate(),
  11006. Sid = item.SId
  11007. });
  11008. }
  11009. if (item.Equals(lastElem))
  11010. {
  11011. //合并小计行
  11012. //创建合并区域的实例
  11013. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11014. rowStartIndex, // 起始行索引(0-based)
  11015. rowStartIndex, // 结束行索引(0-based)
  11016. 0, // 起始列索引(0-based)
  11017. 3 // 结束列索引(0-based)
  11018. );
  11019. sheet.AddMergedRegion(cellRangeAddress);
  11020. var CellStyle = workbook.CreateCellStyle();
  11021. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11022. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11023. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11024. for (int i = 0; i <= clounmCount; i++)
  11025. {
  11026. if (i > 6)
  11027. {
  11028. var CellStyle1 = workbook.CreateCellStyle();
  11029. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11030. IFont Font = workbook.CreateFont(); // 创建字体
  11031. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11032. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11033. CellStyle1.SetFont(Font);
  11034. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11035. }
  11036. else
  11037. {
  11038. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11039. }
  11040. }
  11041. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11042. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11043. //超时合计
  11044. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11045. //超时数
  11046. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11047. //超时合计费用
  11048. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11049. cloneRowFn();
  11050. // 创建合并区域的实例
  11051. cellRangeAddress = new CellRangeAddress(
  11052. rowStartIndex, // 起始行索引(0-based)
  11053. rowStartIndex, // 结束行索引(0-based)
  11054. 0, // 起始列索引(0-based)
  11055. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11056. );
  11057. // 添加合并区域
  11058. sheet.AddMergedRegion(cellRangeAddress);
  11059. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11060. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11061. }
  11062. }
  11063. mergeRow();
  11064. // 保存修改后的Excel文件到新文件
  11065. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11066. // new FileStream(newFilePath, FileMode.CreateNew)
  11067. using (var stream = new MemoryStream())
  11068. {
  11069. workbook.Write(stream, true);
  11070. stream.Flush();
  11071. stream.Seek(0, SeekOrigin.Begin);
  11072. MemoryStream memoryStream = new MemoryStream();
  11073. stream.CopyTo(memoryStream);
  11074. memoryStream.Seek(0, SeekOrigin.Begin);
  11075. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11076. }
  11077. workbook.Close();
  11078. workbook.Dispose();
  11079. }
  11080. catch (Exception ex)
  11081. {
  11082. jw.Msg = "出现异常!" + ex.Message;
  11083. return Ok(jw);
  11084. }
  11085. }
  11086. if (Zips.Count > 0)
  11087. {
  11088. IOOperatorHelper io = new IOOperatorHelper();
  11089. var byts = io.ConvertZipStream(Zips);
  11090. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11091. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11092. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11093. }
  11094. else
  11095. {
  11096. jw.Msg = "暂无生成文件!";
  11097. }
  11098. return Ok(jw);
  11099. }
  11100. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11101. {
  11102. string outStr = string.Empty;
  11103. switch (i)
  11104. {
  11105. case 0:
  11106. outStr = arr[0].SidName;
  11107. break;
  11108. case 1:
  11109. outStr = arr[0].DataPriceStr;
  11110. break;
  11111. case 2:
  11112. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11113. break;
  11114. case 4:
  11115. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11116. break;
  11117. case 7:
  11118. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11119. {
  11120. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11121. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11122. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11123. }
  11124. break;
  11125. case 8:
  11126. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11127. {
  11128. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11129. }
  11130. break;
  11131. case 9:
  11132. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11133. {
  11134. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11135. }
  11136. break;
  11137. case 10:
  11138. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11139. {
  11140. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11141. }
  11142. break;
  11143. }
  11144. return outStr;
  11145. }
  11146. #region OP行程单
  11147. /// <summary>
  11148. /// OP行程单初始化
  11149. /// </summary>
  11150. /// <param name="dto"></param>
  11151. /// <returns></returns>
  11152. [HttpPost]
  11153. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11154. {
  11155. var jw = JsonView(false);
  11156. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11157. var group = groupList.First();
  11158. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11159. if (group == null)
  11160. {
  11161. jw.Msg = "暂无团组!";
  11162. return Ok(jw);
  11163. }
  11164. group = groupList.Find(x => x.Id == diid);
  11165. if (group == null)
  11166. {
  11167. jw.Msg = "请输入正确的团组ID!";
  11168. return Ok(jw);
  11169. }
  11170. string city = string.Empty;
  11171. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11172. if (blackCode.Count > 0)
  11173. {
  11174. var black = blackCode.First();
  11175. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11176. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11177. if (blackSp.Length > 0)
  11178. {
  11179. try
  11180. {
  11181. var cityArrCode = new List<string>(20);
  11182. foreach (var item in blackSp)
  11183. {
  11184. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11185. var IndexSelect = itemSp[2];
  11186. var cityArrCodeLength = cityArrCode.Count - 1;
  11187. var startCity = IndexSelect.Substring(0, 3);
  11188. if (cityArrCodeLength > 0)
  11189. {
  11190. var arrEndCity = cityArrCode[cityArrCodeLength];
  11191. if (arrEndCity != startCity)
  11192. {
  11193. cityArrCode.Add(startCity.ToUpper());
  11194. }
  11195. }
  11196. else
  11197. {
  11198. cityArrCode.Add(startCity.ToUpper());
  11199. }
  11200. var endCity = IndexSelect.Substring(3, 3);
  11201. cityArrCode.Add(endCity.ToUpper());
  11202. }
  11203. var cityThree = string.Empty;
  11204. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11205. cityThree = cityThree.TrimEnd(',');
  11206. if (string.IsNullOrWhiteSpace(cityThree))
  11207. {
  11208. throw new
  11209. Exception("error");
  11210. }
  11211. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11212. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11213. foreach (var item in cityArrCode)
  11214. {
  11215. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11216. if (find != null)
  11217. {
  11218. city += find.City + "/";
  11219. }
  11220. else
  11221. {
  11222. city += item + "三字码未收入/";
  11223. }
  11224. }
  11225. city = city.TrimEnd('/');
  11226. }
  11227. catch (Exception e)
  11228. {
  11229. city = "黑屏代码格式不正确!";
  11230. }
  11231. }
  11232. }
  11233. else
  11234. {
  11235. city = "未录入黑屏代码";
  11236. }
  11237. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11238. {
  11239. Date = x.Date,
  11240. Days = x.Days,
  11241. Diffgroup = x.Diffgroup,
  11242. Diid = x.Diid,
  11243. Traffic_First = x.Traffic_First,
  11244. Traffic_Second = x.Traffic_Second,
  11245. Trip = x.Trip,
  11246. WeekDay = x.WeekDay,
  11247. Id = x.Id
  11248. }).ToList();
  11249. jw.Data = new
  11250. {
  11251. groupList = groupList.Select(x => new
  11252. {
  11253. x.Id,
  11254. x.TeamName,
  11255. x.TourCode
  11256. }).ToList(),
  11257. groupInfo = new
  11258. {
  11259. group.VisitDays,
  11260. group.TourCode,
  11261. group.VisitPNumber,
  11262. group.TeamName,
  11263. city
  11264. },
  11265. OpTravelList
  11266. };
  11267. jw.Code = 200;
  11268. jw.Msg = "操作成功!";
  11269. return Ok(jw);
  11270. }
  11271. /// <summary>
  11272. /// 删除团组行程单
  11273. /// </summary>
  11274. /// <returns></returns>
  11275. [HttpPost]
  11276. public IActionResult DelTravel(DelOpTravelDto dto)
  11277. {
  11278. var jw = JsonView(false);
  11279. if (dto.UserId <= 0 || dto.Diid <= 0)
  11280. {
  11281. jw.Msg = "请输入正确的参数!";
  11282. return Ok(jw);
  11283. }
  11284. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11285. .SetColumns(x => new Grp_TravelList
  11286. {
  11287. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11288. DeleteUserId = dto.UserId,
  11289. IsDel = 1,
  11290. }).ExecuteCommand();
  11291. jw = JsonView(true);
  11292. return Ok(jw);
  11293. }
  11294. /// <summary>
  11295. /// 行程单保存
  11296. /// </summary>
  11297. /// <returns></returns>
  11298. [HttpPost]
  11299. public IActionResult TravelSave(TravelSaveDto dto)
  11300. {
  11301. var jw = JsonView(false);
  11302. if (dto.Arr.Count > 0)
  11303. {
  11304. try
  11305. {
  11306. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11307. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11308. .ToList();
  11309. _sqlSugar.BeginTran();
  11310. foreach (var item in dto.Arr)
  11311. {
  11312. if (item.Id == 0)
  11313. {
  11314. throw new Exception("请传入正确的Id");
  11315. }
  11316. //比较上一次的差异
  11317. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11318. if (findTravel != null)
  11319. {
  11320. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11321. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11322. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11323. }
  11324. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11325. .SetColumns(x => new Grp_TravelList
  11326. {
  11327. Trip = item.Trip
  11328. }).ExecuteCommand();
  11329. }
  11330. _sqlSugar.CommitTran();
  11331. jw = JsonView(true);
  11332. }
  11333. catch (Exception ex)
  11334. {
  11335. _sqlSugar.RollbackTran();
  11336. jw.Msg = "程序异常!" + ex.Message;
  11337. }
  11338. }
  11339. else
  11340. {
  11341. jw.Msg = "请传入正确的参数!";
  11342. }
  11343. return Ok(jw);
  11344. }
  11345. private string CheckStr(string original, string changed)
  11346. {
  11347. // 创建diff_match_patch对象
  11348. var dmp = new diff_match_patch();
  11349. // 计算差异
  11350. List<Diff> diffs = dmp.diff_main(original, changed);
  11351. // 清理和合并差异
  11352. dmp.diff_cleanupSemantic(diffs);
  11353. // 使用StringBuilder构建最终的字符串
  11354. StringBuilder finalString = new StringBuilder();
  11355. // 输出差异结果,并构建变动后的字符串
  11356. foreach (Diff diff in diffs)
  11357. {
  11358. switch (diff.operation)
  11359. {
  11360. case Operation.EQUAL:
  11361. // 相等的部分,直接添加到最终字符串
  11362. finalString.Append(diff.text);
  11363. break;
  11364. case Operation.INSERT:
  11365. // 插入的部分,添加标记并添加到最终字符串
  11366. finalString.Append("[++]" + diff.text + "[++]");
  11367. break;
  11368. case Operation.DELETE:
  11369. // 删除的部分,不添加到最终字符串
  11370. //finalString.Append("[++]" + diff.text + "[++]");
  11371. break;
  11372. }
  11373. }
  11374. // 输出变动后的字符串
  11375. return finalString.ToString();
  11376. }
  11377. private class tagContent
  11378. {
  11379. public DateTime Date { get; set; }
  11380. public string StartTag { get; set; }
  11381. public string EndTag { get; set; }
  11382. public string Content { get; set; }
  11383. public static int tagLength { get { return 3; } }
  11384. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11385. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11386. public bool IsFinally { get; set; }
  11387. }
  11388. private List<string> ExtractContentBetweenTags(string input, string tag)
  11389. {
  11390. List<string> results = new List<string>();
  11391. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11392. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11393. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11394. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11395. string[] strValueArr = new string[1];
  11396. foreach (System.Text.RegularExpressions.Match match in matches)
  11397. {
  11398. var strValue = match.Groups[1].Value;
  11399. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11400. }
  11401. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11402. return results;
  11403. }
  11404. /// <summary>
  11405. /// 导出行程单
  11406. /// </summary>
  11407. /// <param name="dto"></param>
  11408. /// <returns></returns>
  11409. [HttpPost]
  11410. public IActionResult ExportTravel(ExportTravelDto dto)
  11411. {
  11412. var jw = JsonView(false);
  11413. jw.Data = "";
  11414. int diid = 0;
  11415. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11416. if (Find == null)
  11417. {
  11418. jw.Msg = "请选择正确的团组!";
  11419. return Ok(jw);
  11420. }
  11421. else
  11422. {
  11423. diid = Find.Id;
  11424. }
  11425. //数据源
  11426. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11427. DataTable dtBlack = null;
  11428. try
  11429. {
  11430. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11431. }
  11432. catch (Exception)
  11433. {
  11434. jw.Msg = "机票黑屏代码有误!";
  11435. return Ok(jw);
  11436. }
  11437. string CityStr = string.Empty;
  11438. if (dtBlack.Rows.Count == 0)
  11439. {
  11440. jw.Msg = "机票黑屏代码有误!";
  11441. return Ok(jw);
  11442. }
  11443. else
  11444. {
  11445. foreach (DataRow row in dtBlack.Rows)
  11446. {
  11447. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11448. {
  11449. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11450. return Ok(jw);
  11451. }
  11452. }
  11453. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11454. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11455. }
  11456. // 指定的文字
  11457. var targetTextDic = new Dictionary<string, List<string>>();
  11458. //创建数据源Table
  11459. DataTable dtSource = new DataTable();
  11460. dtSource.Columns.Add("Days", typeof(string));
  11461. dtSource.Columns.Add("Date", typeof(string));
  11462. dtSource.Columns.Add("Week", typeof(string));
  11463. dtSource.Columns.Add("Traffic", typeof(string));
  11464. dtSource.Columns.Add("Trip", typeof(string));
  11465. //获取数据,放到datatable
  11466. foreach (var item in _travelList)
  11467. {
  11468. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11469. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11470. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11471. .Replace("[++]", string.Empty);
  11472. DataRow dr = dtSource.NewRow();
  11473. dr["Days"] = item.Days;
  11474. dr["Date"] = item.Date;
  11475. dr["Week"] = item.WeekDay;
  11476. dr["Traffic"] = item.Traffic_First
  11477. + "\r\n"
  11478. + item.Traffic_Second;
  11479. dr["Trip"] = item.Trip;
  11480. dtSource.Rows.Add(dr);
  11481. }
  11482. Dictionary<string, string> dic = new Dictionary<string, string>();
  11483. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11484. dic.Add("City", CityStr);
  11485. dic.Add("Days", Find.VisitDays.ToString());
  11486. dic.Add("DeleCode", Find.TourCode);
  11487. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11488. //模板路径
  11489. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11490. //载入模板
  11491. Document doc = null;
  11492. DocumentBuilder builder = null;
  11493. try
  11494. {
  11495. //载入模板
  11496. doc = new Document(tempPath);
  11497. builder = new DocumentBuilder(doc);
  11498. }
  11499. catch (Exception)
  11500. {
  11501. jw.Msg = "模板位置不存在!";
  11502. return Ok(jw);
  11503. }
  11504. foreach (var key in dic.Keys)
  11505. {
  11506. Bookmark bookmark = doc.Range.Bookmarks[key];
  11507. if (bookmark != null)
  11508. {
  11509. builder.MoveToBookmark(key);
  11510. builder.Write(dic[key]);
  11511. }
  11512. }
  11513. //获取word里所有表格
  11514. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11515. //获取所填表格的序数
  11516. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11517. try
  11518. {
  11519. //循环赋值
  11520. for (int i = 0; i < dtSource.Rows.Count; i++)
  11521. {
  11522. builder.MoveToCell(0, i + 1, 0, 0);
  11523. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11524. builder.MoveToCell(0, i + 1, 1, 0);
  11525. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11526. builder.MoveToCell(0, i + 1, 2, 0);
  11527. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11528. var trip = dtSource.Rows[i]["Trip"].ToString();
  11529. builder.MoveToCell(0, i + 1, 3, 0);
  11530. builder.Write(trip);
  11531. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11532. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11533. // 获取特定索引的段落
  11534. Paragraph paragraph = (Paragraph)paragraphs[0];
  11535. Run run = paragraph.Runs[0];
  11536. Aspose.Words.Font font = run.Font;
  11537. font.Name = "黑体";
  11538. //设置双休红色
  11539. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11540. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11541. paragraph = (Paragraph)paragraphs[1];
  11542. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11543. {
  11544. run = paragraph.Runs[0];
  11545. font = run.Font;
  11546. font.Color = Color.Red;
  11547. }
  11548. }
  11549. }
  11550. catch (Exception ex)
  11551. {
  11552. }
  11553. //删除多余行
  11554. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11555. {
  11556. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11557. }
  11558. var targetTextList = new List<string>();
  11559. // 遍历文档中的表格
  11560. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11561. {
  11562. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11563. {
  11564. var cellIndex = 0;
  11565. foreach (Cell cell in row.Cells)
  11566. {
  11567. if (cellIndex == 1 && row.Cells.Count == 4)
  11568. {
  11569. foreach (var target in targetTextDic.Keys)
  11570. {
  11571. if (cell.GetText().Contains(target))
  11572. {
  11573. targetTextList = targetTextDic[target];
  11574. break;
  11575. }
  11576. }
  11577. }
  11578. // 遍历单元格中的所有段落
  11579. foreach (Paragraph paragraph in cell.Paragraphs)
  11580. {
  11581. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11582. List<Run> runs = new List<Run>();
  11583. foreach (Run run in paragraph.Runs)
  11584. {
  11585. runs.Add(run);
  11586. }
  11587. foreach (Run run in runs)
  11588. {
  11589. foreach (var targetText in targetTextList)
  11590. {
  11591. // 检查文字是否包含指定文字
  11592. if (run.Text.Contains(targetText))
  11593. {
  11594. // 将包含的部分设置为红色
  11595. HighlightText(run, targetText, Color.Red);
  11596. }
  11597. }
  11598. }
  11599. }
  11600. cellIndex++;
  11601. }
  11602. }
  11603. }
  11604. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11605. if (!Directory.Exists(savePath))
  11606. {
  11607. try
  11608. {
  11609. Directory.CreateDirectory(savePath);
  11610. }
  11611. catch
  11612. {
  11613. }
  11614. }
  11615. string path = savePath + Find.TeamName + "出访日程";
  11616. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11617. try
  11618. {
  11619. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11620. string postfix = ".docx";
  11621. if (dto.IsPDF == 1)
  11622. {
  11623. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11624. postfix = ".pdf";
  11625. }
  11626. doc.Save(path + postfix, saveFormat);
  11627. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11628. }
  11629. catch (Exception)
  11630. {
  11631. jw = JsonView(false);
  11632. }
  11633. return Ok(jw);
  11634. }
  11635. /// <summary>
  11636. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11637. /// </summary>
  11638. /// <param name="num"></param>
  11639. /// <returns></returns>
  11640. string GetNum(string num)
  11641. {
  11642. string str = "";
  11643. switch (num)
  11644. {
  11645. case "1":
  11646. str = "一";
  11647. break;
  11648. case "2":
  11649. str = "二";
  11650. break;
  11651. case "3":
  11652. str = "三";
  11653. break;
  11654. case "4":
  11655. str = "四";
  11656. break;
  11657. case "5":
  11658. str = "五";
  11659. break;
  11660. case "6":
  11661. str = "六";
  11662. break;
  11663. case "7":
  11664. str = "七";
  11665. break;
  11666. case "8":
  11667. str = "八";
  11668. break;
  11669. case "9":
  11670. str = "九";
  11671. break;
  11672. case "10":
  11673. str = "十";
  11674. break;
  11675. case "11":
  11676. str = "十一";
  11677. break;
  11678. case "12":
  11679. str = "十二";
  11680. break;
  11681. case "一":
  11682. str = "1";
  11683. break;
  11684. case "二":
  11685. str = "2";
  11686. break;
  11687. case "三":
  11688. str = "3";
  11689. break;
  11690. case "四":
  11691. str = "4";
  11692. break;
  11693. case "五":
  11694. str = "5";
  11695. break;
  11696. case "六":
  11697. str = "6";
  11698. break;
  11699. case "七":
  11700. str = "7";
  11701. break;
  11702. case "八":
  11703. str = "8";
  11704. break;
  11705. case "九":
  11706. str = "9";
  11707. break;
  11708. case "十":
  11709. str = "10";
  11710. break;
  11711. case "十一":
  11712. str = "11";
  11713. break;
  11714. case "十二":
  11715. str = "12";
  11716. break;
  11717. }
  11718. return str;
  11719. }
  11720. // 高亮包含指定文字的部分
  11721. void HighlightText(Run run, string targetText, Color color)
  11722. {
  11723. string text = run.Text;
  11724. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11725. if (startIndex >= 0)
  11726. {
  11727. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11728. // 前部分
  11729. if (startIndex > 0)
  11730. {
  11731. Run beforeRun = (Run)run.Clone(true);
  11732. beforeRun.Text = text.Substring(0, startIndex);
  11733. parentParagraph.InsertBefore(beforeRun, run);
  11734. }
  11735. // 匹配部分
  11736. Run matchRun = (Run)run.Clone(true);
  11737. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11738. matchRun.Font.Color = color;
  11739. parentParagraph.InsertBefore(matchRun, run);
  11740. // 后部分
  11741. if (startIndex + targetText.Length < text.Length)
  11742. {
  11743. Run afterRun = (Run)run.Clone(true);
  11744. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11745. parentParagraph.InsertBefore(afterRun, run);
  11746. }
  11747. // 删除原始Run
  11748. run.Remove();
  11749. }
  11750. }
  11751. #endregion
  11752. #endregion
  11753. #region 团组成本
  11754. /// <summary>
  11755. /// 团组成本数据初始化
  11756. /// </summary>
  11757. /// <param name="dto"></param>
  11758. /// <returns></returns>
  11759. [HttpPost]
  11760. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11761. {
  11762. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11763. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11764. WHEN COUNT(*) >= 0 THEN 'True'
  11765. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11766. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11767. ").ToList(); //团组列表
  11768. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11769. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11770. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11771. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11772. if (groupinfoValue != null)
  11773. {
  11774. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11775. var spArr = new string[1] { countryArr };
  11776. if (countryArr.Contains("|"))
  11777. {
  11778. spArr = countryArr.Split("|");
  11779. }
  11780. else if (countryArr.Contains("、"))
  11781. {
  11782. spArr = countryArr.Split("、");
  11783. }
  11784. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11785. {
  11786. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11787. if (dbQueryCountry != null)
  11788. {
  11789. visaCountryInfoArr.Add(dbQueryCountry);
  11790. }
  11791. }
  11792. }
  11793. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11794. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11795. var create = _GroupCostRepository.
  11796. CreateGroupCostByBlackCode(dto.Diid);
  11797. if (groupCost.Count == 0 && create.Code == 0)
  11798. {
  11799. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11800. }
  11801. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11802. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11803. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11804. groupCostMap = groupCostMap.Select(x =>
  11805. {
  11806. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11807. {
  11808. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11809. }
  11810. return x;
  11811. }).ToList();
  11812. //GroupCostParameter.Add(new
  11813. // Grp_GroupCostParameter());
  11814. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11815. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11816. return Ok(JsonView(new
  11817. {
  11818. groupList,
  11819. groupInfo,
  11820. groupChecks,
  11821. groupCost = groupCostMap,
  11822. hotelNumber,
  11823. GroupCostParameter = GroupCostParameterMap,
  11824. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11825. {
  11826. x.VisaCountry,
  11827. x.VisaPrice,
  11828. x.Id,
  11829. }).ToList(),
  11830. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11831. blackCodeIsTrue = create.Code == 0 ? true : false,
  11832. hotelIsTrue = hotelIsTrue,
  11833. }));
  11834. }
  11835. /// <summary>
  11836. /// 团组成本信息保存
  11837. /// </summary>
  11838. /// <param name="dto"></param>
  11839. /// <returns></returns>
  11840. [HttpPost]
  11841. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11842. {
  11843. if (dto.Diid <= 0 || dto.Userid <= 0)
  11844. {
  11845. return Ok(JsonView(false));
  11846. }
  11847. JsonView jw = null;
  11848. bool isTrue = false;
  11849. #region 复制团组成本
  11850. //if (dto.Diid == 2581)
  11851. //{
  11852. // dto.Diid = 2599;
  11853. // dto.CheckBoxs.ForEach(x =>
  11854. // {
  11855. // x.Diid = 2599;
  11856. // });
  11857. // dto.GroupCosts.ForEach(x =>
  11858. // {
  11859. // x.Diid = 2599;
  11860. // });
  11861. // dto.CostTypeHotelNumbers.ForEach(x =>
  11862. // {
  11863. // x.Diid = 2599;
  11864. // });
  11865. // dto.GroupCostParameters.ForEach(x =>
  11866. // {
  11867. // x.DiId = 2599;
  11868. // });
  11869. //}
  11870. #endregion
  11871. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11872. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11873. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11874. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11875. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11876. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11877. try
  11878. {
  11879. _sqlSugar.BeginTran();
  11880. isTrue = await _GroupCostRepository.
  11881. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11882. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11883. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11884. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11885. _sqlSugar.CommitTran();
  11886. jw = JsonView(true, "保存成功!", isTrue);
  11887. }
  11888. catch (Exception)
  11889. {
  11890. _sqlSugar.RollbackTran();
  11891. jw = JsonView(false);
  11892. }
  11893. return Ok(jw);
  11894. }
  11895. /// <summary>
  11896. /// 司兼导数据
  11897. /// </summary>
  11898. /// <param name="dto"></param>
  11899. /// <returns></returns>
  11900. [HttpPost]
  11901. public IActionResult GetCarGuides(CarGuidesDto dto)
  11902. {
  11903. JsonView jw = null;
  11904. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11905. jw = JsonView(true, "获取成功!", Data);
  11906. return Ok(jw);
  11907. }
  11908. /// <summary>
  11909. /// 导游数据
  11910. /// </summary>
  11911. /// <param name="dto"></param>
  11912. /// <returns></returns>
  11913. [HttpPost]
  11914. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11915. {
  11916. JsonView jw = null;
  11917. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11918. // 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
  11919. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11920. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11921. jw = JsonView(true, "获取成功!", Data);
  11922. return Ok(jw);
  11923. }
  11924. /// <summary>
  11925. /// 成本车数据
  11926. /// </summary>
  11927. /// <param name="dto"></param>
  11928. /// <returns></returns>
  11929. [HttpPost]
  11930. public IActionResult GetCarInfo(CarGuidesDto dto)
  11931. {
  11932. JsonView jw = null;
  11933. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11934. jw = JsonView(true, "获取成功!", Data);
  11935. return Ok(jw);
  11936. }
  11937. /// <summary>
  11938. /// 景点数据
  11939. /// </summary>
  11940. /// <param name="dto"></param>
  11941. /// <returns></returns>
  11942. [HttpPost]
  11943. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11944. {
  11945. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11946. return Ok(JsonView(true, "获取成功!", Data));
  11947. }
  11948. /// <summary>
  11949. /// 成本通知
  11950. /// </summary>
  11951. /// <param name="dto"></param>
  11952. /// <returns></returns>
  11953. [HttpPost]
  11954. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11955. {
  11956. if (dto.Diid < 0)
  11957. {
  11958. return Ok(JsonView(false));
  11959. }
  11960. JsonView jw = null;
  11961. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11962. if (GroupCostParameter != null)
  11963. {
  11964. int IsShare = 0;
  11965. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11966. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11967. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11968. string msg = string.Empty;
  11969. if (isTrue)
  11970. {
  11971. if (IsShare == 0)
  11972. {
  11973. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11974. }
  11975. else
  11976. {
  11977. #region 企微通知对应岗位用户
  11978. try
  11979. {
  11980. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11981. }
  11982. catch (Exception ex)
  11983. {
  11984. }
  11985. #endregion
  11986. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11987. }
  11988. jw = JsonView(isTrue, msg, new { IsShare });
  11989. }
  11990. else
  11991. {
  11992. msg = "修改失败!";
  11993. jw = JsonView(isTrue, msg);
  11994. }
  11995. }
  11996. else
  11997. {
  11998. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11999. }
  12000. return Ok(jw);
  12001. }
  12002. /// <summary>
  12003. /// 导出报价单
  12004. /// </summary>
  12005. /// <param name="dto"></param>
  12006. /// <returns></returns>
  12007. [HttpPost]
  12008. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12009. {
  12010. if (dto.Diid == 0)
  12011. {
  12012. return Ok(JsonView(false, "请传递团组id"));
  12013. }
  12014. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12015. if (deleInfo.Code != 0)
  12016. {
  12017. return Ok(JsonView(false, "团组信息查询失败!"));
  12018. }
  12019. var di = deleInfo.Data as DelegationInfoWebView;
  12020. if (di != null)
  12021. {
  12022. di.TeamName = di.TeamName.Replace("|", "、");
  12023. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12024. //文件名
  12025. string strFileName = di.TeamName + "-收款账单.doc";
  12026. //获取模板
  12027. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12028. //载入模板
  12029. Document doc = new Document(tmppath);
  12030. decimal TotalPrice = 0.00M;
  12031. string itemStr = string.Empty;
  12032. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12033. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12034. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12035. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12036. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12037. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12038. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12039. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12040. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12041. foreach (var cost in groupCostType)
  12042. {
  12043. var List = cost.ToList();
  12044. if (cost.Key == "A")
  12045. {
  12046. foreach (var ListItem in List)
  12047. {
  12048. if (ListItem.number > 0)
  12049. {
  12050. if (ListItem.code.Contains("TBR"))
  12051. {
  12052. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12053. }
  12054. else
  12055. {
  12056. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12057. }
  12058. TotalPrice += (ListItem.number * ListItem.price);
  12059. }
  12060. }
  12061. }
  12062. else
  12063. {
  12064. itemStr = itemStr.Insert(0, "A段\r\n");
  12065. itemStr += "B段\r\n";
  12066. foreach (var ListItem in List)
  12067. {
  12068. if (ListItem.number > 0)
  12069. {
  12070. if (ListItem.code.Contains("TBR"))
  12071. {
  12072. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12073. }
  12074. else
  12075. {
  12076. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12077. }
  12078. TotalPrice += (ListItem.number * ListItem.price);
  12079. }
  12080. }
  12081. }
  12082. }
  12083. #region 替换Word模板书签内容
  12084. Dictionary<string, string> marks = new Dictionary<string, string>();
  12085. marks.Add("To", di.ClientUnit);//付款方
  12086. marks.Add("ToTel", di.TellPhone);//付款方电话
  12087. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12088. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12089. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12090. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12091. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12092. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12093. marks.Add("PayItemContent", itemStr);//详细信息
  12094. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12095. #endregion
  12096. ////注
  12097. //if (doc.Range.Bookmarks["Attention"] != null)
  12098. //{
  12099. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12100. // mark.Text = frList[0].Attention;
  12101. //}
  12102. foreach (var item in marks.Keys)
  12103. {
  12104. if (doc.Range.Bookmarks[item] != null)
  12105. {
  12106. Bookmark mark = doc.Range.Bookmarks[item];
  12107. mark.Text = marks[item];
  12108. }
  12109. }
  12110. byte[] bytes = null;
  12111. using (MemoryStream stream = new MemoryStream())
  12112. {
  12113. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12114. bytes = stream.ToArray();
  12115. }
  12116. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12117. return Ok(JsonView(true, "", new
  12118. {
  12119. Data = bytes,
  12120. strFileName,
  12121. }));
  12122. }
  12123. else
  12124. {
  12125. return Ok(JsonView(false, "团组信息不存在!"));
  12126. }
  12127. }
  12128. /// <summary>
  12129. /// 导出团组成本
  12130. /// </summary>
  12131. /// <param name="dto"></param>
  12132. /// <returns></returns>
  12133. [HttpPost]
  12134. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12135. {
  12136. var jw = JsonView(false);
  12137. if (dto.Diid == 0)
  12138. {
  12139. return Ok(JsonView(false, "请传递团组id"));
  12140. }
  12141. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12142. if (deleInfo.Code != 0)
  12143. {
  12144. return Ok(JsonView(false, "团组信息查询失败!"));
  12145. }
  12146. var di = deleInfo.Data as DelegationInfoWebView;
  12147. if (di == null)
  12148. {
  12149. return Ok(JsonView(false, "团组信息查询失败!"));
  12150. }
  12151. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12152. WorkbookDesigner designer = new WorkbookDesigner();
  12153. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12154. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12155. for (int i = 0; i < List_GC.Count; i++)
  12156. {
  12157. GroupCost_Excel gc = new GroupCost_Excel();
  12158. gc.Id = List_GC[i].Id;
  12159. gc.Diid = List_GC[i].Diid.ToString();
  12160. gc.DAY = List_GC[i].DAY;
  12161. string week = "";
  12162. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12163. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12164. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12165. gc.ITIN = List_GC[i].ITIN;
  12166. gc.CarType = List_GC[i].CarType;
  12167. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12168. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12169. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12170. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12171. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12172. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12173. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12174. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12175. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12176. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12177. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12178. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12179. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12180. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12181. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12182. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12183. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12184. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12185. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12186. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12187. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12188. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12189. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12190. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12191. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12192. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12193. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12194. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12195. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12196. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12197. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12198. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12199. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12200. List_GC1.Add(gc);
  12201. }
  12202. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12203. dt.TableName = "TB";
  12204. //报表标题等不用dt的值
  12205. designer.SetDataSource("TeamName", dto.title.TeamName);
  12206. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12207. designer.SetDataSource("Tax", dto.title.Tax);
  12208. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12209. designer.SetDataSource("Currency", dto.title.Currency);
  12210. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12211. designer.SetDataSource("Rate", dto.title.Rate);
  12212. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12213. var Aparams = hotels.Find(x => x.Type == "Default");
  12214. if (Aparams == null)
  12215. {
  12216. return Ok(jw);
  12217. }
  12218. //酒店数量
  12219. var txtSGRNumber = Aparams.SGR.ToString();
  12220. var txtTBRNumber = Aparams.TBR.ToString();
  12221. var txtJSESNumber = Aparams.JSES.ToString();
  12222. var txtSUITENumbe = Aparams.SUITE.ToString();
  12223. if (dto.costType == "B")
  12224. {
  12225. Aparams = hotels.Find(x => x.Type == "A");
  12226. var Bparams = hotels.Find(x => x.Type == "B");
  12227. if (Aparams == null || Bparams == null)
  12228. {
  12229. return Ok(jw);
  12230. }
  12231. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12232. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12233. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12234. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12235. }
  12236. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12237. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12238. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12239. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12240. var ws = designer.Workbook.Worksheets[0];
  12241. int Row = List_GC.Count;
  12242. int startIndex = 11;
  12243. int HideRows = 0;
  12244. List<int> hideRowsList = new List<int>();
  12245. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12246. #region A段left数据
  12247. var left = dto.leftInfo.Find(x => x.Type == "A");
  12248. if (left == null)
  12249. {
  12250. return Ok(jw);
  12251. }
  12252. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12253. if (leftBindData != null)
  12254. {
  12255. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12256. designer.SetDataSource("VisaRS", leftBindData.rs);
  12257. designer.SetDataSource("VisaXS", leftBindData.xs);
  12258. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12259. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12260. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12261. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12262. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12263. }
  12264. else
  12265. {
  12266. hideRowsList.Add(Row + startIndex + HideRows);
  12267. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12268. }
  12269. HideRows += 2;
  12270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12271. if (leftBindData != null)
  12272. {
  12273. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12274. designer.SetDataSource("BXRS", leftBindData.rs);
  12275. designer.SetDataSource("BXXS", leftBindData.xs);
  12276. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12277. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12278. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12279. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12280. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12281. }
  12282. else
  12283. {
  12284. hideRowsList.Add(Row + startIndex + HideRows);
  12285. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12286. }
  12287. HideRows += 2;
  12288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12289. if (leftBindData != null)
  12290. {
  12291. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12292. designer.SetDataSource("HSRS", leftBindData.rs);
  12293. designer.SetDataSource("HSXS", leftBindData.xs);
  12294. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12295. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12296. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12297. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12298. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12299. }
  12300. else
  12301. {
  12302. hideRowsList.Add(Row + startIndex + HideRows);
  12303. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12304. }
  12305. HideRows += 2;
  12306. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12307. if (leftBindData != null)
  12308. {
  12309. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12310. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12311. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12312. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12313. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12314. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12315. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12316. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12317. }
  12318. else
  12319. {
  12320. hideRowsList.Add(Row + startIndex + HideRows);
  12321. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12322. }
  12323. HideRows += 2;
  12324. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12325. if (leftBindData != null)
  12326. {
  12327. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12328. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12329. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12330. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12331. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12332. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12333. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12334. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12335. }
  12336. else
  12337. {
  12338. hideRowsList.Add(Row + startIndex + HideRows);
  12339. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12340. }
  12341. HideRows += 2;
  12342. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12343. if (leftBindData != null)
  12344. {
  12345. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12346. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12347. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12348. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12349. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12350. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12351. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12352. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12353. }
  12354. else
  12355. {
  12356. hideRowsList.Add(Row + startIndex + HideRows);
  12357. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12358. }
  12359. HideRows += 2;
  12360. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12361. if (leftBindData != null)
  12362. {
  12363. ////TBR
  12364. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12365. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12366. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12367. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12368. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12369. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12370. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12371. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12372. }
  12373. else
  12374. {
  12375. hideRowsList.Add(Row + startIndex + HideRows);
  12376. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12377. }
  12378. HideRows += 2;
  12379. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12380. if (leftBindData != null)
  12381. {
  12382. ////SGR
  12383. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12384. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12385. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12386. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12387. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12388. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12389. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12390. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12391. }
  12392. else
  12393. {
  12394. hideRowsList.Add(Row + startIndex + HideRows);
  12395. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12396. }
  12397. HideRows += 2;
  12398. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12399. if (leftBindData != null)
  12400. {
  12401. ////JS/ES
  12402. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12403. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12404. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12405. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12406. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12407. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12408. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12409. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12410. }
  12411. else
  12412. {
  12413. hideRowsList.Add(Row + startIndex + HideRows);
  12414. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12415. }
  12416. HideRows += 2;
  12417. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12418. if (leftBindData != null)
  12419. {
  12420. ////SUITE
  12421. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12422. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12423. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12424. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12425. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12426. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12427. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12428. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12429. }
  12430. else
  12431. {
  12432. hideRowsList.Add(Row + startIndex + HideRows);
  12433. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12434. }
  12435. HideRows += 2;
  12436. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12437. if (leftBindData != null)
  12438. {
  12439. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12440. designer.SetDataSource("DJRS", leftBindData.rs);
  12441. designer.SetDataSource("DJXS", leftBindData.xs);
  12442. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12443. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12444. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12445. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12446. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12447. }
  12448. else
  12449. {
  12450. hideRowsList.Add(Row + startIndex + HideRows);
  12451. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12452. }
  12453. HideRows += 2;
  12454. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12455. if (leftBindData != null)
  12456. {
  12457. designer.SetDataSource("HCPCB", leftBindData.cb);
  12458. designer.SetDataSource("HCPRS", leftBindData.rs);
  12459. designer.SetDataSource("HCPXS", leftBindData.xs);
  12460. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12461. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12462. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12463. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12464. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12465. }
  12466. else
  12467. {
  12468. hideRowsList.Add(Row + startIndex + HideRows);
  12469. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12470. }
  12471. HideRows += 2;
  12472. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12473. if (leftBindData != null)
  12474. {
  12475. designer.SetDataSource("CPCB", leftBindData.cb);
  12476. designer.SetDataSource("CPRS", leftBindData.rs);
  12477. designer.SetDataSource("CPXS", leftBindData.xs);
  12478. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12479. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12480. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12481. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12482. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12483. }
  12484. else
  12485. {
  12486. hideRowsList.Add(Row + startIndex + HideRows);
  12487. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12488. }
  12489. HideRows += 2;
  12490. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12491. if (leftBindData != null)
  12492. {
  12493. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12494. designer.SetDataSource("GWRS", leftBindData.rs);
  12495. designer.SetDataSource("GWXS", leftBindData.xs);
  12496. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12497. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12498. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12499. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12500. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12501. }
  12502. else
  12503. {
  12504. hideRowsList.Add(Row + startIndex + HideRows);
  12505. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12506. }
  12507. HideRows += 2;
  12508. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12509. if (leftBindData != null)
  12510. {
  12511. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12512. designer.SetDataSource("LYJRS", leftBindData.rs);
  12513. designer.SetDataSource("LYJXS", leftBindData.xs);
  12514. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12515. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12516. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12517. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12518. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12519. }
  12520. else
  12521. {
  12522. hideRowsList.Add(Row + startIndex + HideRows);
  12523. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12524. }
  12525. #endregion
  12526. #region A段Right信息
  12527. var right = dto.rightInfo.Find(x => x.Type == "A");
  12528. if (right == null)
  12529. {
  12530. return Ok(jw);
  12531. }
  12532. HideRows += 4;
  12533. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12534. if (rightBindData != null)
  12535. {
  12536. //经济舱 + 双人间 TBR
  12537. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12538. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12539. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12540. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12541. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12542. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12543. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12544. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12545. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12546. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12547. }
  12548. else
  12549. {
  12550. hideRowsList.Add(Row + startIndex + HideRows);
  12551. }
  12552. HideRows += 2;
  12553. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12554. if (rightBindData != null)
  12555. {
  12556. //经济舱 + 单人间 SGR
  12557. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12558. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12559. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12560. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12561. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12562. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12563. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12564. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12565. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12566. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12567. }
  12568. else
  12569. {
  12570. hideRowsList.Add(Row + startIndex + HideRows);
  12571. }
  12572. HideRows += 2;
  12573. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12574. if (rightBindData != null)
  12575. {
  12576. //公务舱 + 单人间 SGR
  12577. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12578. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12579. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12580. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12581. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12582. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12583. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12584. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12585. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12586. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12587. }
  12588. else
  12589. {
  12590. hideRowsList.Add(Row + startIndex + HideRows);
  12591. }
  12592. HideRows += 2;
  12593. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12594. if (rightBindData != null)
  12595. {
  12596. //公务舱 + 小套房 JSES
  12597. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12598. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12599. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12600. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12601. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12602. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12603. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12604. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12605. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12606. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12607. }
  12608. else
  12609. {
  12610. hideRowsList.Add(Row + startIndex + HideRows);
  12611. }
  12612. HideRows += 2;
  12613. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12614. if (rightBindData != null)
  12615. {
  12616. //公务舱 + 小套房 JSES
  12617. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12618. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12619. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12620. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12621. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12622. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12623. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12624. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12625. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12626. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12627. }
  12628. else
  12629. {
  12630. hideRowsList.Add(Row + startIndex + HideRows);
  12631. }
  12632. HideRows += 2;
  12633. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12634. if (rightBindData != null)
  12635. {
  12636. //经济舱 + 大套房
  12637. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12638. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12639. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12640. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12641. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12642. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12643. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12644. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12645. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12646. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12647. }
  12648. else
  12649. {
  12650. hideRowsList.Add(Row + startIndex + HideRows);
  12651. }
  12652. HideRows += 2;
  12653. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12654. if (rightBindData != null)
  12655. {
  12656. //头等舱 + 小套房 JSES
  12657. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12658. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12659. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12660. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12661. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12662. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12663. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12664. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12665. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12666. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12667. }
  12668. else
  12669. {
  12670. hideRowsList.Add(Row + startIndex + HideRows);
  12671. }
  12672. HideRows += 2;
  12673. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12674. if (rightBindData != null)
  12675. {
  12676. //头等舱 + 大套房
  12677. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12678. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12679. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12680. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12681. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12682. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12683. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12684. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12685. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12686. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12687. }
  12688. else
  12689. {
  12690. hideRowsList.Add(Row + startIndex + HideRows);
  12691. }
  12692. #endregion
  12693. #region B段标题清空
  12694. designer.SetDataSource("CostBDRCB", "");
  12695. designer.SetDataSource("CostBRS", "");
  12696. designer.SetDataSource("CostBXS", "");
  12697. designer.SetDataSource("CostBZCB", "");
  12698. designer.SetDataSource("CostBDRBJ", "");
  12699. designer.SetDataSource("CostBZBJ", "");
  12700. designer.SetDataSource("CostBDRLR", "");
  12701. designer.SetDataSource("CostBZLR", "");
  12702. designer.SetDataSource("CostBDRCBOM", "");
  12703. designer.SetDataSource("CostBRSOM", "");
  12704. designer.SetDataSource("CostBZCBOM", "");
  12705. designer.SetDataSource("CostBDRBJOM", "");
  12706. designer.SetDataSource("CostBZBJOM", "");
  12707. designer.SetDataSource("CostBDRLROM", "");
  12708. designer.SetDataSource("CostBZLROM", "");
  12709. #endregion
  12710. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12711. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12712. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12713. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12714. designer.SetDataSource("DJName", "地接(CNY)");
  12715. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12716. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12717. designer.SetDataSource("GWName", "公务(CNY)");
  12718. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12719. designer.SetDataSource("LYJName", "零用金(CNY)");
  12720. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12721. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12722. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12723. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12724. designer.SetDataSource("BXName", "保险(CNY)");
  12725. designer.SetDataSource("VisaName", "签证(CNY)");
  12726. #region B段基本数据
  12727. if (dto.costType == "B")
  12728. {
  12729. left = dto.leftInfo.Find(x => x.Type == "B");
  12730. if (left == null)
  12731. {
  12732. return Ok(jw);
  12733. }
  12734. #region B段left数据
  12735. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12736. if (leftBindData != null)
  12737. {
  12738. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12739. designer.SetDataSource("BHSRS", leftBindData.rs);
  12740. designer.SetDataSource("BHSXS", leftBindData.xs);
  12741. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12742. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12743. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12744. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12745. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12746. }
  12747. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12748. if (leftBindData != null)
  12749. {
  12750. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12751. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12752. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12753. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12754. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12755. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12756. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12757. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12758. }
  12759. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12760. if (leftBindData != null)
  12761. {
  12762. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12763. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12764. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12765. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12766. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12767. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12768. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12769. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12770. }
  12771. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12772. if (leftBindData != null)
  12773. {
  12774. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12775. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12776. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12777. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12778. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12779. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12780. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12781. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12782. }
  12783. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12784. if (leftBindData != null)
  12785. {
  12786. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12787. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12788. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12789. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12790. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12791. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12792. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12793. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12794. }
  12795. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12796. if (leftBindData != null)
  12797. {
  12798. designer.SetDataSource("BCPCB", leftBindData.cb);
  12799. designer.SetDataSource("BCPRS", leftBindData.rs);
  12800. designer.SetDataSource("BCPXS", leftBindData.xs);
  12801. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12802. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12803. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12804. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12805. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12806. }
  12807. //TBR
  12808. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12809. if (leftBindData != null)
  12810. {
  12811. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12812. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12813. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12814. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12815. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12816. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12817. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12818. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12819. }
  12820. //SGR
  12821. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12822. if (leftBindData != null)
  12823. {
  12824. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12825. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12826. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12827. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12828. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12829. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12830. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12831. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12832. }
  12833. //JS/ES
  12834. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12835. if (leftBindData != null)
  12836. {
  12837. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12838. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12839. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12840. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12841. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12842. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12843. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12844. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12845. }
  12846. //SUITE
  12847. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12848. if (leftBindData != null)
  12849. {
  12850. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12851. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12852. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12853. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12854. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12855. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12856. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12857. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12858. }
  12859. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12860. if (leftBindData != null)
  12861. {
  12862. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12863. designer.SetDataSource("BDJRS", leftBindData.rs);
  12864. designer.SetDataSource("BDJXS", leftBindData.xs);
  12865. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12866. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12867. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12868. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12869. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12870. }
  12871. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12872. if (leftBindData != null)
  12873. {
  12874. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12875. designer.SetDataSource("BGWRS", leftBindData.rs);
  12876. designer.SetDataSource("BGWXS", leftBindData.xs);
  12877. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12878. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12879. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12880. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12881. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12882. }
  12883. #region 优化方案
  12884. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12885. //excelBind.Add("零用金", new {
  12886. //cb="",
  12887. //rs="",
  12888. //xs ="",
  12889. //zcb = "",
  12890. //});
  12891. #endregion
  12892. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12893. if (leftBindData != null)
  12894. {
  12895. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12896. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12897. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12898. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12899. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12900. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12901. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12902. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12903. }
  12904. #endregion
  12905. #region B段Right信息
  12906. right = dto.rightInfo.Find(x => x.Type == "B");
  12907. if (right == null)
  12908. {
  12909. return Ok(jw);
  12910. }
  12911. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12912. if (rightBindData != null)
  12913. {
  12914. //经济舱 + 双人间 TBR
  12915. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12916. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12917. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12918. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12919. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12920. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12921. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12922. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12923. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12924. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12925. }
  12926. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12927. if (rightBindData != null)
  12928. {
  12929. //经济舱 + 单人间 SGR
  12930. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12931. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12932. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12933. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12934. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12935. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12936. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12937. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12938. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12939. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12940. }
  12941. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12942. if (rightBindData != null)
  12943. {
  12944. //公务舱 + 单人间 SGR
  12945. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12946. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12947. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12948. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12949. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12950. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12951. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12952. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12953. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12954. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12955. }
  12956. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12957. if (rightBindData != null)
  12958. {
  12959. //公务舱 + 小套房 JSES
  12960. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12961. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12962. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12963. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12964. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12965. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12966. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12967. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12968. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12969. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12970. }
  12971. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12972. if (rightBindData != null)
  12973. {
  12974. //公务舱 + 小套房 JSES
  12975. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12976. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12977. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12978. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12979. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12980. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12981. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12982. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12983. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12984. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12985. }
  12986. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12987. if (rightBindData != null)
  12988. {
  12989. //经济舱 + 大套房
  12990. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12991. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12992. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12993. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12994. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12995. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12996. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12997. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12998. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12999. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13000. }
  13001. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13002. if (rightBindData != null)
  13003. {
  13004. //头等舱 + 小套房 JSES
  13005. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13006. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13007. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13008. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13009. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13010. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13011. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13012. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13013. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13014. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13015. }
  13016. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13017. if (rightBindData != null)
  13018. {
  13019. //头等舱 + 大套房
  13020. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13021. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13022. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13023. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13024. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13025. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13026. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13027. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13028. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13029. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13030. }
  13031. #endregion
  13032. #region 标题
  13033. designer.SetDataSource("CostBDRCB", "单人成本");
  13034. designer.SetDataSource("CostBRS", "人数");
  13035. designer.SetDataSource("CostBXS", "系数");
  13036. designer.SetDataSource("CostBZCB", "总成本");
  13037. designer.SetDataSource("CostBDRBJ", "单人报价");
  13038. designer.SetDataSource("CostBZBJ", "总报价");
  13039. designer.SetDataSource("CostBDRLR", "单人利润");
  13040. designer.SetDataSource("CostBZLR", "总利润");
  13041. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13042. designer.SetDataSource("CostBRSOM", "人数");
  13043. designer.SetDataSource("CostBZCBOM", "总成本");
  13044. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13045. designer.SetDataSource("CostBZBJOM", "总报价");
  13046. designer.SetDataSource("CostBDRLROM", "单人利润");
  13047. designer.SetDataSource("CostBZLROM", "总利润");
  13048. #endregion
  13049. }
  13050. #endregion
  13051. designer.SetDataSource("TzZCB2", TzZCB2);
  13052. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13053. designer.SetDataSource("TzZLR2", TzZLR2);
  13054. string[] dataSourceKeys = new string[]
  13055. {
  13056. "VF",
  13057. "TGS",
  13058. "TGOF",
  13059. "TGM",
  13060. "TGA",
  13061. "TGTF",
  13062. "TGEF",
  13063. "CFM",
  13064. "CFOF",
  13065. "B",
  13066. "L",
  13067. "D",
  13068. "TBR",
  13069. "SGR",
  13070. "JSES",
  13071. "Suite",
  13072. "TV",
  13073. "1L",
  13074. "IF",
  13075. "EF",
  13076. "BRF",
  13077. "TE",
  13078. "TGT",
  13079. "DRVT",
  13080. "PC",
  13081. "TLF",
  13082. "ECT"
  13083. };
  13084. foreach (var item in dataSourceKeys)
  13085. {
  13086. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13087. if (find != null)
  13088. {
  13089. designer.SetDataSource(item, find.text);
  13090. }
  13091. else
  13092. {
  13093. designer.SetDataSource(item, 0);
  13094. }
  13095. }
  13096. designer.SetDataSource(dt);
  13097. //根据数据源处理生成报表内容
  13098. designer.Process();
  13099. designer.Workbook.Worksheets[0].Name = "清单";
  13100. Worksheet sheet = designer.Workbook.Worksheets[0];
  13101. foreach (var Rowindex in hideRowsList)
  13102. {
  13103. ws.Cells.HideRows(Rowindex, 2);
  13104. }
  13105. byte[] bytes = null;
  13106. string strFileName = di.TeamName + "-团组-成本.xls";
  13107. using (MemoryStream stream = new MemoryStream())
  13108. {
  13109. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13110. bytes = stream.ToArray();
  13111. }
  13112. return Ok(JsonView(true, "", new
  13113. {
  13114. Data = bytes,
  13115. strFileName,
  13116. }));
  13117. }
  13118. /// <summary>
  13119. /// 导出客户报表
  13120. /// </summary>
  13121. /// <returns></returns>
  13122. [HttpPost]
  13123. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13124. {
  13125. var jw = JsonView(false);
  13126. if (dto.Diid == 0)
  13127. {
  13128. return Ok(JsonView(false, "请传递团组id"));
  13129. }
  13130. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13131. if (deleInfo.Code != 0)
  13132. {
  13133. return Ok(JsonView(false, "团组信息查询失败!"));
  13134. }
  13135. var di = deleInfo.Data as DelegationInfoWebView;
  13136. if (di == null)
  13137. {
  13138. return Ok(JsonView(false, "团组信息查询失败!"));
  13139. }
  13140. //文件名
  13141. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13142. //获取模板
  13143. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13144. //载入模板
  13145. Document doc = new Document(tmppath);
  13146. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13147. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13148. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13149. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13150. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13151. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13152. if (AParameter == null)
  13153. {
  13154. return Ok(JsonView(false, "系数不存在!"));
  13155. }
  13156. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13157. , TzAirDesc, TzZCost;
  13158. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13159. = TzAirDesc = TzZCost = string.Empty;
  13160. TzNumber = AParameter.CostTypenumber.ToString();
  13161. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13162. CarGuides1 = dto.CarGuides1;
  13163. Meal = dto.Meal;
  13164. SubsidizedMeals = dto.SubsidizedMeals;
  13165. NightRepair = dto.NightRepair;
  13166. AttractionsTickets = dto.AttractionsTickets;
  13167. MiscellaneousFees = dto.MiscellaneousFees;
  13168. ATip = dto.ATip;
  13169. TzHotelDesc = "";
  13170. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13171. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13172. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13173. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13174. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13175. TzAirDesc = "";
  13176. TzZCost = dto.TzZCost;
  13177. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13178. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13179. var index = 1;
  13180. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13181. foreach (var item in TzHotelDescArr)
  13182. {
  13183. if (AinfoArr != null)
  13184. {
  13185. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13186. if (Ainfo != null)
  13187. {
  13188. if (int.Parse(Ainfo.rs) <= 0)
  13189. {
  13190. continue;
  13191. }
  13192. var hotelText = string.Empty;
  13193. switch (item)
  13194. {
  13195. case "SGR":
  13196. hotelText = "单人间";
  13197. break;
  13198. case "JSES":
  13199. hotelText = "小套房";
  13200. break;
  13201. case "SUITE":
  13202. hotelText = "套房";
  13203. break;
  13204. case "TBR":
  13205. hotelText = "双人间";
  13206. break;
  13207. }
  13208. if (item != "TBR")
  13209. {
  13210. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  13211. }
  13212. else
  13213. {
  13214. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  13215. }
  13216. index++;
  13217. }
  13218. }
  13219. }
  13220. index = 1;
  13221. foreach (var item in TzAirDescArr)
  13222. {
  13223. if (AinfoArr != null)
  13224. {
  13225. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13226. if (Ainfo != null)
  13227. {
  13228. if (int.Parse(Ainfo.rs) <= 0)
  13229. {
  13230. continue;
  13231. }
  13232. 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";
  13233. index++;
  13234. }
  13235. }
  13236. }
  13237. if (dto.costType == "B")
  13238. {
  13239. if (BParameter == null)
  13240. {
  13241. return Ok(JsonView(false, "B段系数不存在!"));
  13242. }
  13243. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13244. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13245. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13246. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13247. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13248. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13249. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13250. foreach (var item in TzHotelDescArr)
  13251. {
  13252. if (AinfoArr != null)
  13253. {
  13254. TzHotelDesc += "B段信息 \r\n";
  13255. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13256. if (Ainfo != null)
  13257. {
  13258. if (int.Parse(Ainfo.rs) <= 0)
  13259. {
  13260. continue;
  13261. }
  13262. var hotelText = string.Empty;
  13263. switch (item)
  13264. {
  13265. case "SGR":
  13266. hotelText = "单人间";
  13267. break;
  13268. case "JSES":
  13269. hotelText = "小套房";
  13270. break;
  13271. case "SUITE":
  13272. hotelText = "套房";
  13273. break;
  13274. case "TBR":
  13275. hotelText = "双人间";
  13276. break;
  13277. }
  13278. if (item != "TBR")
  13279. {
  13280. 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";
  13281. }
  13282. else
  13283. {
  13284. 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";
  13285. }
  13286. index++;
  13287. }
  13288. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13289. }
  13290. }
  13291. index = 1;
  13292. foreach (var item in TzAirDescArr)
  13293. {
  13294. if (AinfoArr != null)
  13295. {
  13296. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13297. if (Ainfo != null)
  13298. {
  13299. if (int.Parse(Ainfo.rs) <= 0)
  13300. {
  13301. continue;
  13302. }
  13303. 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";
  13304. index++;
  13305. }
  13306. }
  13307. }
  13308. }
  13309. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13310. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13311. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13312. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13313. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13314. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13315. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13316. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13317. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13318. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13319. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13320. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13321. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13322. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13323. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13324. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13325. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13326. DickeyValue.Add("TzZCost", TzZCost);
  13327. foreach (var key in DickeyValue.Keys)
  13328. {
  13329. if (doc.Range.Bookmarks[key] != null)
  13330. {
  13331. Bookmark mark = doc.Range.Bookmarks[key];
  13332. mark.Text = DickeyValue[key];
  13333. }
  13334. }
  13335. byte[] bytes = null;
  13336. string strFileName = di.TeamName + "-客户报价.doc";
  13337. using (MemoryStream stream = new MemoryStream())
  13338. {
  13339. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13340. bytes = stream.ToArray();
  13341. }
  13342. return Ok(JsonView(true, "", new
  13343. {
  13344. Data = bytes,
  13345. strFileName,
  13346. }));
  13347. }
  13348. /// <summary>
  13349. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13350. /// </summary>
  13351. /// <param name="dto"></param>
  13352. /// <returns></returns>
  13353. [HttpPost]
  13354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13355. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13356. {
  13357. try
  13358. {
  13359. #region 参数验证
  13360. if (dto.DiId < 0)
  13361. {
  13362. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13363. }
  13364. List<int> cTableIds = new List<int>() {
  13365. 76 ,//酒店预订
  13366. 77 ,//行程
  13367. 79 ,//车/导游地接
  13368. 80 ,//签证
  13369. 81 ,//邀请/公务活
  13370. 82 ,//团组客户保险
  13371. 85 ,//机票预订
  13372. 98 ,//其他款项
  13373. 285 ,//收款退还
  13374. 751 ,//酒店早餐
  13375. 1015 // 超支费用
  13376. };
  13377. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13378. {
  13379. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13380. }
  13381. #endregion
  13382. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13383. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13384. if (_GroupCostParameters.Count <= 0)
  13385. {
  13386. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13387. }
  13388. if (_GroupCostParameters[0].IsShare == 0)
  13389. {
  13390. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13391. }
  13392. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13393. //处理date为空问题
  13394. if (_GroupCosts.Count > 0)
  13395. {
  13396. for (int i = 0; i < _GroupCosts.Count; i++)
  13397. {
  13398. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13399. {
  13400. if (i > 0)
  13401. {
  13402. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13403. }
  13404. }
  13405. }
  13406. }
  13407. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13408. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13409. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13410. string currCode = "";
  13411. #region currCode 验证
  13412. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13413. if (isInt)
  13414. {
  13415. var currData = currDatas.Find(it => it.Id == intCurrency);
  13416. if (currData != null)
  13417. {
  13418. currCode = currData.Name;
  13419. }
  13420. }
  13421. else
  13422. {
  13423. currCode = _GroupCostParameters[0].Currency.Trim();
  13424. }
  13425. #endregion
  13426. //op,酒店单段模式存储
  13427. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13428. {
  13429. CurrencyCode = currCode,
  13430. Rate = _GroupCostParameters[0].Rate,
  13431. CostType = _GroupCostParameters[0].CostType,
  13432. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13433. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13434. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13435. };
  13436. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13437. if (_GroupCostParameters.Count == 2)
  13438. {
  13439. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13440. }
  13441. foreach (var item in _GroupCostParameters)
  13442. {
  13443. decimal _rate = 1;
  13444. decimal _rate1 = item.Rate;
  13445. decimal _scale = 1;
  13446. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13447. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13448. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13449. //if (userInfo != null)
  13450. //{
  13451. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13452. // {
  13453. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13454. // {
  13455. // _scale = 1.00M;
  13456. // }
  13457. // }
  13458. //}
  13459. #endregion
  13460. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13461. {
  13462. CurrencyCode = currCode,
  13463. Rate = _rate1,
  13464. CostType = item.CostType,
  13465. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13466. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13467. CostTypeNumber = item.CostTypenumber
  13468. };
  13469. if (_GroupCostParameters.Count > 1)
  13470. {
  13471. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13472. }
  13473. else
  13474. {
  13475. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13476. }
  13477. if (dto.CTable == 79)//
  13478. {
  13479. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13480. modulePromptInfo.TotalCost = item.DJCB;
  13481. }
  13482. List<string> costTypes = new List<string>() { "A", "B" };
  13483. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13484. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13485. if (_GroupCostsDuplicates.Count() == 1)
  13486. {
  13487. _GroupCostsTypeData = _GroupCosts;
  13488. }
  13489. else
  13490. {
  13491. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13492. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13493. }
  13494. /*
  13495. * 76 酒店预订
  13496. * 77 行程
  13497. * 79 车/导游地接
  13498. * 80 签证
  13499. * 81 邀请/公务活动
  13500. * 82 团组客户保险
  13501. * 85 机票预订
  13502. * 98 其他款项
  13503. * 285 收款退还
  13504. * 751 酒店早餐
  13505. * 1015 超支费用
  13506. */
  13507. switch (dto.CTable)
  13508. {
  13509. case 76: // 酒店预订
  13510. _ModuleSubPromptInfo.AddRange(
  13511. _GroupCostsTypeData.Select(it => new
  13512. {
  13513. it.DAY,
  13514. it.Date,
  13515. it.ACCON,
  13516. it.ITIN,
  13517. it.SGR,
  13518. it.TBR,
  13519. it.JS_ES,
  13520. it.Suite
  13521. })
  13522. );
  13523. break;
  13524. case 79: // 车/导游地接
  13525. _ModuleSubPromptInfo.AddRange(
  13526. _GroupCostsTypeData.Select(it => new
  13527. {
  13528. Date = it.Date, //日期
  13529. CarFee = it.CarCost * _rate * _scale, //车费用
  13530. CarType = it.CarType, //车型
  13531. DriverFee = it.CFS * _rate * _scale, //司机工资
  13532. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13533. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13534. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13535. GuideFee = it.TGS * _rate * _scale, //导游费用
  13536. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13537. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13538. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13539. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13540. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13541. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13542. Breakfast = it.B * _rate * _scale, //早餐费
  13543. Lunch = it.L * _rate * _scale, //午餐费
  13544. Dinner = it.D * _rate * _scale, //晚餐费
  13545. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13546. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13547. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13548. TicketFee = it.EF * _rate * _scale, //门票费
  13549. TicketRemark = it.EFR, //门票费描述
  13550. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13551. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13552. SpentCash = it.PC * _rate * _scale, //零用金
  13553. LeadersFee = it.TLF * _rate * _scale, //领队费
  13554. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13555. })
  13556. );
  13557. break;
  13558. case 85: // 机票
  13559. List<dynamic> datas = new List<dynamic>();
  13560. datas.Add(
  13561. new
  13562. {
  13563. AirType = "经济舱",
  13564. AirNum = item.JJCRS,
  13565. AirDRCB = item.JJCCB,
  13566. AirZCB = (item.JJCRS * item.JJCCB)
  13567. }
  13568. );
  13569. datas.Add(
  13570. new
  13571. {
  13572. AirType = "公务舱",
  13573. AirNum = item.GWCRS,
  13574. AirDRCB = item.GWCCB,
  13575. AirZCB = (item.GWCRS * item.GWCCB)
  13576. }
  13577. );
  13578. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13579. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13580. modulePromptInfo.Data = new
  13581. {
  13582. airFeeData = datas,
  13583. airInitData = initDatas
  13584. };
  13585. _ModulePromptInfos.Add(modulePromptInfo);
  13586. break;
  13587. default:
  13588. break;
  13589. }
  13590. }
  13591. if (dto.CTable != 85)
  13592. {
  13593. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13594. _ModulePromptInfos.Add(_ModulePromptInfo);
  13595. }
  13596. _view.ModulePromptInfos = _ModulePromptInfos;
  13597. return Ok(JsonView(true, "操作成功!", _view));
  13598. }
  13599. catch (Exception ex)
  13600. {
  13601. return Ok(JsonView(false, ex.Message));
  13602. }
  13603. }
  13604. /// <summary>
  13605. /// 根据黑屏代码重新生成行程
  13606. /// </summary>
  13607. /// <param name="dto"></param>
  13608. /// <returns></returns>
  13609. [HttpPost]
  13610. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13611. {
  13612. var jw = JsonView(false);
  13613. var Create = _GroupCostRepository.
  13614. CreateGroupCostByBlackCode(dto.Diid);
  13615. jw.Msg = Create.Msg;
  13616. if (Create.Code == 0)
  13617. {
  13618. jw.Code = 200;
  13619. jw.Data = new
  13620. {
  13621. groupCost = Create.Data,
  13622. blackCodeIsTrue = true
  13623. };
  13624. }
  13625. else
  13626. {
  13627. jw.Code = 400;
  13628. jw.Data = new
  13629. {
  13630. groupCost = Create.Data,
  13631. blackCodeIsTrue = false,
  13632. };
  13633. }
  13634. return Ok(jw);
  13635. }
  13636. /// <summary>
  13637. /// 成本获取OP历史车费用
  13638. /// </summary>
  13639. /// <param name="dto"></param>
  13640. /// <returns></returns>
  13641. [HttpPost]
  13642. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13643. {
  13644. var jw = JsonView(false);
  13645. try
  13646. {
  13647. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13648. //获取现有所有车的数据
  13649. if (!dto.Param.IsNullOrWhiteSpace())
  13650. {
  13651. string sql = $@"
  13652. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13653. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13654. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13655. 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
  13656. AND gctggr.ServiceEndTime is not NULL
  13657. ORDER by gctggrc.id DESC
  13658. ";
  13659. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13660. var numeberResult = await Task.Run(() =>
  13661. {
  13662. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13663. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13664. return numberArr;
  13665. });
  13666. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13667. foreach (var item in numeberResult)
  13668. {
  13669. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13670. {
  13671. Country = "数据异常!",
  13672. City = string.Empty,
  13673. };
  13674. item.Area = find.Country + " " + find.City;
  13675. }
  13676. dbResult.AddRange(numeberResult);
  13677. if (dto.Param.Contains("、"))
  13678. {
  13679. var sp = dto.Param.Split("、");
  13680. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13681. .Where(x =>
  13682. {
  13683. return System.Array.Exists(sp, e =>
  13684. {
  13685. bool where = false;
  13686. if (x.Area != null)
  13687. {
  13688. where = x.Area.Contains(e);
  13689. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13690. {
  13691. return false;
  13692. }
  13693. }
  13694. if (x.PriceName != null && !where)
  13695. {
  13696. where = x.PriceName.Contains(e);
  13697. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13698. {
  13699. return false;
  13700. }
  13701. }
  13702. return where;
  13703. });
  13704. }).ToList();
  13705. }
  13706. else
  13707. {
  13708. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13709. .Where(x =>
  13710. {
  13711. bool where = false;
  13712. if (x.Area != null)
  13713. {
  13714. where = x.Area.Contains(dto.Param);
  13715. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13716. {
  13717. return false;
  13718. }
  13719. }
  13720. if (x.PriceName != null && !where)
  13721. {
  13722. where = x.PriceName.Contains(dto.Param);
  13723. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13724. {
  13725. return false;
  13726. }
  13727. }
  13728. return where;
  13729. }
  13730. )
  13731. .ToList();
  13732. }
  13733. }
  13734. var view = dbResult.Select(x =>
  13735. {
  13736. decimal dp = 0.00M;
  13737. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13738. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13739. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13740. {
  13741. if (startB && endB)
  13742. {
  13743. var timesp = endD.Subtract(startD);
  13744. if ((timesp.Days + 1) != 0)
  13745. {
  13746. dp = x.Price / (timesp.Days + 1);
  13747. }
  13748. }
  13749. }
  13750. else
  13751. {
  13752. dp = x.Price;
  13753. }
  13754. return new
  13755. {
  13756. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13757. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13758. x.Area,
  13759. x.id,
  13760. price = x.Price.ToString("F2"),
  13761. x.PriceName,
  13762. x.PriceContent,
  13763. x.TeamName,
  13764. x.DatePrice,
  13765. dayPrice = dp.ToString("F2"),
  13766. };
  13767. }).OrderByDescending(x => x.id).ToList();
  13768. jw = JsonView(true, "获取成功!", view);
  13769. }
  13770. catch (Exception e)
  13771. {
  13772. jw = JsonView(false, e.Message);
  13773. }
  13774. return Ok(jw);
  13775. }
  13776. #endregion
  13777. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13778. /// <summary>
  13779. /// 酒店预订
  13780. /// 酒店费用列表 根据团组Id查询
  13781. /// </summary>
  13782. /// <param name="_dto"></param>
  13783. /// <returns></returns>
  13784. [HttpPost]
  13785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13786. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13787. {
  13788. #region 参数验证
  13789. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13790. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13791. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13792. #region 团组操作权限验证 76 酒店预定模块
  13793. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13794. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13795. #endregion
  13796. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13797. #region 页面操作权限验证
  13798. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13799. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13800. #endregion
  13801. #endregion
  13802. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13803. }
  13804. /// <summary>
  13805. /// 酒店预订
  13806. /// 基础数据
  13807. /// </summary>
  13808. /// <param name="_dto"></param>
  13809. /// <returns></returns>
  13810. [HttpPost]
  13811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13812. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13813. {
  13814. #region 参数验证
  13815. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13816. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13817. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13818. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13819. #region 页面操作权限验证
  13820. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13821. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13822. #endregion
  13823. #region 团组操作权限验证 76 酒店预定模块
  13824. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13825. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13826. #endregion
  13827. #endregion
  13828. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13829. }
  13830. /// <summary>
  13831. /// 酒店预订
  13832. /// 创建 入住卷号码
  13833. /// </summary>
  13834. /// <param name="_dto"></param>
  13835. /// <returns></returns>
  13836. [HttpPost]
  13837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13838. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13839. {
  13840. #region 参数验证
  13841. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13842. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13843. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13844. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13845. #region 页面操作权限验证
  13846. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13847. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13848. #endregion
  13849. #region 团组操作权限验证 76 酒店预定模块
  13850. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13851. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13852. #endregion
  13853. #endregion
  13854. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13855. if (data.Code != 0)
  13856. {
  13857. return Ok(JsonView(false, data.Msg));
  13858. }
  13859. return Ok(JsonView(true, data.Msg, data.Data));
  13860. }
  13861. /// <summary>
  13862. /// 酒店预订
  13863. /// 详情
  13864. /// </summary>
  13865. /// <param name="_dto"></param>
  13866. /// <returns></returns>
  13867. [HttpPost]
  13868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13869. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13870. {
  13871. #region 参数验证
  13872. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13873. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13874. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13875. #region 团组操作权限验证 76 酒店预定模块
  13876. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13877. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13878. #endregion
  13879. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13880. #region 页面操作权限验证
  13881. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13882. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13883. #endregion
  13884. #endregion
  13885. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13886. }
  13887. /// <summary>
  13888. /// 酒店预订
  13889. /// Add Or Edit
  13890. /// </summary>
  13891. /// <param name="_dto"></param>
  13892. /// <returns></returns>
  13893. [HttpPost]
  13894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13895. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13896. {
  13897. #region 参数验证
  13898. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13899. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13900. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13901. #region 团组操作权限验证 76 酒店预定模块
  13902. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13903. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13904. #endregion
  13905. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13906. #region 页面操作权限验证
  13907. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13908. if (_dto.Id == 0) // Add
  13909. {
  13910. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13911. }
  13912. else if (_dto.Id > 1) // Edit
  13913. {
  13914. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13915. }
  13916. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13917. #endregion
  13918. #endregion
  13919. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13920. if (_view.Code != 200)
  13921. {
  13922. return Ok(_view);
  13923. }
  13924. #region 成本无酒店价格数据进入超支
  13925. _sqlSugar.BeginTran();
  13926. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13927. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13928. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13929. for (int i = 0; i < groupCost.Count; i++)
  13930. {
  13931. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13932. {
  13933. groupCost[i].Date = groupCost[i - 1].Date;
  13934. }
  13935. }
  13936. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13937. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13938. List<Fin_GroupExtraCostDto_OP>();
  13939. if (start_Bool && end_Bool)
  13940. {
  13941. while (start_Time < end_Time)
  13942. {
  13943. foreach (var item in groupCost_Grp)
  13944. {
  13945. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13946. {
  13947. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13948. {
  13949. extraCostList.Add(new
  13950. Fin_GroupExtraCostDto_OP
  13951. {
  13952. Area = _dto.AreaId,
  13953. coefficient = 1.5M,
  13954. createUser = _dto.UserId,
  13955. currency = _dto.CardPriceCurrency,
  13956. diId = _dto.DiId,
  13957. ManagerConfirm = 0,
  13958. SupervisorConfirm = 0,
  13959. SYsupervisorConfirm = 0,
  13960. editType = 1,
  13961. PortType = 1,
  13962. price = _dto.CardPrice,
  13963. PriceCount = 1,
  13964. priceType = 1027,
  13965. priceDetailType = 1044,
  13966. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13967. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13968. });
  13969. }
  13970. }
  13971. }
  13972. start_Time = start_Time.AddDays(1);
  13973. }
  13974. }
  13975. if (extraCostList.Any())
  13976. {
  13977. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13978. }
  13979. _sqlSugar.CommitTran();
  13980. #endregion
  13981. #region 应用推送
  13982. try
  13983. {
  13984. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13985. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13986. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13987. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  13988. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  13989. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  13990. var diId = _dto.DiId;
  13991. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13992. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13993. #region 操作记录
  13994. var opInfo = new Crm_TableOperationRecord()
  13995. {
  13996. TableName = "Grp_HotelReservations",
  13997. PortType = _dto.PortType,
  13998. DataId = hotelId,
  13999. CreateUserId = _dto.UserId
  14000. };
  14001. //var opStatus = OperationEnum.NoOperation;
  14002. if (_dto.Id < 1) //添加操作
  14003. {
  14004. opInfo.OperationItem = OperationEnum.Add;
  14005. }
  14006. else if (_dto.Id > 0)
  14007. {
  14008. opInfo.OperationItem = OperationEnum.Edit;
  14009. }
  14010. string opRemark = string.Empty;
  14011. if (ccpInfo != null)
  14012. {
  14013. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14014. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14015. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14016. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14017. }
  14018. opInfo.Remark = opRemark;
  14019. await _tableorRep.AddAsync(opInfo);
  14020. #endregion
  14021. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14022. //2024-10-21 新增LZ UID
  14023. var userIds = new List<int>() { 21 };
  14024. string title = $"费用审核";
  14025. string content = "";
  14026. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14027. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14028. try
  14029. {
  14030. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14031. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14032. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14033. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14034. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14035. }
  14036. catch (Exception ex)
  14037. {
  14038. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14039. }
  14040. }
  14041. catch (Exception ex)
  14042. {
  14043. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14044. }
  14045. try
  14046. {
  14047. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14048. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14049. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14050. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14051. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14052. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14053. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14054. //自动审核
  14055. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14056. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14057. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14058. //2024-10-21 新增LZ UID
  14059. var userIds = new List<int>() { 21 };
  14060. string title = $"系统通知";
  14061. var diId = _dto.DiId;
  14062. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14063. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14064. string content = "";
  14065. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14066. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14067. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14068. }
  14069. catch (Exception ex)
  14070. {
  14071. }
  14072. #endregion
  14073. return Ok(_view);
  14074. }
  14075. /// <summary>
  14076. /// 酒店自动审核测试
  14077. /// Add Or Edit
  14078. /// </summary>
  14079. /// <param name="diid"></param>
  14080. /// <param name="dataId"></param>
  14081. /// <returns></returns>
  14082. [HttpPost]
  14083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14084. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14085. {
  14086. #region 应用推送
  14087. try
  14088. {
  14089. //自动审核
  14090. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14091. }
  14092. catch (Exception ex)
  14093. {
  14094. return Ok(JsonView(false, "操作失败"));
  14095. }
  14096. #endregion
  14097. return Ok(JsonView(false, "操作成功"));
  14098. }
  14099. /// <summary>
  14100. /// 酒店预订
  14101. /// Del
  14102. /// </summary>
  14103. /// <param name="_dto"></param>
  14104. /// <returns></returns>
  14105. [HttpPost]
  14106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14107. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14108. {
  14109. #region 参数验证
  14110. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14111. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14112. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14113. #region 团组操作权限验证 76 酒店预定模块
  14114. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14115. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14116. #endregion
  14117. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14118. #region 页面操作权限验证
  14119. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14120. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14121. #endregion
  14122. #endregion
  14123. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14124. #region 操作记录
  14125. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14126. {
  14127. TableName = "Grp_HotelReservations",
  14128. PortType = _dto.PortType,
  14129. OperationItem = OperationEnum.Del,
  14130. DataId = _dto.Id,
  14131. CreateUserId = _dto.UserId
  14132. });
  14133. #endregion
  14134. return Ok(data);
  14135. }
  14136. /// <summary>
  14137. /// 酒店预订
  14138. /// 生成VOUCHER
  14139. /// 2024.05.06 之前版本
  14140. /// </summary>
  14141. /// <param name="_dto"></param>
  14142. /// <returns></returns>
  14143. [HttpPost]
  14144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14145. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14146. {
  14147. try
  14148. {
  14149. #region 参数验证
  14150. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14151. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14152. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14153. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14154. #region 团组操作权限验证 76 酒店预定模块
  14155. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14156. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14157. #endregion
  14158. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14159. #region 页面操作权限验证
  14160. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14161. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14162. #endregion
  14163. #endregion
  14164. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14165. //判断数据是否完整
  14166. if (hr != null)
  14167. {
  14168. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14169. {
  14170. string strFileName = "HotelStatement/";
  14171. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14172. if (dele != null)
  14173. strFileName += dele.TourCode;
  14174. //载入模板
  14175. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14176. Document doc = new Document(sss);
  14177. DocumentBuilder builder = new DocumentBuilder(doc);
  14178. #region 替换Word模板书签内容
  14179. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14180. //入住卷预定号码
  14181. if (doc.Range.Bookmarks["VNO"] != null)
  14182. {
  14183. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14184. mark.Text = hr.CheckNumber;
  14185. }
  14186. //酒店时间
  14187. if (doc.Range.Bookmarks["Date"] != null)
  14188. {
  14189. Bookmark mark = doc.Range.Bookmarks["Date"];
  14190. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14191. }
  14192. //团号
  14193. if (doc.Range.Bookmarks["TNo"] != null)
  14194. {
  14195. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14196. mark.Text = dele.TourCode;
  14197. }
  14198. //预定号码
  14199. if (doc.Range.Bookmarks["BookingId"] != null)
  14200. {
  14201. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14202. mark.Text = hr.ReservationsNo;
  14203. }
  14204. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14205. {
  14206. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14207. mark.Text = hr.DetermineNo;
  14208. }
  14209. //酒店城市
  14210. if (doc.Range.Bookmarks["City"] != null)
  14211. {
  14212. Bookmark mark = doc.Range.Bookmarks["City"];
  14213. mark.Text = hr.City;
  14214. }
  14215. //酒店名称
  14216. if (doc.Range.Bookmarks["HName"] != null)
  14217. {
  14218. Bookmark mark = doc.Range.Bookmarks["HName"];
  14219. mark.Text = hr.HotelName;
  14220. }
  14221. //酒店地址
  14222. if (doc.Range.Bookmarks["Address"] != null)
  14223. {
  14224. Bookmark mark = doc.Range.Bookmarks["Address"];
  14225. mark.Text = hr.HotelAddress;
  14226. }
  14227. //酒店电话
  14228. if (doc.Range.Bookmarks["Tel"] != null)
  14229. {
  14230. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14231. mark.Text = hr.HotelTel;
  14232. }
  14233. //酒店传真
  14234. if (doc.Range.Bookmarks["Fax"] != null)
  14235. {
  14236. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14237. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14238. {
  14239. mark.Text = hr.HotelFax;
  14240. }
  14241. }
  14242. //入住时间
  14243. if (doc.Range.Bookmarks["CIn"] != null)
  14244. {
  14245. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14246. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14247. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14248. }
  14249. //退房时间
  14250. if (doc.Range.Bookmarks["COut"] != null)
  14251. {
  14252. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14253. Bookmark mark = doc.Range.Bookmarks["COut"];
  14254. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14255. }
  14256. //客户名称
  14257. if (doc.Range.Bookmarks["GName"] != null)
  14258. {
  14259. string guestName = "";
  14260. string[] clients = new string[] { };
  14261. if (hr.GuestName.Contains(","))
  14262. {
  14263. clients = hr.GuestName.Split(",");
  14264. }
  14265. else
  14266. {
  14267. clients = new string[] { hr.GuestName };
  14268. }
  14269. List<int> clientIds_int = new List<int>();
  14270. if (clients.Length > 0)
  14271. {
  14272. foreach (var item in clients)
  14273. {
  14274. if (item.IsNumeric())
  14275. {
  14276. clientIds_int.Add(int.Parse(item));
  14277. }
  14278. }
  14279. }
  14280. if (clientIds_int.Count > 0)
  14281. {
  14282. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14283. foreach (var client in _clientDatas)
  14284. {
  14285. //男
  14286. if (client.Sex == 0) guestName += $"Mr.";
  14287. //女
  14288. else if (client.Sex == 1) guestName += $"Ms.";
  14289. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14290. {
  14291. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14292. }
  14293. //guestName += $"{client.Pinyin},";
  14294. }
  14295. if (guestName.Length > 0)
  14296. {
  14297. guestName = guestName.Substring(0, guestName.Length - 1);
  14298. }
  14299. }
  14300. else
  14301. {
  14302. guestName = hr.GuestName;
  14303. }
  14304. Bookmark mark = doc.Range.Bookmarks["GName"];
  14305. mark.Text = guestName;
  14306. }
  14307. //房间介绍
  14308. if (doc.Range.Bookmarks["ROOM"] != null)
  14309. {
  14310. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14311. mark.Text = hr.RoomExplanation;
  14312. }
  14313. //报价描述
  14314. if (doc.Range.Bookmarks["NOTE"] != null)
  14315. {
  14316. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14317. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14318. if (ss != null)
  14319. mark.Text = ss.Name;
  14320. }
  14321. //入住时间
  14322. if (doc.Range.Bookmarks["CheckIn"] != null)
  14323. {
  14324. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14325. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14326. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14327. }
  14328. //退房时间
  14329. if (doc.Range.Bookmarks["CheckOut"] != null)
  14330. {
  14331. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14332. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14333. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14334. }
  14335. //日期
  14336. if (doc.Range.Bookmarks["DT"] != null)
  14337. {
  14338. Bookmark mark = doc.Range.Bookmarks["DT"];
  14339. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14340. }
  14341. //名称
  14342. if (doc.Range.Bookmarks["VName"] != null)
  14343. {
  14344. Bookmark mark = doc.Range.Bookmarks["VName"];
  14345. mark.Text = hr.HotelName;
  14346. }
  14347. //号码
  14348. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14349. {
  14350. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14351. mark.Text = hr.CheckNumber;
  14352. }
  14353. #endregion
  14354. strFileName += "VOUCHER.doc";
  14355. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14356. doc.Save(fileDir);
  14357. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14358. return Ok(JsonView(true, "操作成功!", Url));
  14359. }
  14360. else
  14361. {
  14362. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14363. }
  14364. }
  14365. else
  14366. {
  14367. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14368. }
  14369. }
  14370. catch (Exception ex)
  14371. {
  14372. return Ok(JsonView(false, ex.Message));
  14373. }
  14374. }
  14375. /// <summary>
  14376. /// 酒店预订
  14377. /// 生成VOUCHER
  14378. /// 2024.05.06 之后版本
  14379. /// </summary>
  14380. /// <param name="_dto"></param>
  14381. /// <returns></returns>
  14382. [HttpPost]
  14383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14384. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14385. {
  14386. #region 参数验证
  14387. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14388. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14389. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14390. #region 团组操作权限验证 76 酒店预定模块
  14391. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14392. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14393. #endregion
  14394. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14395. #region 页面操作权限验证
  14396. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14397. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14398. #endregion
  14399. #endregion
  14400. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14401. //判断数据是否完整
  14402. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14403. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14404. string strFileName = "HotelStatement/";
  14405. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14406. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14407. #region 数据处理
  14408. List<int> guestIds = new List<int>();
  14409. //int index = 0;
  14410. foreach (var item in hrDtas)
  14411. {
  14412. if (item.GuestName.Contains(","))
  14413. {
  14414. string[] guestIdArr = item.GuestName.Split(',');
  14415. foreach (var guestIdStr in guestIdArr)
  14416. {
  14417. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14418. if (guestBool)
  14419. {
  14420. guestIds.Add(guestId);
  14421. }
  14422. }
  14423. }
  14424. else guestNames += item.GuestName;
  14425. var voucherInfo = new HotelVoucherInfoView()
  14426. {
  14427. HotelName = item.HotelName,
  14428. CheckInDate = item.CheckInDate,
  14429. CheckOutDate = item.CheckOutDate,
  14430. ConfirmationNumber = item.DetermineNo.Trim(),
  14431. RoomType = item.RoomExplanation
  14432. };
  14433. vouchers.Add(voucherInfo);
  14434. }
  14435. if (guestIds.Count > 0)
  14436. {
  14437. guestIds = guestIds.Distinct().ToList();
  14438. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14439. if (guestDatas.Count > 0)
  14440. {
  14441. guestNames = "";
  14442. foreach (var guest in guestDatas)
  14443. {
  14444. string guestName = "";
  14445. if (guest.Sex == 0) guestName += @"MR.";
  14446. else if (guest.Sex == 1) guestName += @"MS.";
  14447. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14448. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14449. guestNames += @$"{guestName.Trim()}、";
  14450. }
  14451. if (guestNames.Length > 0)
  14452. {
  14453. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14454. }
  14455. }
  14456. }
  14457. #endregion
  14458. //载入模板
  14459. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14460. Document doc = new Document(sss);
  14461. DocumentBuilder builder = new DocumentBuilder(doc);
  14462. if (doc.Range.Bookmarks["GuestName"] != null)
  14463. {
  14464. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14465. mark.Text = guestNames;
  14466. }
  14467. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14468. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14469. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14470. for (int i = 1; i <= vouchers.Count; i++)
  14471. {
  14472. HotelVoucherInfoView hviv = vouchers[i - 1];
  14473. builder.MoveToCell(0, i, 0, 0);
  14474. builder.Write(hviv.HotelName);
  14475. builder.MoveToCell(0, i, 1, 0);
  14476. builder.Write(hviv.CheckInDate);
  14477. builder.MoveToCell(0, i, 2, 0);
  14478. builder.Write(hviv.CheckOutDate);
  14479. builder.MoveToCell(0, i, 3, 0);
  14480. builder.Write(hviv.RoomType);
  14481. builder.MoveToCell(0, i, 4, 0);
  14482. builder.Write(hviv.ConfirmationNumber);
  14483. }
  14484. //删除多余行
  14485. int currRowIndex = vouchers.Count + 1;
  14486. int delRows = 21 - currRowIndex;
  14487. if (delRows > 0)
  14488. {
  14489. for (int i = 0; i < delRows; i++)
  14490. {
  14491. table.Rows.RemoveAt(currRowIndex);
  14492. //cultivateRowIndex++;
  14493. }
  14494. }
  14495. strFileName += "VOUCHER.docx";
  14496. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14497. doc.Save(fileDir);
  14498. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14499. return Ok(JsonView(true, "操作成功!", Url));
  14500. }
  14501. /// <summary>
  14502. /// 酒店预订
  14503. /// 生成VOUCHER 批量生成
  14504. /// New
  14505. /// </summary>
  14506. /// <param name="_dto"></param>
  14507. /// <returns></returns>
  14508. [HttpPost]
  14509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14510. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14511. {
  14512. #region 参数验证
  14513. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14514. if (_dto.PageId < 1) _dto.PageId = 28;
  14515. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14516. #region 团组操作权限验证 76 酒店预定模块
  14517. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14518. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14519. #endregion
  14520. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14521. #region 页面操作权限验证
  14522. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14523. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14524. #endregion
  14525. #endregion
  14526. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14527. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14528. .OrderBy(x => x.CheckInDate)
  14529. .ToListAsync();
  14530. //判断数据是否完整
  14531. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14532. string strFileName = "HotelStatement/";
  14533. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14534. if (dele != null)
  14535. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14536. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14537. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14538. .Where(it => it.IsDel == 0)
  14539. .ToListAsync();
  14540. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14541. for (int i = 0; i < hrDtas.Count; i++)
  14542. {
  14543. string guestNames = string.Empty;
  14544. List<int> guestIds = new List<int>();
  14545. var item = hrDtas[i];
  14546. //处理客户姓名
  14547. if (item.GuestName.Contains(","))
  14548. {
  14549. string[] guestIdArr = item.GuestName.Split(',');
  14550. foreach (var guestIdStr in guestIdArr)
  14551. if (int.TryParse(guestIdStr, out int guestId))
  14552. guestIds.Add(guestId);
  14553. }
  14554. else
  14555. {
  14556. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14557. if (guestIdBool)
  14558. {
  14559. guestIds.Add(guestId);
  14560. }
  14561. //NaN
  14562. if (item.GuestName.Contains("NaN"))
  14563. {
  14564. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14565. }
  14566. }
  14567. if (guestIds.Count > 0)
  14568. {
  14569. guestIds = guestIds.Distinct().ToList();
  14570. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14571. if (guestDatas1.Count > 0)
  14572. {
  14573. guestNames = "";
  14574. foreach (var guest in guestDatas1)
  14575. {
  14576. string guestName = "";
  14577. if (guest.Sex == 0) guestName += @"MR.";
  14578. else if (guest.Sex == 1) guestName += @"MS.";
  14579. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14580. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14581. guestNames += @$"{guestName.Trim()}、";
  14582. }
  14583. if (guestNames.Length > 0)
  14584. {
  14585. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14586. }
  14587. }
  14588. }
  14589. //if (!string.IsNullOrEmpty(guestNames))
  14590. //{
  14591. hrDtas[i].GuestName = guestNames;
  14592. //}
  14593. }
  14594. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14595. Document doc = new Document();
  14596. DocumentBuilder builder = new DocumentBuilder(doc);
  14597. try
  14598. {
  14599. builder.MoveToDocumentStart();
  14600. foreach (var item in hrDtas)
  14601. {
  14602. //标题
  14603. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14604. builder.ParagraphFormat.LineSpacing = 1;
  14605. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14606. builder.ParagraphFormat.Style.Font.Size = 9;
  14607. builder.ParagraphFormat.Style.Font.Bold = true;
  14608. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14609. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14610. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14611. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14612. builder.ParagraphFormat.LineSpacing = 1;
  14613. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14614. builder.ParagraphFormat.Style.Font.Size = 9;
  14615. builder.ParagraphFormat.Style.Font.Bold = true;
  14616. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14617. builder.StartTable();
  14618. // 设置边框颜色
  14619. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14620. //设置边框样式
  14621. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14622. //表格
  14623. #region 第一行
  14624. builder.InsertCell();
  14625. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14626. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14627. //builder.CellFormat.AllowAutoFit = false;
  14628. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14629. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14630. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14631. builder.CellFormat.WrapText = true; //自动换行
  14632. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14633. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14634. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14635. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14636. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14637. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14638. builder.Write("TOUR NO:");
  14639. builder.InsertCell();
  14640. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14641. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14642. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14643. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14644. builder.ParagraphFormat.Style.Font.Bold = false;
  14645. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14646. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14647. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14648. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14649. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14650. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14651. builder.Write($"{dele?.TourCode ?? "-"}");
  14652. builder.InsertCell();
  14653. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14654. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14655. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14656. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14657. builder.ParagraphFormat.Style.Font.Bold = false;
  14658. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14659. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14660. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14661. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14662. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14663. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14664. builder.Write($"CITY:");
  14665. builder.InsertCell();
  14666. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14667. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14668. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14669. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14670. builder.ParagraphFormat.Style.Font.Bold = false;
  14671. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14672. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14673. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14674. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14675. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14676. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14677. builder.Write($"{item.City}");
  14678. builder.EndRow();
  14679. #endregion
  14680. #region 第二行
  14681. builder.InsertCell();
  14682. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14683. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14684. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14685. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14686. builder.ParagraphFormat.Style.Font.Bold = false;
  14687. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14688. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14689. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14690. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14691. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14692. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14693. builder.Write("CONFIRMATION NO:");
  14694. builder.InsertCell();
  14695. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14696. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14697. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14698. builder.ParagraphFormat.Style.Font.Bold = false;
  14699. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14700. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14701. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14702. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14703. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14704. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14705. builder.CellFormat.VerticalMerge = CellMerge.None;
  14706. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14707. builder.Write($"{item.DetermineNo}");
  14708. builder.InsertCell();
  14709. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14710. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14711. builder.InsertCell();
  14712. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14713. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14714. builder.EndRow();
  14715. #endregion
  14716. #region 第三行
  14717. builder.InsertCell();
  14718. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14719. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14720. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14721. builder.ParagraphFormat.Style.Font.Bold = false;
  14722. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14723. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14724. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14725. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14726. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14727. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14728. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14729. builder.Write($"HOTEL NAME:");
  14730. builder.InsertCell();
  14731. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14732. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14733. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14734. builder.ParagraphFormat.Style.Font.Bold = false;
  14735. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14736. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14737. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14738. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14739. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14740. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14741. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14742. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14743. builder.Write($"{item.HotelName}");
  14744. builder.InsertCell();
  14745. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14746. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14747. builder.InsertCell();
  14748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14749. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14750. builder.EndRow();
  14751. #endregion
  14752. #region 第四行
  14753. builder.InsertCell();
  14754. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14755. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14756. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14757. builder.ParagraphFormat.Style.Font.Bold = false;
  14758. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14759. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14760. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14761. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14762. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14763. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14764. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14765. builder.Write($"HOTEL ADDRESS:");
  14766. builder.InsertCell();
  14767. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14768. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14769. builder.ParagraphFormat.Style.Font.Size = 8;
  14770. builder.ParagraphFormat.Style.Font.Bold = false;
  14771. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14772. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14773. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14774. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14775. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14776. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14777. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14778. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14779. builder.Write($"{item.HotelAddress}");
  14780. builder.InsertCell();
  14781. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14782. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14783. builder.InsertCell();
  14784. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14785. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14786. builder.EndRow();
  14787. #endregion
  14788. #region 第五行
  14789. builder.InsertCell();
  14790. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14791. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14792. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14793. builder.ParagraphFormat.Style.Font.Bold = false;
  14794. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14795. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14796. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14797. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14798. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14799. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14800. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14801. builder.Write("TEL:");
  14802. builder.InsertCell();
  14803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14804. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14805. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14806. builder.ParagraphFormat.Style.Font.Bold = false;
  14807. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14808. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14809. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14810. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14811. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14812. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14813. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14814. builder.Write($"{item.HotelTel}");
  14815. builder.InsertCell();
  14816. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14817. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14818. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14819. builder.ParagraphFormat.Style.Font.Bold = false;
  14820. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14821. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14822. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14823. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14824. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14825. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14826. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14827. builder.Write($"FAX:");
  14828. builder.InsertCell();
  14829. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14830. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14831. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14832. builder.ParagraphFormat.Style.Font.Bold = false;
  14833. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14834. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14835. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14836. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14837. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14838. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14839. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14840. builder.Write($"{item.HotelFax}");
  14841. builder.EndRow();
  14842. #endregion
  14843. #region 第六行
  14844. builder.InsertCell();
  14845. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14846. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14847. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14848. builder.ParagraphFormat.Style.Font.Bold = false;
  14849. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14850. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14851. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14852. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14853. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14854. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14855. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14856. builder.Write("CHECK IN:");
  14857. builder.InsertCell();
  14858. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14859. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14860. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14861. builder.ParagraphFormat.Style.Font.Bold = false;
  14862. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14863. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14864. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14865. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14866. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14867. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14868. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14869. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14870. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14871. builder.Write($"{checkInStr}");
  14872. builder.InsertCell();
  14873. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14874. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14875. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14876. builder.ParagraphFormat.Style.Font.Bold = false;
  14877. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14878. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14879. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14880. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14881. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14882. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14883. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14884. builder.Write($"CHECK OUT:");
  14885. builder.InsertCell();
  14886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14887. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14888. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14889. builder.ParagraphFormat.Style.Font.Bold = false;
  14890. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14891. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14892. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14893. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14894. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14895. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14896. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14897. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14898. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14899. builder.Write($"{checkOutStr}");
  14900. builder.EndRow();
  14901. #endregion
  14902. #region 第七行
  14903. builder.InsertCell();
  14904. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14905. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14906. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14907. builder.ParagraphFormat.Style.Font.Bold = false;
  14908. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14909. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14910. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14911. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14912. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14913. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14914. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14915. builder.Write($"GUEST NAME:");
  14916. builder.InsertCell();
  14917. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14918. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14919. builder.ParagraphFormat.Style.Font.Size = 8;
  14920. builder.ParagraphFormat.Style.Font.Bold = false;
  14921. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14922. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14923. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14924. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14925. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14926. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14927. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14928. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14929. builder.Write($"{item.GuestName}");
  14930. builder.InsertCell();
  14931. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14932. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14933. builder.InsertCell();
  14934. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14935. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14936. builder.EndRow();
  14937. #endregion
  14938. #region 第八行
  14939. builder.InsertCell();
  14940. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14941. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14942. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14943. builder.ParagraphFormat.Style.Font.Bold = false;
  14944. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14945. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14946. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14947. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14948. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14949. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14950. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14951. builder.Write($"ROOM TYPE:");
  14952. builder.InsertCell();
  14953. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14954. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14955. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14956. builder.ParagraphFormat.Style.Font.Bold = false;
  14957. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14958. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14959. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14960. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14961. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14962. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14963. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14964. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14965. builder.Write($"{item.RoomExplanation}");
  14966. builder.InsertCell();
  14967. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14968. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14969. builder.InsertCell();
  14970. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14971. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14972. builder.EndRow();
  14973. #endregion
  14974. #region 第九行
  14975. builder.InsertCell();
  14976. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14977. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14978. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14979. builder.ParagraphFormat.Style.Font.Bold = false;
  14980. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14981. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14982. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14983. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14984. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14985. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14986. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14987. builder.Write($"NOTE:");
  14988. builder.InsertCell();
  14989. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14990. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14991. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14992. builder.ParagraphFormat.Style.Font.Bold = false;
  14993. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14994. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14995. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14996. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14997. 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.");
  14998. builder.InsertCell();
  14999. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15000. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15001. builder.InsertCell();
  15002. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15003. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15004. builder.EndRow();
  15005. #endregion
  15006. builder.EndTable();
  15007. //换行
  15008. builder.Writeln("");
  15009. builder.Writeln("");
  15010. }
  15011. #region 获取文档中的所有表格 设置文字自适应
  15012. // 获取文档中的所有表格。
  15013. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15014. {
  15015. // 遍历表格中的所有行。
  15016. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15017. {
  15018. foreach (Cell cell in row.Cells)
  15019. {
  15020. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15021. cellFormat.Width = 0;
  15022. }
  15023. }
  15024. }
  15025. #endregion
  15026. #region 设置页眉
  15027. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15028. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15029. if (System.IO.File.Exists(voucherHeaderPath))
  15030. {
  15031. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15032. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15033. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15034. Shape shape = builder.InsertImage(imageBytes);
  15035. // 调整图片位置
  15036. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15037. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15038. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15039. shape.Left = 0; // 将图片距离页面左边缘的距离
  15040. shape.Width = 81; // 设置图片宽度
  15041. shape.Height = 36; // 设置图片高度
  15042. }
  15043. //靠右
  15044. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15045. //// 设置页脚上下边距
  15046. //builder.PageSetup.HeaderDistance = 42;
  15047. // 添加页眉线
  15048. Aspose.Words.Border borderHeader = null;
  15049. try
  15050. {
  15051. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15052. }
  15053. catch (Exception e)
  15054. {
  15055. // TODO Auto-generated catch block
  15056. //e.printStackTrace();
  15057. }
  15058. borderHeader.Shadow = true;
  15059. borderHeader.DistanceFromText = 2;
  15060. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15061. #endregion
  15062. }
  15063. catch (Exception ex)
  15064. {
  15065. }
  15066. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15067. doc.Save(fileDir);
  15068. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15069. return Ok(JsonView(true, "操作成功!", Url));
  15070. }
  15071. /// <summary>
  15072. /// 酒店预订
  15073. /// 生成 预定成本 Excel
  15074. /// </summary>
  15075. /// <param name="_dto"></param>
  15076. /// <returns></returns>
  15077. [HttpPost]
  15078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15079. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15080. {
  15081. #region 参数验证
  15082. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15083. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15084. if (!vadalitorRes.IsValid)
  15085. {
  15086. var errors = new StringBuilder();
  15087. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15088. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15089. }
  15090. #region 团组操作权限验证 76 酒店预定模块
  15091. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15092. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15093. #endregion
  15094. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15095. #region 页面操作权限验证
  15096. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15097. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15098. #endregion
  15099. #endregion
  15100. decimal _rate = 1.00M;
  15101. string _currency = string.Empty;
  15102. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15103. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15104. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15105. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15106. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15107. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15108. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15109. if (_GroupCostParameter == null)
  15110. {
  15111. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15112. bool isIntType = int.TryParse(_currency, out int currId);
  15113. if (isIntType)
  15114. {
  15115. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15116. }
  15117. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15118. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15119. if (currInfo == null)
  15120. {
  15121. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15122. }
  15123. else _rate = currInfo.Rate;
  15124. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15125. {
  15126. _rate = _GroupCostParameter.Rate;
  15127. }
  15128. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15129. //string strFileName = "HotelStatement/";
  15130. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15131. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15132. var rateDatas = new List<dynamic>();
  15133. #region 数据处理
  15134. foreach (var item in hrDtas)
  15135. {
  15136. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15137. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15138. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15139. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15140. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15141. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15142. {
  15143. continue;
  15144. }
  15145. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15146. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15147. string singleRoomFeeStr = string.Empty,
  15148. doubleRoomFeeStr = string.Empty,
  15149. suiteRoomFeeStr = string.Empty,
  15150. otherRoomFeeStr = string.Empty,
  15151. payMoneyStr = string.Empty,
  15152. cardPriceStr = string.Empty;
  15153. if (roomCurr.Equals("CNY"))
  15154. {
  15155. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15156. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15157. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15158. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15159. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15160. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15161. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15162. }
  15163. else
  15164. {
  15165. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15166. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15167. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15168. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15169. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15170. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15171. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15172. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15173. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15174. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15175. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15176. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15177. if (ccpPaymentCurrency.Equals("CNY"))
  15178. {
  15179. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15180. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15181. }
  15182. else
  15183. {
  15184. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15185. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15186. }
  15187. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15188. if (hotelcardPriceCurrency.Equals("CNY"))
  15189. {
  15190. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15191. }
  15192. else
  15193. {
  15194. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15195. }
  15196. }
  15197. string breakfastPriceStr = string.Empty,
  15198. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15199. governmentRentStr = string.Empty,
  15200. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15201. cityTaxStr = string.Empty,
  15202. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15203. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15204. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15205. {
  15206. if (breakfastCurrency1.Equals("CNY"))
  15207. {
  15208. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15209. }
  15210. else
  15211. {
  15212. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15213. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15214. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15215. }
  15216. }
  15217. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15218. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15219. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15220. {
  15221. if (governmentRentCurrency.Equals("CNY"))
  15222. {
  15223. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15224. }
  15225. else
  15226. {
  15227. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15228. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15229. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15230. }
  15231. }
  15232. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15233. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15234. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15235. {
  15236. if (cityTaxStrCurrency1.Equals("CNY"))
  15237. {
  15238. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15239. }
  15240. else
  15241. {
  15242. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15243. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15244. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15245. }
  15246. }
  15247. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15248. int payDId = roomInfo?.PayDId ?? 0;
  15249. pcfds.Add(new HotelReservations_PCFD_View()
  15250. {
  15251. City = item.City,
  15252. HotelName = item.HotelName,
  15253. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15254. // SingleRoomCount = item.SingleRoomCount,
  15255. SingleRoomPrice = singleRoomFeeStr,
  15256. // DoubleRoomCount = item.DoubleRoomCount,
  15257. DoubleRoomPrice = doubleRoomFeeStr,
  15258. //SuiteRoomCount = item.SuiteRoomCount,
  15259. SuiteRoomPrice = suiteRoomFeeStr,
  15260. OtherRoomPrice = otherRoomFeeStr,
  15261. //OtherRoomCount = item.OtherRoomCount,
  15262. BreakfastPrice = breakfastPriceStr,
  15263. GovernmentRent = governmentRentStr,
  15264. CityTax = cityTaxStr,
  15265. RoomExplanation = item.RoomExplanation,
  15266. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15267. PayTime = roomInfo?.ConsumptionDate,
  15268. BankNo = roomInfo?.BankNo,
  15269. PayMoney = payMoneyStr,
  15270. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15271. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15272. CardPrice = cardPriceStr,
  15273. Remark = ccpInfo.Remark
  15274. });
  15275. }
  15276. #endregion
  15277. //载入模板
  15278. WorkbookDesigner designer = new WorkbookDesigner();
  15279. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15280. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15281. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15282. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15283. var rateDatas1 = rateDatas.Distinct();
  15284. var rateStr = string.Empty;
  15285. foreach (var item in rateDatas1)
  15286. {
  15287. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15288. }
  15289. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15290. designer.SetDataSource("Opertor", userInfo.CnName);
  15291. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15292. dt.TableName = "ViewMyHotelReservations";
  15293. designer.SetDataSource(dt);
  15294. designer.Process();
  15295. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15296. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15297. designer.Workbook.Save(serverPath);
  15298. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15299. #region 删除指定行
  15300. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15301. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15302. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15303. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15304. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15305. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15306. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15307. cssIndex = dt.Columns["CityTax"].Ordinal,
  15308. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15309. remarkIndex = dt.Columns["Remark"].Ordinal;
  15310. //删除指定列
  15311. foreach (DataRow item in dt.Rows)
  15312. {
  15313. string singleStr = item["SingleRoomPrice"].ToString();
  15314. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15315. if (containsDigitButNotZero1) singleDel = false;
  15316. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15317. string doubleStr = item["DoubleRoomPrice"].ToString();
  15318. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15319. if (containsDigitButNotZero2) doubleDel = false;
  15320. string suiteStr = item["SuiteRoomPrice"].ToString();
  15321. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15322. if (containsDigitButNotZero3) suiteDel = false;
  15323. string otherStr = item["OtherRoomPrice"].ToString();
  15324. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15325. if (containsDigitButNotZero4) otherDel = false;
  15326. string zcStr = item["BreakfastPrice"].ToString();
  15327. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15328. if (containsDigitButNotZero5) zcDel = false;
  15329. string dsStr = item["GovernmentRent"].ToString();
  15330. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15331. if (containsDigitButNotZero6) dsDel = false;
  15332. string cssStr = item["CityTax"].ToString();
  15333. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15334. if (containsDigitButNotZero7) cssDel = false;
  15335. string cpStr = item["ConsumptionPatterns"].ToString();
  15336. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15337. string remarkStr = item["Remark"].ToString();
  15338. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15339. }
  15340. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15341. DeleteColumn(serverPath, cpIndex, cpDel);
  15342. DeleteColumn(serverPath, dsIndex, dsDel);
  15343. DeleteColumn(serverPath, cssIndex, cssDel);
  15344. DeleteColumn(serverPath, zcIndex, zcDel);
  15345. DeleteColumn(serverPath, otherIndex, otherDel);
  15346. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15347. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15348. DeleteColumn(serverPath, singleIndex, singleDel);
  15349. #endregion
  15350. //只保留第一个表格
  15351. DeleteSheet(serverPath);
  15352. return Ok(JsonView(true, "操作成功", url = rst));
  15353. }
  15354. else
  15355. {
  15356. _currency = _GroupCostParameter.Currency;
  15357. bool isIntType = int.TryParse(_currency, out int currId);
  15358. if (isIntType)
  15359. {
  15360. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15361. }
  15362. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15363. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15364. if (currInfo == null)
  15365. {
  15366. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15367. }
  15368. if (!_currency.ToUpper().Equals("CNY"))
  15369. {
  15370. _rate = _GroupCostParameter.Rate;
  15371. }
  15372. _rate = currInfo.Rate;
  15373. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15374. //string strFileName = "HotelStatement/";
  15375. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15376. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15377. #region 数据处理
  15378. foreach (var item in hrDtas)
  15379. {
  15380. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15381. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15382. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15383. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15384. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15385. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15386. string singleRoomFeeStr = string.Empty,
  15387. doubleRoomFeeStr = string.Empty,
  15388. suiteRoomFeeStr = string.Empty,
  15389. otherRoomFeeStr = string.Empty,
  15390. payMoneyStr = string.Empty,
  15391. cardPriceStr = string.Empty;
  15392. if (roomCurr.Equals(_currency))
  15393. {
  15394. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15395. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15396. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15397. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15398. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15399. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15400. }
  15401. else
  15402. {
  15403. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15404. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15405. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15406. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15407. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15408. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15409. }
  15410. string breakfastPriceStr = string.Empty,
  15411. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15412. governmentRentStr = string.Empty,
  15413. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15414. cityTaxStrStr = string.Empty,
  15415. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15416. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15417. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15418. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15419. int payDId = roomInfo?.PayDId ?? 0;
  15420. pcfds.Add(new HotelReservations_PCFD_View()
  15421. {
  15422. City = item.City,
  15423. HotelName = item.HotelName,
  15424. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15425. // SingleRoomCount = item.SingleRoomCount,
  15426. SingleRoomPrice = singleRoomFeeStr,
  15427. // DoubleRoomCount = item.DoubleRoomCount,
  15428. DoubleRoomPrice = doubleRoomFeeStr,
  15429. //SuiteRoomCount = item.SuiteRoomCount,
  15430. SuiteRoomPrice = suiteRoomFeeStr,
  15431. OtherRoomPrice = otherRoomFeeStr,
  15432. //OtherRoomCount = item.OtherRoomCount,
  15433. BreakfastPrice = breakfastPriceStr,
  15434. GovernmentRent = governmentRentStr,
  15435. CityTax = cityTaxStrStr,
  15436. RoomExplanation = item.RoomExplanation,
  15437. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15438. PayTime = roomInfo?.ConsumptionDate,
  15439. BankNo = roomInfo?.BankNo,
  15440. PayMoney = payMoneyStr,
  15441. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15442. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15443. CardPrice = cardPriceStr,
  15444. Remark = ccpInfo.Remark
  15445. });
  15446. }
  15447. #endregion
  15448. //载入模板
  15449. WorkbookDesigner designer = new WorkbookDesigner();
  15450. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15451. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15452. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15453. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15454. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15455. designer.SetDataSource("Opertor", userInfo.CnName);
  15456. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15457. dt.TableName = "ViewMyHotelReservations";
  15458. designer.SetDataSource(dt);
  15459. designer.Process();
  15460. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15461. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15462. designer.Workbook.Save(serverPath);
  15463. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15464. #region 删除指定行
  15465. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15466. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15467. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15468. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15469. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15470. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15471. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15472. cssIndex = dt.Columns["CityTax"].Ordinal,
  15473. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15474. remarkIndex = dt.Columns["Remark"].Ordinal;
  15475. //删除指定列
  15476. foreach (DataRow item in dt.Rows)
  15477. {
  15478. string singleStr = item["SingleRoomPrice"].ToString();
  15479. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15480. if (containsDigitButNotZero1) singleDel = false;
  15481. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15482. string doubleStr = item["DoubleRoomPrice"].ToString();
  15483. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15484. if (containsDigitButNotZero2) doubleDel = false;
  15485. string suiteStr = item["SuiteRoomPrice"].ToString();
  15486. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15487. if (containsDigitButNotZero3) suiteDel = false;
  15488. string otherStr = item["OtherRoomPrice"].ToString();
  15489. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15490. if (containsDigitButNotZero4) otherDel = false;
  15491. string zcStr = item["BreakfastPrice"].ToString();
  15492. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15493. if (containsDigitButNotZero5) zcDel = false;
  15494. string dsStr = item["GovernmentRent"].ToString();
  15495. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15496. if (containsDigitButNotZero6) dsDel = false;
  15497. string cssStr = item["CityTax"].ToString();
  15498. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15499. if (containsDigitButNotZero7) cssDel = false;
  15500. string cpStr = item["ConsumptionPatterns"].ToString();
  15501. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15502. string remarkStr = item["Remark"].ToString();
  15503. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15504. }
  15505. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15506. DeleteColumn(serverPath, cpIndex, cpDel);
  15507. DeleteColumn(serverPath, dsIndex, dsDel);
  15508. DeleteColumn(serverPath, cssIndex, cssDel);
  15509. DeleteColumn(serverPath, zcIndex, zcDel);
  15510. DeleteColumn(serverPath, otherIndex, otherDel);
  15511. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15512. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15513. DeleteColumn(serverPath, singleIndex, singleDel);
  15514. #endregion
  15515. //只保留第一个表格
  15516. DeleteSheet(serverPath);
  15517. return Ok(JsonView(true, "操作成功", url = rst));
  15518. }
  15519. //return Ok(JsonView(false));
  15520. }
  15521. /// <summary>
  15522. /// 删除指定列
  15523. /// </summary>
  15524. /// <param name="file"></param>
  15525. /// <param name="columnIndex"></param>
  15526. /// <param name="isDel"></param>
  15527. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15528. {
  15529. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15530. //wb.Save(file);
  15531. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15532. if (sheet1 != null)
  15533. {
  15534. if (isDel)
  15535. {
  15536. Cells cells = sheet1.Cells;
  15537. cells.DeleteColumn(columnIndex);
  15538. }
  15539. }
  15540. wb.Save(file);
  15541. }
  15542. /// <summary>
  15543. /// 删除sheet
  15544. /// </summary>
  15545. /// <param name="file"></param>
  15546. /// <param name="sheetName"></param>
  15547. private void DeleteSheet(string file, string sheetName = "")
  15548. {
  15549. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15550. //wb.Save(file);
  15551. List<string> sheets = new List<string>();
  15552. foreach (var item in wb.Worksheets)
  15553. {
  15554. sheets.Add(item.Name);
  15555. }
  15556. if (sheets.Count > 0)
  15557. {
  15558. sheets.RemoveAt(0);//不删除第一个sheet
  15559. foreach (var item in sheets)
  15560. {
  15561. wb.Worksheets.RemoveAt(item);
  15562. }
  15563. }
  15564. wb.Save(file);
  15565. }
  15566. /// <summary>
  15567. /// 酒店预订
  15568. /// 确认单
  15569. /// </summary>
  15570. /// <param name="_dto"></param>
  15571. /// <returns></returns>
  15572. [HttpPost]
  15573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15574. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15575. {
  15576. try
  15577. {
  15578. #region 参数验证
  15579. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15580. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15581. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15582. #region 团组操作权限验证 76 酒店预定模块
  15583. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15584. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15585. #endregion
  15586. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15587. #region 页面操作权限验证
  15588. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15589. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15590. #endregion
  15591. #endregion
  15592. //团组信息
  15593. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15594. //酒店数据
  15595. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15596. if (listhoteldata.Count < 0)
  15597. {
  15598. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15599. }
  15600. //利datatable存储
  15601. DataTable dt = new DataTable();
  15602. dt.Columns.Add("CheckInDate", typeof(string));
  15603. dt.Columns.Add("City", typeof(string));
  15604. dt.Columns.Add("Hotel", typeof(string));
  15605. dt.Columns.Add("Room", typeof(string));
  15606. for (int i = 0; i < listhoteldata.Count; i++)
  15607. {
  15608. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15609. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15610. while (dayStart < dayEnd)
  15611. {
  15612. string temp = "";
  15613. DataRow row = dt.NewRow();
  15614. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15615. row["City"] = listhoteldata[i].City;
  15616. row["Hotel"] = listhoteldata[i].HotelName;
  15617. if (listhoteldata[i].SingleRoomCount > 0)
  15618. {
  15619. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15620. }
  15621. if (listhoteldata[i].DoubleRoomCount > 0)
  15622. {
  15623. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15624. }
  15625. if (listhoteldata[i].SuiteRoomCount > 0)
  15626. {
  15627. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15628. }
  15629. if (listhoteldata[i].OtherRoomCount > 0)
  15630. {
  15631. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15632. }
  15633. row["Room"] = temp;
  15634. dt.Rows.Add(row);
  15635. dayStart = dayStart.AddDays(1);
  15636. }
  15637. }
  15638. Dictionary<string, string> dic = new Dictionary<string, string>();
  15639. dic.Add("Dele", di.TeamName);
  15640. dic.Add("City", di.VisitCountry);
  15641. //模板路径
  15642. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15643. //载入模板
  15644. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15645. DocumentBuilder builder = new DocumentBuilder(doc);
  15646. foreach (var key in dic.Keys)
  15647. {
  15648. builder.MoveToBookmark(key);
  15649. builder.Write(dic[key]);
  15650. }
  15651. //获取word里所有表格
  15652. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15653. //获取所填表格的序数
  15654. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15655. var rowStart = tableOne.Rows[0]; //获取第1行
  15656. //循环赋值
  15657. for (int i = 0; i < dt.Rows.Count; i++)
  15658. {
  15659. builder.MoveToCell(0, i + 1, 0, 0);
  15660. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15661. builder.MoveToCell(0, i + 1, 1, 0);
  15662. builder.Write(dt.Rows[i]["City"].ToString());
  15663. builder.MoveToCell(0, i + 1, 2, 0);
  15664. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15665. builder.MoveToCell(0, i + 1, 3, 0);
  15666. builder.Write(dt.Rows[i]["Room"].ToString());
  15667. }
  15668. //删除多余行
  15669. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15670. {
  15671. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15672. }
  15673. string strFileName = di.TeamName + "酒店确认单.doc";
  15674. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15675. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15676. return Ok(JsonView(true, "成功", url));
  15677. }
  15678. catch (Exception ex)
  15679. {
  15680. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15681. }
  15682. }
  15683. #endregion
  15684. #region 团组状态
  15685. /// <summary>
  15686. /// 团组状态列表 Page
  15687. /// </summary>
  15688. /// <param name="dto">团组列表请求dto</param>
  15689. /// <returns></returns>
  15690. [HttpPost]
  15691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15692. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15693. {
  15694. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15695. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15696. {
  15697. string sqlWhere = string.Empty;
  15698. if (dto.IsSure == 0) //未完成
  15699. {
  15700. sqlWhere += string.Format(@" And IsSure = 0");
  15701. }
  15702. else if (dto.IsSure == 1) //已完成
  15703. {
  15704. sqlWhere += string.Format(@" And IsSure = 1");
  15705. }
  15706. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15707. {
  15708. string tj = dto.SearchCriteria;
  15709. 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}%')",
  15710. tj, tj, tj, tj, tj);
  15711. }
  15712. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15713. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15714. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15715. From (
  15716. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15717. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15718. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15719. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15720. From Grp_DelegationInfo gdi
  15721. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15722. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15723. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15724. Where gdi.IsDel = 0 {0}
  15725. ) temp ", sqlWhere);
  15726. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15727. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15728. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15729. }
  15730. else
  15731. {
  15732. return Ok(JsonView(false, "查询失败"));
  15733. }
  15734. }
  15735. /// <summary>
  15736. /// 团组状态
  15737. /// 设置操作完成
  15738. /// </summary>
  15739. /// <param name="dto">团组列表请求dto</param>
  15740. /// <returns></returns>
  15741. [HttpPost]
  15742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15743. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15744. {
  15745. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15746. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15747. {
  15748. Id = dto.Id,
  15749. IsSure = 1
  15750. };
  15751. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15752. .UpdateColumns(it => new { it.IsSure })
  15753. .WhereColumns(it => new { it.Id })
  15754. .ExecuteCommandAsync();
  15755. if (result > 0)
  15756. {
  15757. return Ok(JsonView(true, "操作完成!"));
  15758. }
  15759. return Ok(JsonView(false, "操作失败!"));
  15760. }
  15761. #endregion
  15762. #region 保险费用录入
  15763. /// <summary>
  15764. /// 根据团组Id查询保险费用列表
  15765. /// </summary>
  15766. /// <param name="dto"></param>
  15767. /// <returns></returns>
  15768. [HttpPost]
  15769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15770. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15771. {
  15772. Result groupData = await _customersRep.CustomersByDiId(dto);
  15773. if (groupData.Code != 0)
  15774. {
  15775. return Ok(JsonView(false, groupData.Msg));
  15776. }
  15777. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15778. }
  15779. /// <summary>
  15780. /// 根据保险费用Id查询保险费用详细
  15781. /// </summary>
  15782. /// <param name="dto"></param>
  15783. /// <returns></returns>
  15784. [HttpPost]
  15785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15786. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15787. {
  15788. try
  15789. {
  15790. Result groupData = await _customersRep.CustomersById(dto);
  15791. if (groupData.Code != 0)
  15792. {
  15793. return Ok(JsonView(false, groupData.Msg));
  15794. }
  15795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15796. }
  15797. catch (Exception ex)
  15798. {
  15799. return Ok(JsonView(false, ex.Message));
  15800. }
  15801. }
  15802. /// <summary>
  15803. /// 保险费用录入页面初始化绑定
  15804. /// </summary>
  15805. /// <param name="dto"></param>
  15806. /// <returns></returns>
  15807. [HttpPost]
  15808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15809. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15810. {
  15811. try
  15812. {
  15813. Result groupData = await _customersRep.CustomersInitialize(dto);
  15814. if (groupData.Code != 0)
  15815. {
  15816. return Ok(JsonView(false, groupData.Msg));
  15817. }
  15818. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15819. }
  15820. catch (Exception ex)
  15821. {
  15822. return Ok(JsonView(false, ex.Message));
  15823. }
  15824. }
  15825. /// <summary>
  15826. /// 保险费用操作(Status:1.新增,2.修改)
  15827. /// </summary>
  15828. /// <param name="dto"></param>
  15829. /// <returns></returns>
  15830. [HttpPost]
  15831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15832. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15833. {
  15834. Result groupData = await _customersRep.OpCustomers(dto);
  15835. if (groupData.Code != 0)
  15836. {
  15837. return Ok(JsonView(false, groupData.Msg));
  15838. }
  15839. #region 应用推送
  15840. try
  15841. {
  15842. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15843. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15844. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15845. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15846. //自动审核
  15847. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15848. //2024-10-21 新增LZ UID
  15849. var userIds = new List<int>() { 21 };
  15850. string title = $"系统通知";
  15851. var diId = dto.DiId;
  15852. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15853. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15854. string content = "";
  15855. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15856. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15857. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15858. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15859. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15860. }
  15861. catch (Exception ex)
  15862. {
  15863. }
  15864. #endregion
  15865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15866. }
  15867. /// <summary>
  15868. /// 保险文件上传
  15869. /// </summary>
  15870. /// <param name="file"></param>
  15871. /// <returns></returns>
  15872. [HttpPost]
  15873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15874. public async Task<IActionResult> UploadCus(IFormFile file)
  15875. {
  15876. try
  15877. {
  15878. if (file != null)
  15879. {
  15880. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15881. //文件名称
  15882. string projectFileName = file.FileName;
  15883. //上传的文件的路径
  15884. string filePath = "";
  15885. if (!Directory.Exists(fileDir))
  15886. {
  15887. Directory.CreateDirectory(fileDir);
  15888. }
  15889. //上传的文件的路径
  15890. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15891. using (FileStream fs = System.IO.File.Create(filePath))
  15892. {
  15893. file.CopyTo(fs);
  15894. fs.Flush();
  15895. }
  15896. return Ok(JsonView(true, "上传成功!", projectFileName));
  15897. }
  15898. else
  15899. {
  15900. return Ok(JsonView(false, "上传失败!"));
  15901. }
  15902. }
  15903. catch (Exception ex)
  15904. {
  15905. return Ok(JsonView(false, "程序错误!"));
  15906. throw;
  15907. }
  15908. }
  15909. /// <summary>
  15910. /// 保险删除指定文件
  15911. /// </summary>
  15912. /// <param name="dto"></param>
  15913. /// <returns></returns>
  15914. [HttpPost]
  15915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15916. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15917. {
  15918. try
  15919. {
  15920. string filePath = "";
  15921. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15922. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15923. //int id = 0;
  15924. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15925. // 删除该文件
  15926. try
  15927. {
  15928. System.IO.File.Delete(filePath);
  15929. 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()
  15930. {
  15931. Attachment = "",
  15932. }).ExecuteCommandAsync();
  15933. if (result != 0)
  15934. {
  15935. return Ok(JsonView(true, "成功!"));
  15936. }
  15937. else
  15938. {
  15939. return Ok(JsonView(false, "失败!"));
  15940. }
  15941. }
  15942. catch (Exception)
  15943. {
  15944. 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()
  15945. {
  15946. Attachment = "",
  15947. }).ExecuteCommandAsync();
  15948. if (result != 0)
  15949. {
  15950. return Ok(JsonView(true, "成功!"));
  15951. }
  15952. else
  15953. {
  15954. return Ok(JsonView(false, "失败!"));
  15955. }
  15956. }
  15957. }
  15958. catch (Exception ex)
  15959. {
  15960. return Ok(JsonView(false, "程序错误!"));
  15961. throw;
  15962. }
  15963. }
  15964. /// <summary>
  15965. /// 保险费用操作(删除)
  15966. /// </summary>
  15967. /// <param name="dto"></param>
  15968. /// <returns></returns>
  15969. [HttpPost]
  15970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15971. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15972. {
  15973. try
  15974. {
  15975. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15976. if (!res)
  15977. {
  15978. return Ok(JsonView(false, "删除失败"));
  15979. }
  15980. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15981. {
  15982. IsDel = 1,
  15983. DeleteUserId = dto.DeleteUserId,
  15984. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15985. }).ExecuteCommandAsync();
  15986. return Ok(JsonView(true, "删除成功!"));
  15987. }
  15988. catch (Exception ex)
  15989. {
  15990. return Ok(JsonView(false, "程序错误!"));
  15991. throw;
  15992. }
  15993. }
  15994. #endregion
  15995. #region 接团客户名单 PageId 104
  15996. /// <summary>
  15997. /// 接团客户名单
  15998. /// 迁移数据(慎用!)
  15999. /// </summary>
  16000. /// <returns></returns>
  16001. [HttpPost]
  16002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16003. public async Task<IActionResult> PostTourClientListChange()
  16004. {
  16005. try
  16006. {
  16007. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16008. //var groupClinetData1
  16009. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16010. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16011. int updateCount = 0;
  16012. if (oldOAClientList.Count > 0)
  16013. {
  16014. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16015. _sqlSugar.BeginTran();
  16016. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16017. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16018. foreach (var item in oldOAClientList)
  16019. {
  16020. int comId = 0;
  16021. string format = "yyyy-MM-dd HH:mm:ss";
  16022. string data11 = "1990-01-01 00:00";
  16023. var data1 = IsValidDate(item.OPdate, format);
  16024. if (data1) data11 = item.OPdate;
  16025. //客户公司验证
  16026. if (!string.IsNullOrEmpty(item.Company))
  16027. {
  16028. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16029. if (clientComInfo == null) // add
  16030. {
  16031. var addInfo = new Crm_CustomerCompany()
  16032. {
  16033. CompanyAbbreviation = "",
  16034. CompanyFullName = item.Company,
  16035. Address = "",
  16036. PostCodes = "",
  16037. LastedOpUserId = item.OPer,
  16038. LastedOpDt = Convert.ToDateTime(data11),
  16039. CreateUserId = item.OPer,
  16040. CreateTime = Convert.ToDateTime(data11),
  16041. IsDel = 0
  16042. };
  16043. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16044. if (comId1 > 0) comId = comId1;
  16045. }
  16046. else comId = clientComInfo.Id;
  16047. }
  16048. //客户人员验证
  16049. int clientId = 0;
  16050. string name = item.LastName + item.Name;
  16051. if (!string.IsNullOrEmpty(name))
  16052. {
  16053. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16054. if (clientInfo == null)
  16055. {
  16056. DateTime? dateTime = null;
  16057. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16058. if (isDt) dateTime = birthDayDt;
  16059. var addInfo1 = new Crm_DeleClient()
  16060. {
  16061. CrmCompanyId = comId,
  16062. DiId = -1,
  16063. LastName = item.LastName,
  16064. FirstName = item.Name,
  16065. OldName = "",
  16066. Pinyin = item.Pinyin,
  16067. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16068. Marriage = 0,
  16069. Phone = item.Phone,
  16070. Job = item.Job,
  16071. BirthDay = dateTime
  16072. };
  16073. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16074. if (clientId1 > 0) clientId = clientId1;
  16075. }
  16076. else clientId = clientInfo.Id;
  16077. }
  16078. if (clientId < 1)
  16079. {
  16080. continue;
  16081. }
  16082. int airType = 0;
  16083. if (item.AirType == "超经舱") airType = 459;
  16084. else if (item.AirType == "公务舱") airType = 458;
  16085. else if (item.AirType == "经济舱") airType = 460;
  16086. else if (item.AirType == "其他") airType = 565;
  16087. else if (item.AirType == "头等舱") airType = 457;
  16088. var _TourClientListEntity = new Grp_TourClientList()
  16089. {
  16090. DiId = item.Diid,
  16091. ClientId = clientId,
  16092. CreateUserId = item.OPer,
  16093. CreateTime = Convert.ToDateTime(data11),
  16094. Remark = item.Remark,
  16095. IsDel = item.Isdel,
  16096. ShippingSpaceTypeId = airType,
  16097. ShippingSpaceSpecialNeeds = item.AirRemark,
  16098. HotelSpecialNeeds = item.RoomType
  16099. };
  16100. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16101. if (_TourClientList > 0)
  16102. {
  16103. updateCount++;
  16104. }
  16105. }
  16106. _sqlSugar.CommitTran();
  16107. }
  16108. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16109. }
  16110. catch (Exception ex)
  16111. {
  16112. _sqlSugar.RollbackTran();
  16113. return Ok(JsonView(false, ex.Message));
  16114. }
  16115. //return Ok(JsonView(true));
  16116. }
  16117. private bool IsValidDate(string dateString, string format)
  16118. {
  16119. DateTime dateValue;
  16120. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16121. return valid;
  16122. }
  16123. /// <summary>
  16124. /// 接团客户名单
  16125. /// 根据团组Id查询List
  16126. /// </summary>
  16127. /// <param name="_dto"></param>
  16128. /// <returns></returns>
  16129. [HttpPost]
  16130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16131. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16132. {
  16133. #region 参数验证
  16134. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16135. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16136. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16137. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16138. #region 页面操作权限验证
  16139. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16140. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16141. #endregion
  16142. #endregion
  16143. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16144. if (viewData.Code != 0)
  16145. {
  16146. return Ok(JsonView(false, viewData.Msg));
  16147. }
  16148. return Ok(JsonView(viewData.Data));
  16149. }
  16150. /// <summary>
  16151. /// 接团客户名单
  16152. /// 基础数据 Init
  16153. /// </summary>
  16154. /// <param name="_dto"></param>
  16155. /// <returns></returns>
  16156. [HttpPost]
  16157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16158. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16159. {
  16160. #region 参数验证
  16161. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16162. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16163. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16164. #region 页面操作权限验证
  16165. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16166. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16167. #endregion
  16168. #endregion
  16169. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16170. }
  16171. /// <summary>
  16172. /// 接团客户名单
  16173. /// 根据 Id查询 Details
  16174. /// </summary>
  16175. /// <param name="_dto"></param>
  16176. /// <returns></returns>
  16177. [HttpPost]
  16178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16179. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16180. {
  16181. #region 参数验证
  16182. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16183. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16184. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16185. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16186. #region 页面操作权限验证
  16187. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16188. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16189. #endregion
  16190. #endregion
  16191. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16192. if (viewData.Code != 0)
  16193. {
  16194. return Ok(JsonView(false, viewData.Msg));
  16195. }
  16196. return Ok(JsonView(viewData.Data));
  16197. }
  16198. /// <summary>
  16199. /// 接团客户名单
  16200. /// Add Or Edit
  16201. /// </summary>
  16202. /// <param name="_dto"></param>
  16203. /// <returns></returns>
  16204. [HttpPost]
  16205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16206. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16207. {
  16208. #region 参数验证
  16209. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16210. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16211. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16212. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16213. #region 页面操作权限验证
  16214. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16215. if (_dto.Id == 0) //添加
  16216. {
  16217. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16218. }
  16219. else if (_dto.Id >= 0) //修改
  16220. {
  16221. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16222. }
  16223. #endregion
  16224. #endregion
  16225. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16226. if (viewData.Code != 0)
  16227. {
  16228. return Ok(JsonView(false, viewData.Msg));
  16229. }
  16230. return Ok(JsonView(true));
  16231. }
  16232. /// <summary>
  16233. /// 接团客户名单
  16234. /// json字符串 AddMultiple(添加多个)
  16235. /// </summary>
  16236. /// <param name="_dto"></param>
  16237. /// <returns></returns>
  16238. [HttpPost]
  16239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16240. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16241. {
  16242. #region 参数验证
  16243. string jsonLabel = _dto.JsonLabel;
  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 request = new TourClientListAddMultipleDto();
  16253. request.DiId = _dto.DiId;
  16254. request.UserId = _dto.UserId;
  16255. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16256. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16257. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16258. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16259. var infos = new List<TourClientListInfo>();
  16260. foreach (var data in datas)
  16261. {
  16262. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16263. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16264. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16265. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16266. {
  16267. continue;
  16268. }
  16269. infos.Add(new TourClientListInfo()
  16270. {
  16271. IsAccompany = 1,
  16272. LastName = lastName,
  16273. FirstName = firstName,
  16274. Pinyin = lastNameEn + @"/" + firstNameEn,
  16275. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16276. CompanyFullName = data.CompanyFullName,
  16277. Job = data.Job
  16278. });
  16279. }
  16280. if (infos.Any())
  16281. {
  16282. var viewData = await _tourClientListRep._AddMultiple(request);
  16283. if (viewData.Code != 0)
  16284. {
  16285. return Ok(JsonView(false, viewData.Msg));
  16286. }
  16287. return Ok(JsonView(true));
  16288. }
  16289. return Ok(JsonView(false));
  16290. }
  16291. /// <summary>
  16292. /// 接团客户名单
  16293. /// AddMultiple(添加多个)
  16294. /// </summary>
  16295. /// <param name="_dto"></param>
  16296. /// <returns></returns>
  16297. [HttpPost]
  16298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16299. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16300. {
  16301. #region 参数验证
  16302. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16303. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16304. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16305. #region 页面操作权限验证
  16306. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16307. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16308. #endregion
  16309. #endregion
  16310. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16311. if (viewData.Code != 0)
  16312. {
  16313. return Ok(JsonView(false, viewData.Msg));
  16314. }
  16315. return Ok(JsonView(true));
  16316. }
  16317. /// <summary>
  16318. /// 接团客户名单
  16319. /// Del
  16320. /// </summary>
  16321. /// <param name="_dto"></param>
  16322. /// <returns></returns>
  16323. [HttpPost]
  16324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16325. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16326. {
  16327. #region 参数验证
  16328. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16329. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16330. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16331. #region 页面操作权限验证
  16332. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16333. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16334. #endregion
  16335. #endregion
  16336. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16337. if (viewData.Code != 0)
  16338. {
  16339. return Ok(JsonView(false, viewData.Msg));
  16340. }
  16341. return Ok(JsonView(true));
  16342. }
  16343. /// <summary>
  16344. /// 接团客户名单
  16345. /// 文件下载 客户名单
  16346. /// </summary>
  16347. /// <param name="_dto"></param>
  16348. /// <returns></returns>
  16349. [HttpPost]
  16350. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16351. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16352. {
  16353. #region 参数验证
  16354. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16355. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16356. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16357. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16358. #region 页面操作权限验证
  16359. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16360. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16361. #endregion
  16362. #endregion
  16363. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16364. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16365. From Grp_TourClientList tcl
  16366. Left Join
  16367. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16368. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16369. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16370. From Crm_DeleClient dc
  16371. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16372. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16373. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16374. Where dc.IsDel = 0) temp
  16375. On temp.DcId =tcl.ClientId
  16376. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16377. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16378. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16379. //载入模板
  16380. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16381. if (_dto.Language == 1)
  16382. {
  16383. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16384. }
  16385. //载入模板
  16386. var doc = new Document(tempPath);
  16387. DocumentBuilder builder = new DocumentBuilder(doc);
  16388. //获取word里所有表格
  16389. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16390. //获取所填表格的序数
  16391. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16392. var rowStart = tableOne.Rows[0]; //获取第1行
  16393. if (_dto.Language == 0)
  16394. {
  16395. //循环赋值
  16396. for (int i = 0; i < DcList.Count; i++)
  16397. {
  16398. EncryptionProcessor.DecryptProperties(DcList[i]);
  16399. builder.MoveToCell(0, i + 1, 0, 0);
  16400. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16401. builder.MoveToCell(0, i + 1, 1, 0);
  16402. int sex = DcList[i].Sex;
  16403. string sexStr = string.Empty;
  16404. if (sex == 0) sexStr = "男";
  16405. else if (sex == 1) sexStr = "女";
  16406. else sexStr = "未设置";
  16407. builder.Write(sexStr);
  16408. builder.MoveToCell(0, i + 1, 2, 0);
  16409. string birthDay = DcList[i].BirthDay;
  16410. string birthDayStr = string.Empty;
  16411. if (!string.IsNullOrEmpty(birthDay))
  16412. {
  16413. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16414. }
  16415. builder.Write(birthDayStr);
  16416. builder.MoveToCell(0, i + 1, 3, 0);
  16417. string company = "";
  16418. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16419. {
  16420. company = DcList[i].CompanyFullName.ToString();
  16421. }
  16422. builder.Write(company);
  16423. builder.MoveToCell(0, i + 1, 4, 0);
  16424. builder.Write(DcList[i].Job);
  16425. }
  16426. }
  16427. else if (_dto.Language == 1)
  16428. {
  16429. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16430. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16431. List<string> transArrayStr = new List<string>();
  16432. string transStrRes1 = "";
  16433. for (int i = 0; i < DcList.Count; i++)
  16434. {
  16435. var dc = DcList[i];
  16436. EncryptionProcessor.DecryptProperties(dc);
  16437. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16438. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16439. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16440. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16441. else transStrRes1 += $"{str1}|";
  16442. }
  16443. //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";
  16444. string transStrRes = "";
  16445. if (transStrRes1.Length > 0)
  16446. {
  16447. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16448. }
  16449. //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
  16450. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16451. //List<string> transArray = new List<string> { };
  16452. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16453. if (transStrRes.Contains("|"))
  16454. {
  16455. string[] transArray1 = transStrRes.Split('|');
  16456. if (transArray1.Length > 0)
  16457. {
  16458. foreach (var item in transArray1)
  16459. {
  16460. if (item.Contains("&"))
  16461. {
  16462. string[] transArray2 = item.Split('&');
  16463. int index = 0;
  16464. string companyName = "", job = "";
  16465. if (transArray2.Length > 0)
  16466. {
  16467. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16468. if (1 < transArray2.Length) companyName = transArray2[1];
  16469. if (2 < transArray2.Length) job = transArray2[2];
  16470. }
  16471. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16472. }
  16473. }
  16474. }
  16475. }
  16476. //循环赋值
  16477. for (int i = 0; i < DcList.Count; i++)
  16478. {
  16479. string PYName = "";
  16480. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16481. {
  16482. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16483. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16484. PYName = PY_First + " " + PY_Last;
  16485. }
  16486. else
  16487. {
  16488. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16489. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16490. PYName = PY_First + " " + PY_Last;
  16491. }
  16492. builder.MoveToCell(0, i + 1, 0, 0);
  16493. builder.Write(PYName);
  16494. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16495. builder.MoveToCell(0, i + 1, 1, 0);
  16496. builder.Write(sex);
  16497. DateTime birthDt;
  16498. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16499. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16500. builder.MoveToCell(0, i + 1, 2, 0);
  16501. builder.Write(birthday);
  16502. string company = string.Empty, job = string.Empty;
  16503. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16504. if (dcTransInfo != null)
  16505. {
  16506. company = dcTransInfo.CompanyName;
  16507. job = dcTransInfo.Job;
  16508. }
  16509. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16510. {
  16511. //查询对照表
  16512. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16513. if (tempCec != null)
  16514. {
  16515. company = tempCec.enName;
  16516. }
  16517. //翻译
  16518. else
  16519. {
  16520. }
  16521. }
  16522. builder.MoveToCell(0, i + 1, 3, 0);
  16523. builder.Write(company);
  16524. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16525. {
  16526. //查询对照表
  16527. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16528. if (tempPec != null)
  16529. {
  16530. job = tempPec.enName;
  16531. }
  16532. //翻译
  16533. else
  16534. {
  16535. }
  16536. }
  16537. builder.MoveToCell(0, i + 1, 4, 0);
  16538. builder.Write(job);
  16539. }
  16540. }
  16541. //删除多余行
  16542. while (tableOne.Rows.Count > DcList.Count + 1)
  16543. {
  16544. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16545. }
  16546. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16547. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16548. doc.Save(fileDir);
  16549. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16550. return Ok(JsonView(true, "操作成功!", Url));
  16551. }
  16552. private class TranslateInfo
  16553. {
  16554. public int Index { get; set; }
  16555. public string CompanyName { get; set; }
  16556. public string Job { get; set; }
  16557. }
  16558. #endregion
  16559. #region 团组倒推表
  16560. /// <summary>
  16561. /// 倒推表基础数据
  16562. /// Init
  16563. /// </summary>
  16564. /// <returns></returns>
  16565. [HttpPost]
  16566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16567. public async Task<IActionResult> PostInvertedListInit()
  16568. {
  16569. var viewData = await _invertedListRep._Init();
  16570. if (viewData.Code != 0)
  16571. {
  16572. return Ok(JsonView(false, viewData.Msg));
  16573. }
  16574. return Ok(JsonView(viewData.Data));
  16575. }
  16576. /// <summary>
  16577. /// 倒推表
  16578. /// Info
  16579. /// </summary>
  16580. /// <param name="dto"></param>
  16581. /// <returns></returns>
  16582. [HttpPost]
  16583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16584. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16585. {
  16586. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16587. if (viewData.Code != 0)
  16588. {
  16589. return Ok(JsonView(false, viewData.Msg));
  16590. }
  16591. return Ok(JsonView(viewData.Data));
  16592. }
  16593. /// <summary>
  16594. /// 倒推表
  16595. /// Create
  16596. /// </summary>
  16597. /// <param name="dto"></param>
  16598. /// <returns></returns>
  16599. [HttpPost]
  16600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16601. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16602. {
  16603. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16604. if (viewData.Code != 0)
  16605. {
  16606. return Ok(JsonView(false, viewData.Msg));
  16607. }
  16608. return Ok(JsonView(viewData.Data));
  16609. }
  16610. /// <summary>
  16611. /// 倒推表
  16612. /// Update
  16613. /// </summary>
  16614. /// <param name="dto"></param>
  16615. /// <returns></returns>
  16616. [HttpPost]
  16617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16618. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16619. {
  16620. var viewData = await _invertedListRep._Update(dto);
  16621. if (viewData.Code != 0)
  16622. {
  16623. return Ok(JsonView(false, viewData.Msg));
  16624. }
  16625. return Ok(JsonView(viewData.Data));
  16626. }
  16627. /// <summary>
  16628. /// 倒推表
  16629. /// File Download
  16630. /// </summary>
  16631. /// <param name="dto"></param>
  16632. /// <returns></returns>
  16633. [HttpPost]
  16634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16635. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16636. {
  16637. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16638. if (info2.Code != 0)
  16639. {
  16640. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16641. }
  16642. var info1 = info2.Data as InvertedListInfoView;
  16643. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16644. string teamName = "";
  16645. if (info != null) teamName = info.TeamName;
  16646. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  16647. var doc = new Document();
  16648. var builder = new DocumentBuilder(doc);
  16649. #region old insert
  16650. ////载入模板
  16651. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  16652. //Document doc = new Document(tempPath);
  16653. //DocumentBuilder builder = new DocumentBuilder(doc);
  16654. //利用键值对存放数据
  16655. //Dictionary<string, string> dic = new Dictionary<string, string>();
  16656. //dic.Add("TeamName", teamName);
  16657. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16658. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16659. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  16660. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16661. //dic.Add("SQRemark", info1.ApprovalRemark);
  16662. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16663. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16664. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16665. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  16666. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16667. //dic.Add("QZRemark", info1.VisaInformationRemark);
  16668. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16669. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  16670. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16671. //dic.Add("CQRemark", info1.IssueVisaRemark);
  16672. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16673. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16674. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16675. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16676. //#region 填充word模板书签内容
  16677. //foreach (var key in dic.Keys)
  16678. //{
  16679. // builder.MoveToBookmark(key);
  16680. // builder.Write(dic[key]);
  16681. //}
  16682. //#endregion
  16683. #endregion
  16684. #region New Insert
  16685. string titleFont = $"仿宋",
  16686. contentFont = $"仿宋";
  16687. var fontColor = Color.FromArgb(64, 64, 64);
  16688. //设置标题 团组名称
  16689. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16690. builder.Font.Name = titleFont;
  16691. builder.Font.Color = fontColor;
  16692. builder.Font.Size = 12;
  16693. builder.Font.Bold = true;
  16694. builder.Writeln(teamName);
  16695. //设置副标题 团组出访时间
  16696. builder.Font.Size = 12;
  16697. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  16698. builder.Writeln();
  16699. var backgroundColor = Color.FromArgb(199, 199, 199);
  16700. var table = builder.StartTable();
  16701. builder.InsertCell();
  16702. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  16703. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  16704. builder.CellFormat.Borders.LineWidth = 1;
  16705. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  16706. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  16707. builder.RowFormat.Height = 40;
  16708. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16709. builder.Font.Name = contentFont;
  16710. builder.Font.Size = 12;
  16711. builder.Font.Bold = true;
  16712. builder.Font.Color = fontColor;
  16713. builder.Write("时间");
  16714. builder.InsertCell();
  16715. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  16716. builder.Write("流程");
  16717. builder.InsertCell();
  16718. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  16719. builder.Write("说明");
  16720. builder.EndRow();
  16721. //报批资料准备
  16722. if (info1.IsSelectedAirportd)
  16723. {
  16724. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  16725. }
  16726. //报批/提供送签资料
  16727. if (info1.IsSelectedApprovalData)
  16728. {
  16729. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  16730. }
  16731. //出批件护照办理
  16732. if (info1.IsSelectedIssueApproval)
  16733. {
  16734. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  16735. }
  16736. //签证资料准备
  16737. if (info1.IsSelectedVisaInfo)
  16738. {
  16739. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  16740. }
  16741. //送签
  16742. if (info1.IsSelectedSendVisa)
  16743. {
  16744. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  16745. }
  16746. //出签
  16747. if (info1.IsSelectedIssueVisa)
  16748. {
  16749. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  16750. }
  16751. //机票
  16752. if (info1.IsSelectedAirTicket)
  16753. {
  16754. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  16755. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  16756. }
  16757. //酒店
  16758. if (info1.IsSelectedHotel)
  16759. {
  16760. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  16761. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  16762. }
  16763. //开行前会
  16764. if (info1.IsSelectedPreTripMeeting)
  16765. {
  16766. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  16767. }
  16768. //送机
  16769. if (info1.IsSelectedAirportdDropOff)
  16770. {
  16771. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  16772. }
  16773. builder.EndTable();
  16774. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  16775. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  16776. for (int i = 0; i < table.Rows.Count; i++)
  16777. {
  16778. var row = table.Rows[i];
  16779. //设置宽度
  16780. row.Cells[0].CellFormat.Width = 20.00;
  16781. row.Cells[1].CellFormat.Width = 30.00;
  16782. row.Cells[2].CellFormat.Width = 50.00;
  16783. if (i != 0)
  16784. {
  16785. //边框设置
  16786. InvertedListFileDownloadSetBorders(row.Cells, 0);
  16787. InvertedListFileDownloadSetBorders(row.Cells, 1);
  16788. InvertedListFileDownloadSetBorders(row.Cells, 2);
  16789. }
  16790. }
  16791. #region 页脚插入图片
  16792. // 创建页脚
  16793. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  16794. doc.FirstSection.HeadersFooters.Add(footer);
  16795. Paragraph para = new Paragraph(doc);
  16796. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  16797. footer.AppendChild(para);
  16798. builder.MoveTo(para);
  16799. string imagePath = "./Images/FMGJ_Log.png";
  16800. builder.InsertImage(imagePath);
  16801. #endregion
  16802. #endregion
  16803. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16804. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  16805. string filePath = fileDir + $@"InvertedList/{fileName}";
  16806. doc.Save(filePath);
  16807. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16808. return Ok(JsonView(true, "操作成功!", Url));
  16809. }
  16810. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  16811. {
  16812. var fontColor = Color.FromArgb(64, 64, 64);
  16813. builder.InsertCell();
  16814. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  16815. builder.RowFormat.Height = 40;
  16816. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16817. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  16818. builder.Font.Name = fontName;
  16819. builder.Font.Size = 8;
  16820. builder.Font.Bold = true;
  16821. builder.Font.Color = fontColor;
  16822. builder.Write(dateTime);
  16823. builder.InsertCell();
  16824. builder.Font.Size = 9;
  16825. builder.Font.Bold = true;
  16826. builder.Font.Color = fontColor;
  16827. builder.Write(content);
  16828. builder.InsertCell();
  16829. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  16830. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16831. builder.Font.Size = 9;
  16832. builder.Font.Bold = false;
  16833. builder.Font.Color = fontColor;
  16834. builder.Write(reamrk);
  16835. builder.EndRow();
  16836. }
  16837. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  16838. {
  16839. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  16840. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  16841. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  16842. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  16843. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  16844. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  16845. }
  16846. #endregion
  16847. #region 会务倒推表
  16848. /// <summary>
  16849. /// 会务倒推表
  16850. /// Init
  16851. /// </summary>
  16852. /// <returns></returns>
  16853. [HttpPost]
  16854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16855. public async Task<IActionResult> InforRetrogressTableInit()
  16856. {
  16857. var groupData = await _groupRepository.PostShareGroupInfos(1);
  16858. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  16859. return Ok(JsonView(false, groupData.Msg));
  16860. }
  16861. /// <summary>
  16862. /// 会务倒推表
  16863. /// ExcelDownload
  16864. /// </summary>
  16865. /// <param name="dto"></param>
  16866. /// <returns></returns>
  16867. [HttpPost]
  16868. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  16869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16870. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  16871. {
  16872. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  16873. var validatorRes = await validator.ValidateAsync(dto);
  16874. if (!validatorRes.IsValid)
  16875. {
  16876. StringBuilder sb = new StringBuilder();
  16877. foreach (var item in validatorRes.Errors)
  16878. {
  16879. sb.AppendLine(item.ErrorMessage);
  16880. }
  16881. return Ok(JsonView(false, sb.ToString()));
  16882. }
  16883. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  16884. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  16885. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  16886. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  16887. #region Excel
  16888. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  16889. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  16890. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  16891. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  16892. var fileNamePrefix = string.Empty;
  16893. if (days >= 30)
  16894. {
  16895. tempPath += $"会务工作倒推进度表(30天).xlsx";
  16896. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  16897. }
  16898. else if (days < 30 && days > 7)
  16899. {
  16900. tempPath += $"会务工作倒推进度表(15天).xlsx";
  16901. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  16902. }
  16903. else if (days <= 7)
  16904. {
  16905. tempPath += $"会务工作倒推进度表(7天).xlsx";
  16906. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  16907. }
  16908. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  16909. fileName = CommonFun.ValidFileName(fileName);
  16910. //载入模板
  16911. WorkbookDesigner designer = new WorkbookDesigner();
  16912. designer.Workbook = new Workbook(tempPath);
  16913. designer.Process();
  16914. if (!Directory.Exists(savePath))
  16915. {
  16916. Directory.CreateDirectory(savePath);
  16917. }
  16918. string serverPath = $"{savePath}{fileName}";
  16919. designer.Workbook.Save(serverPath);
  16920. string rst = $"{servicePath}{ftpPath}{fileName}";
  16921. #endregion
  16922. return Ok(JsonView(new { url = rst }));
  16923. }
  16924. #endregion
  16925. #region 三公签证费用(签证费、代办费)
  16926. /// <summary>
  16927. /// 三公签证费用(签证费、代办费)
  16928. /// List
  16929. /// </summary>
  16930. /// <returns></returns>
  16931. [HttpPost]
  16932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16933. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16934. {
  16935. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16936. if (_view.Code != 0)
  16937. {
  16938. return Ok(JsonView(false, _view.Msg));
  16939. }
  16940. return Ok(JsonView(true, "操作成功!", _view.Data));
  16941. }
  16942. /// <summary>
  16943. /// 三公签证费用(签证费、代办费)
  16944. /// Add Or Update
  16945. /// </summary>
  16946. /// <returns></returns>
  16947. [HttpPost]
  16948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16949. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16950. {
  16951. var _view = await _visaFeeInfoRep._Update(_dto);
  16952. if (_view.Code != 0)
  16953. {
  16954. return Ok(JsonView(false, _view.Msg));
  16955. }
  16956. return Ok(JsonView(true, _view.Msg));
  16957. }
  16958. #endregion
  16959. #region 酒店询价
  16960. /// <summary>
  16961. /// 酒店询价
  16962. /// Init
  16963. /// </summary>
  16964. /// <returns></returns>
  16965. [HttpPost]
  16966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16967. public async Task<IActionResult> PostHotelInquiryInit()
  16968. {
  16969. var res = await _hotelInquiryRep._Init();
  16970. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16971. return Ok(JsonView(true, res.Msg, res.Data));
  16972. }
  16973. /// <summary>
  16974. /// 酒店询价
  16975. /// page Item
  16976. /// </summary>
  16977. /// <param name="_dto"></param>
  16978. /// <returns></returns>
  16979. [HttpPost]
  16980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16981. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16982. {
  16983. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16984. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16985. var view = res.Data as PageDataViewBase;
  16986. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16987. }
  16988. /// <summary>
  16989. /// 酒店询价
  16990. /// info
  16991. /// </summary>
  16992. /// <param name="_dto"></param>
  16993. /// <returns></returns>
  16994. [HttpPost]
  16995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16996. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16997. {
  16998. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16999. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17000. return Ok(JsonView(true, res.Msg, res.Data));
  17001. }
  17002. /// <summary>
  17003. /// 酒店询价
  17004. /// Add Or Edit
  17005. /// </summary>
  17006. /// <param name="_dto"></param>
  17007. /// <returns></returns>
  17008. [HttpPost]
  17009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17010. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17011. {
  17012. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17013. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17014. return Ok(JsonView(true, res.Msg, res.Data));
  17015. }
  17016. /// <summary>
  17017. /// 酒店询价
  17018. /// Del
  17019. /// </summary>
  17020. /// <param name="_dto"></param>
  17021. /// <returns></returns>
  17022. [HttpPost]
  17023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17024. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17025. {
  17026. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17027. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17028. return Ok(JsonView(true, res.Msg, res.Data));
  17029. }
  17030. #endregion
  17031. #region 下载匹配op行程单
  17032. /// <summary>
  17033. /// 匹配op行程单
  17034. /// Init
  17035. /// </summary>
  17036. /// <param name="dto">团组列表请求dto</param>
  17037. /// <returns></returns>
  17038. [HttpPost]
  17039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17040. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17041. {
  17042. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17043. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17044. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17045. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17046. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17047. .Where(it => it.IsDel == 0)
  17048. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17049. .OrderByDescending(it => it.CreateUserId)
  17050. .ToList();
  17051. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17052. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17053. var diids = groupInfos.Select(it => it.Id).ToList();
  17054. List<string> countrys = new List<string>();
  17055. foreach (var item in country)
  17056. {
  17057. var data = _groupRepository.FormartTeamName(item);
  17058. var dataArray = _groupRepository.GroupSplitCountry(data);
  17059. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17060. }
  17061. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17062. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17063. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17064. foreach (var item in areaItem)
  17065. {
  17066. string areaStr = item.Value;
  17067. if (!string.IsNullOrEmpty(areaStr))
  17068. {
  17069. string[] str1 = areaStr.Split("-");
  17070. if (str1.Length > 0)
  17071. {
  17072. areaArray.AddRange(str1);
  17073. }
  17074. }
  17075. }
  17076. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17077. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17078. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17079. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17080. .ToList();
  17081. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17082. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17083. .Where(it => countriesIds.Contains(it.Id))
  17084. .Select(it => new { it.Id, Name = it.Name_CN })
  17085. .ToList();
  17086. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17087. .Select(it => it.TeamName).ToList();
  17088. stopwatch.Stop();
  17089. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17090. }
  17091. ///// <summary>
  17092. ///// 匹配op行程单
  17093. ///// Init 查询区域数据
  17094. ///// </summary>
  17095. ///// <param name="dto">团组列表请求dto</param>
  17096. ///// <returns></returns>
  17097. //[HttpPost]
  17098. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17099. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17100. //{
  17101. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17102. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17103. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17104. // if (string.IsNullOrEmpty(countriesDataStr))
  17105. // {
  17106. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17107. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17108. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17109. // }
  17110. // else
  17111. // {
  17112. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17113. // }
  17114. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17115. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17116. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17117. // List<dynamic> childList = new List<dynamic>();
  17118. // int parentId = dto.CountriesId;
  17119. // if (provinceData.Count > 1)
  17120. // {
  17121. // foreach (var item1 in provinceData)
  17122. // {
  17123. // List<dynamic> childList1 = new List<dynamic>();
  17124. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17125. // foreach (var item2 in citiesData1)
  17126. // {
  17127. // List<dynamic> childList2 = new List<dynamic>();
  17128. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17129. // foreach (var item3 in countiesData1)
  17130. // {
  17131. // childList2.Add(new
  17132. // {
  17133. // id = item3.Id,
  17134. // parentId = item2.Id,
  17135. // level = "district",
  17136. // name = item3.Name_CN,
  17137. // });
  17138. // }
  17139. // childList1.Add(new
  17140. // {
  17141. // id = item2.Id,
  17142. // parentId = item1.Id,
  17143. // level = "city",
  17144. // name = item2.Name_CN,
  17145. // childList = childList2
  17146. // });
  17147. // }
  17148. // childList.Add(new
  17149. // {
  17150. // id = item1.Id,
  17151. // parentId = parentId,
  17152. // level = "province",
  17153. // name = item1.Name_CN,
  17154. // childList = childList1
  17155. // });
  17156. // }
  17157. // //城市
  17158. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17159. // foreach (var item2 in citiesData2)
  17160. // {
  17161. // List<dynamic> childList22 = new List<dynamic>();
  17162. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17163. // foreach (var item3 in countiesData1)
  17164. // {
  17165. // childList22.Add(new
  17166. // {
  17167. // id = item3.Id,
  17168. // parentId = item2.Id,
  17169. // level = "district",
  17170. // name = item3.Name_CN,
  17171. // });
  17172. // }
  17173. // childList.Add(new
  17174. // {
  17175. // id = item2.Id,
  17176. // parentId = parentId,
  17177. // level = "city",
  17178. // name = item2.Name_CN,
  17179. // childList = childList22
  17180. // });
  17181. // }
  17182. // }
  17183. // else
  17184. // {
  17185. // foreach (var item2 in citiesData)
  17186. // {
  17187. // string cname = item2.Name_CN;
  17188. // List<dynamic> childList1 = new List<dynamic>();
  17189. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17190. // foreach (var item3 in countiesData1)
  17191. // {
  17192. // childList1.Add(new
  17193. // {
  17194. // Id = item3.Id,
  17195. // parentId = item2.Id,
  17196. // level = "district",
  17197. // name = item3.Name_CN
  17198. // });
  17199. // }
  17200. // childList.Add(new
  17201. // {
  17202. // id = item2.Id,
  17203. // parentId = parentId,
  17204. // level = "city",
  17205. // name = item2.Name_CN,
  17206. // childList = childList1
  17207. // });
  17208. // }
  17209. // }
  17210. // stopwatch.Stop();
  17211. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17212. //}
  17213. /// <summary>
  17214. /// 匹配op行程单
  17215. /// 接团信息列表 Page
  17216. /// </summary>
  17217. /// <param name="dto">团组列表请求dto</param>
  17218. /// <returns></returns>
  17219. [HttpPost]
  17220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17221. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17222. {
  17223. var swatch = new Stopwatch();
  17224. swatch.Start();
  17225. #region 参数验证
  17226. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17227. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17228. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17229. #region 页面操作权限验证
  17230. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17231. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17232. #endregion
  17233. #endregion
  17234. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17235. {
  17236. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17237. //string sqlWhere = "";
  17238. if (!string.IsNullOrEmpty(dto.Country))
  17239. {
  17240. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17241. }
  17242. if (!string.IsNullOrEmpty(dto.Area))
  17243. {
  17244. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17245. }
  17246. if (!string.IsNullOrEmpty(dto.TeamName))
  17247. {
  17248. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17249. }
  17250. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17251. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17252. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17253. swatch.Stop();
  17254. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17255. }
  17256. else
  17257. {
  17258. return Ok(JsonView(false, "查询失败"));
  17259. }
  17260. }
  17261. /// <summary>
  17262. /// 匹配op行程单
  17263. /// 行程单下载
  17264. /// </summary>
  17265. /// <param name="dto">团组列表请求dto</param>
  17266. /// <returns></returns>
  17267. [HttpPost]
  17268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17269. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17270. {
  17271. #region 参数验证
  17272. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17273. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17274. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17275. #region 页面操作权限验证
  17276. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17277. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17278. #endregion
  17279. #endregion
  17280. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17281. {
  17282. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17283. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17284. }
  17285. else
  17286. {
  17287. return Ok(JsonView(false, "下载失败!"));
  17288. }
  17289. }
  17290. #endregion
  17291. #region 国家信息 数据 注释
  17292. //[HttpPost]
  17293. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17294. //{
  17295. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17296. // foreach (var item in dto)
  17297. // {
  17298. // infos.Add(new Grp_GroupsTaskAssignment()
  17299. // {
  17300. // DIId = item,
  17301. // CTId = 82,
  17302. // UId = 248,
  17303. // IsEnable = 1,
  17304. // CreateUserId = 233,
  17305. // CreateTime = DateTime.Now,
  17306. // IsDel = 0
  17307. // });
  17308. // infos.Add(new Grp_GroupsTaskAssignment()
  17309. // {
  17310. // DIId = item,
  17311. // CTId = 82,
  17312. // UId = 286,
  17313. // IsEnable = 1,
  17314. // CreateUserId = 233,
  17315. // CreateTime = DateTime.Now,
  17316. // IsDel = 0
  17317. // });
  17318. // }
  17319. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17320. // return Ok("操作成功");
  17321. //}
  17322. //public class paramJsonDto
  17323. //{
  17324. // public List<CountriesInfo> str { get; set; }
  17325. //}
  17326. //[HttpPost]
  17327. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17328. //{
  17329. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17330. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17331. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17332. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17333. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17334. // _sqlSugar.BeginTran();
  17335. // int countitiesIndex = 0;
  17336. // foreach (var item in dto.str)
  17337. // {
  17338. // dynamic data = item.c;
  17339. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17340. // if (data != null)
  17341. // {
  17342. // countitiesIndex++;
  17343. // foreach (var item1 in data)
  17344. // {
  17345. // string cnname = item1.cn;
  17346. // string enname = item1.en;
  17347. // Sys_Cities provinceInfo = new Sys_Cities()
  17348. // {
  17349. // CountriesId = countriesId,
  17350. // Name_CN = cnname,
  17351. // Name_EN = enname,
  17352. // ParentId = 0,
  17353. // IsCapital = 1,
  17354. // CreateUserId = 208,
  17355. // CreateTime = DateTime.Now,
  17356. // IsDel = 0
  17357. // };
  17358. // if (item1.lv == "province") //省份
  17359. // {
  17360. // provinceInfo.Level = 1;
  17361. // int provinceId = 0;
  17362. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17363. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17364. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17365. // var data1 = item1.c;
  17366. // foreach (var item2 in data1)
  17367. // {
  17368. // if (item2.lv == "city")
  17369. // {
  17370. // string citycnname = item2.cn;
  17371. // string cityenname = item2.en;
  17372. // Sys_Cities cityInfo = new Sys_Cities()
  17373. // {
  17374. // CountriesId = countriesId,
  17375. // ParentId = provinceId,
  17376. // Level = 2,
  17377. // Name_CN = citycnname,
  17378. // Name_EN = cityenname,
  17379. // IsCapital = 1,
  17380. // CreateUserId = 208,
  17381. // CreateTime = DateTime.Now,
  17382. // IsDel = 0
  17383. // };
  17384. // if (item2.c != null)
  17385. // {
  17386. // int cityId = 0;
  17387. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17388. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17389. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17390. // foreach (var item3 in item2.c)
  17391. // {
  17392. // if (item3.lv == "district")
  17393. // {
  17394. // var districtInfo = new Sys_Cities()
  17395. // {
  17396. // CountriesId = countriesId,
  17397. // Name_CN = item3.cn,
  17398. // Name_EN = item3.en,
  17399. // Level = 3,
  17400. // ParentId = cityId,
  17401. // IsCapital = 1,
  17402. // CreateUserId = 208,
  17403. // CreateTime = DateTime.Now,
  17404. // IsDel = 0
  17405. // };
  17406. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17407. // //{
  17408. // districts.Add(districtInfo);
  17409. // //}
  17410. // }
  17411. // }
  17412. // }
  17413. // else
  17414. // {
  17415. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17416. // //{
  17417. // cities.Add(cityInfo);
  17418. // //}
  17419. // }
  17420. // }
  17421. // }
  17422. // }
  17423. // else if (item1.lv == "city")//城市
  17424. // {
  17425. // provinceInfo.Level = 2;
  17426. // if (item1.c != null)
  17427. // {
  17428. // int cityId = 0;
  17429. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17430. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17431. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17432. // foreach (var item3 in item1.c)
  17433. // {
  17434. // if (item3.lv == "district")
  17435. // {
  17436. // var districtInfo = new Sys_Cities()
  17437. // {
  17438. // CountriesId = countriesId,
  17439. // Name_CN = item3.cn,
  17440. // Name_EN = item3.en,
  17441. // Level = 3,
  17442. // ParentId = cityId,
  17443. // IsCapital = 1,
  17444. // CreateUserId = 208,
  17445. // CreateTime = DateTime.Now,
  17446. // IsDel = 0
  17447. // };
  17448. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17449. // //{
  17450. // districts.Add(districtInfo);
  17451. // //}
  17452. // }
  17453. // }
  17454. // }
  17455. // else
  17456. // {
  17457. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17458. // //{
  17459. // cities.Add(provinceInfo);
  17460. // //}
  17461. // }
  17462. // }
  17463. // }
  17464. // }
  17465. // }
  17466. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17467. // cities = cities.Distinct().ToList();
  17468. // districts = districts.Distinct().ToList();
  17469. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17470. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17471. // cities.AddRange(districts);
  17472. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17473. // //_sqlSugar.RollbackTran();
  17474. // _sqlSugar.CommitTran();
  17475. // return Ok(JsonView(false, "操作成功!"));
  17476. //}
  17477. //[HttpPost]
  17478. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17479. //{
  17480. // List<CountitiesInfo> infos = dto.MyProperty;
  17481. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17482. // _sqlSugar.BeginTran();
  17483. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17484. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17485. // foreach (var item in infos)
  17486. // {
  17487. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17488. // if (countryInfo != null)
  17489. // {
  17490. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17491. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17492. // if (cityInfo1 != null)
  17493. // {
  17494. // cityInfo1.IsCapital = 0;
  17495. // cityInfos.Add(cityInfo1);
  17496. // }
  17497. // }
  17498. // }
  17499. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17500. // .UpdateColumns(it => it.IsCapital)
  17501. // .WhereColumns(it => it.Id)
  17502. // .ExecuteCommand();
  17503. // //_sqlSugar.RollbackTran();
  17504. // _sqlSugar.CommitTran();
  17505. // return Ok(JsonView(false, "操作成功!"));
  17506. //}
  17507. //public class CounrtiesDto
  17508. //{
  17509. // public List<CountitiesInfo> MyProperty { get; set; }
  17510. //}
  17511. //public class CountitiesInfo
  17512. //{
  17513. // /// <summary>
  17514. // /// 圣约翰
  17515. // /// </summary>
  17516. // public string capital_name_chinese { get; set; }
  17517. // /// <summary>
  17518. // ///
  17519. // /// </summary>
  17520. // public string capital_name { get; set; }
  17521. // /// <summary>
  17522. // ///
  17523. // /// </summary>
  17524. // public string country_type { get; set; }
  17525. // /// <summary>
  17526. // /// 安提瓜和巴布达
  17527. // /// </summary>
  17528. // public string country_name_chinese { get; set; }
  17529. // /// <summary>
  17530. // /// 安提瓜和巴布达
  17531. // /// </summary>
  17532. // public string country_name_chinese_short { get; set; }
  17533. // /// <summary>
  17534. // /// 安提瓜和巴布达
  17535. // /// </summary>
  17536. // public string country_name_chinese_UN { get; set; }
  17537. // /// <summary>
  17538. // ///
  17539. // /// </summary>
  17540. // public string country_name_english_abbreviation { get; set; }
  17541. // /// <summary>
  17542. // ///
  17543. // /// </summary>
  17544. // public string country_name_english_formal { get; set; }
  17545. // /// <summary>
  17546. // ///
  17547. // /// </summary>
  17548. // public string country_name_english_UN { get; set; }
  17549. // /// <summary>
  17550. // ///
  17551. // /// </summary>
  17552. // public string continent_name { get; set; }
  17553. // /// <summary>
  17554. // ///
  17555. // /// </summary>
  17556. // public string subregion_name { get; set; }
  17557. // /// <summary>
  17558. // ///
  17559. // /// </summary>
  17560. // public string country_code2 { get; set; }
  17561. // /// <summary>
  17562. // ///
  17563. // /// </summary>
  17564. // public string country_code3 { get; set; }
  17565. // /// <summary>
  17566. // ///
  17567. // /// </summary>
  17568. // public string phone_code { get; set; }
  17569. //}
  17570. //public class CountriesInfo : BasicInfo
  17571. //{
  17572. // public List<CitiesInfo> c { get; set; }
  17573. //}
  17574. //public class CitiesInfo : BasicInfo
  17575. //{
  17576. // public List<AreaInfo> c { get; set; }
  17577. //}
  17578. //public class AreaInfo : BasicInfo
  17579. //{
  17580. // public List<AreaInfo> c { get; set; }
  17581. //}
  17582. //public class BasicInfo
  17583. //{
  17584. // public string code { get; set; }
  17585. // public string cn { get; set; }
  17586. // public string lv { get; set; }
  17587. // public string en { get; set; }
  17588. //}
  17589. #endregion
  17590. #region 查看邀请方
  17591. /// <summary>
  17592. /// 查看邀请方
  17593. /// 邀请方信息 Init
  17594. /// </summary>
  17595. /// <param name="dto"></param>
  17596. /// <returns></returns>
  17597. [HttpPost]
  17598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17599. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17600. {
  17601. string sqlWhere = string.Empty;
  17602. if (!string.IsNullOrEmpty(dto.Search))
  17603. {
  17604. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17605. }
  17606. string sql = string.Format($@"Select
  17607. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17608. Id,
  17609. UnitName
  17610. From Res_InvitationOfficialActivityData
  17611. Where IsDel = 0
  17612. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17613. RefAsync<int> total = 0;
  17614. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17615. return Ok(JsonView(true, MsgTips.Succeed, _views, 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> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17626. {
  17627. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17628. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17629. var diids = groupInfos.Select(it => it.Id).ToList();
  17630. List<string> countrys = new List<string>();
  17631. foreach (var item in country)
  17632. {
  17633. var data = _groupRepository.FormartTeamName(item);
  17634. var dataArray = _groupRepository.GroupSplitCountry(data);
  17635. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17636. }
  17637. countrys = countrys.Distinct().ToList();
  17638. for (int i = 0; i < countrys.Count; i++)
  17639. {
  17640. string item = countrys[i];
  17641. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17642. {
  17643. countrys.Remove(item);
  17644. i--;
  17645. }
  17646. }
  17647. RefAsync<int> total = 0;
  17648. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17649. .Where(it => countrys.Contains(it.Name_CN))
  17650. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17651. .Select(it => new { id = it.Id, name = it.Name_CN })
  17652. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17653. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17654. }
  17655. /// <summary>
  17656. /// 查看邀请方
  17657. /// 城市信息 Init
  17658. /// </summary>
  17659. /// <param name="dto"></param>
  17660. /// <returns></returns>
  17661. [HttpPost]
  17662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17663. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17664. {
  17665. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17666. RefAsync<int> total = 0;
  17667. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17668. .Where(it => it.CountriesId == dto.CountiesId)
  17669. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17670. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17671. .Select(it => new { id = it.Id, name = it.Name_CN })
  17672. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17673. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17674. }
  17675. /// <summary>
  17676. /// 查看邀请方
  17677. /// 团组名称 Init
  17678. /// </summary>
  17679. /// <param name="dto"></param>
  17680. /// <returns></returns>
  17681. [HttpPost]
  17682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17683. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17684. {
  17685. var watch = new Stopwatch();
  17686. watch.Start();
  17687. RefAsync<int> total = 0;
  17688. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17689. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17690. .Where((oa, di) => oa.IsDel == 0)
  17691. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17692. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17693. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17694. .Distinct()
  17695. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17696. watch.Stop();
  17697. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17698. }
  17699. /// <summary>
  17700. /// 查看邀请方
  17701. /// 团组 & 邀请方信息
  17702. /// </summary>
  17703. /// <param name="dto"></param>
  17704. /// <returns></returns>
  17705. [HttpPost]
  17706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17707. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17708. {
  17709. var watch = new Stopwatch();
  17710. watch.Start();
  17711. RefAsync<int> total = 0;
  17712. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17713. .AS("Grp_DelegationInfo")
  17714. .Includes(x => x.InvitingInfos)
  17715. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17716. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17717. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17718. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17719. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17720. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17721. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17722. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17723. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17724. infos.ForEach(x =>
  17725. {
  17726. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17727. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17728. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17729. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17730. });
  17731. watch.Stop();
  17732. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17733. }
  17734. #endregion
  17735. #region 报批行程
  17736. /// <summary>
  17737. /// 报批行程初始化
  17738. /// </summary>
  17739. /// <param name="dto"></param>
  17740. /// <returns></returns>
  17741. [HttpPost]
  17742. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17743. {
  17744. const int chiNumber = 5;
  17745. var jw = JsonView(false);
  17746. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17747. var group = groupList.First();
  17748. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17749. group = groupList.First(x => x.Id == diid);
  17750. if (group == null)
  17751. {
  17752. jw.Msg = "暂无团组!";
  17753. return Ok(jw);
  17754. }
  17755. var data = new
  17756. {
  17757. groupList = groupList.Select(x => new
  17758. {
  17759. x.TeamName,
  17760. x.Id
  17761. }),
  17762. content = new ArrayList(),
  17763. groupInfo = new
  17764. {
  17765. group.VisitDays,
  17766. group.TourCode,
  17767. group.VisitPNumber,
  17768. group.TeamName,
  17769. group.Id,
  17770. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17771. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17772. },
  17773. };
  17774. var resultArr = new ArrayList();
  17775. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17776. if (content.Count == 0)
  17777. {
  17778. var stay = "-";
  17779. var cityPath = "-";
  17780. //添加城市路径以及住宿地
  17781. //黑屏代码数据
  17782. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17783. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17784. {
  17785. jw = JsonView(true, "黑屏代码有误!", data);
  17786. return Ok(jw);
  17787. }
  17788. foreach (DataRow row in dtBlack.Rows)
  17789. {
  17790. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17791. {
  17792. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17793. return Ok(jw);
  17794. }
  17795. }
  17796. //黑屏代码获取时间区间
  17797. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17798. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17799. _sqlSugar.BeginTran();
  17800. for (int i = 0; i < timeArr.Count; i++)
  17801. {
  17802. stay = "-";
  17803. cityPath = "-";
  17804. DateTime NewData = DateTime.Parse(timeArr[i]);
  17805. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17806. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17807. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17808. if (tbSelect.Length > 0)
  17809. {
  17810. List<string> threeCodeStr = new List<string>();
  17811. foreach (var item in tbSelect)
  17812. {
  17813. var threeCode = item["Three"].ToString() ?? "";
  17814. if (threeCode.Length == 6)
  17815. {
  17816. var start = threeCode.Substring(0, 3);
  17817. var end = threeCode.Substring(3, 3);
  17818. if (threeCodeStr.Count == 0)
  17819. {
  17820. threeCodeStr.Add(start);
  17821. threeCodeStr.Add(end);
  17822. }
  17823. else
  17824. {
  17825. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17826. {
  17827. threeCodeStr.Add(end);
  17828. }
  17829. else
  17830. {
  17831. threeCodeStr.Add(start);
  17832. threeCodeStr.Add(end);
  17833. }
  17834. }
  17835. }
  17836. }
  17837. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17838. var last = threeCodeStr.Last();
  17839. foreach (var item in threeCodeStr)
  17840. {
  17841. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17842. if (item.Equals(last))
  17843. {
  17844. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17845. }
  17846. }
  17847. cityPath = cityPath.Trim('-');
  17848. }
  17849. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17850. appro.Diid = diid ?? -1;
  17851. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17852. appro.Id = thisId;
  17853. appro.CreateUserId = dto.UserId;
  17854. appro.CreateTime = DateTime.Now;
  17855. content.Add(appro);
  17856. }
  17857. _sqlSugar.CommitTran();
  17858. }
  17859. foreach (var x in content)
  17860. {
  17861. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17862. if (chiList.Count < chiNumber)
  17863. {
  17864. for (int i = chiList.Count; i < chiNumber; i++)
  17865. {
  17866. chiList.Add(new Grp_ApprovalTravelDetails());
  17867. }
  17868. }
  17869. resultArr.Add(new
  17870. {
  17871. x.Id,
  17872. x.Date,
  17873. x.Diid,
  17874. chiList = chiList.Select(x1 => new
  17875. {
  17876. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17877. x1.Details,
  17878. x1.ParentId,
  17879. x1.Id
  17880. })
  17881. });
  17882. }
  17883. data = data with
  17884. {
  17885. content = resultArr,
  17886. };
  17887. jw = JsonView(true, "获取成功!", data);
  17888. return Ok(jw);
  17889. }
  17890. /// <summary>
  17891. /// 报批行程删除
  17892. /// </summary>
  17893. /// <param name="dto"></param>
  17894. /// <returns></returns>
  17895. [HttpPost]
  17896. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17897. {
  17898. var jw = JsonView(false);
  17899. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17900. if (group == null)
  17901. {
  17902. jw.Msg = "团组参数有误!";
  17903. return Ok(jw);
  17904. }
  17905. try
  17906. {
  17907. _sqlSugar.BeginTran();
  17908. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17909. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17910. {
  17911. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17912. DeleteUserId = dto.uesrId,
  17913. IsDel = 1
  17914. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17915. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17916. {
  17917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17918. DeleteUserId = dto.uesrId,
  17919. IsDel = 1
  17920. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17921. _sqlSugar.CommitTran();
  17922. jw = JsonView(true, "删除成功");
  17923. }
  17924. catch (Exception ex)
  17925. {
  17926. jw = JsonView(false, ex.Message);
  17927. }
  17928. return Ok(jw);
  17929. }
  17930. /// <summary>
  17931. /// 报批行程保存
  17932. /// </summary>
  17933. /// <param name="dto"></param>
  17934. /// <returns></returns>
  17935. [HttpPost]
  17936. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17937. {
  17938. var jw = JsonView(false);
  17939. var Find = dto.Arr.Find(x => x.id == 0);
  17940. if (Find != null)
  17941. {
  17942. jw.Msg = "生成的ID为0!";
  17943. return Ok(jw);
  17944. }
  17945. foreach (var item in dto.Arr)
  17946. {
  17947. foreach (var chi in item.chiList)
  17948. {
  17949. if (chi.parentId == 0)
  17950. {
  17951. chi.parentId = item.id;
  17952. }
  17953. }
  17954. }
  17955. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17956. _sqlSugar.BeginTran();
  17957. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17958. {
  17959. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17960. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17961. {
  17962. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17963. DeleteUserId = dto.UserId,
  17964. IsDel = 1
  17965. }).ExecuteCommand();
  17966. }
  17967. try
  17968. {
  17969. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17970. {
  17971. CreateTime = DateTime.Now,
  17972. CreateUserId = dto.UserId,
  17973. Details = x.details,
  17974. ParentId = x.parentId,
  17975. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17976. Remark = "",
  17977. IsDel = 0
  17978. }).ToList()).ExecuteCommand();
  17979. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17980. {
  17981. Id = x.id,
  17982. Details = x.details,
  17983. ParentId = x.parentId,
  17984. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17985. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17986. {
  17987. Details = x.Details,
  17988. ParentId = x.ParentId,
  17989. Time = x.Time
  17990. }).ExecuteCommand();
  17991. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17992. {
  17993. Id = x.id,
  17994. Date = x.date,
  17995. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17996. {
  17997. Date = x.Date
  17998. }).ExecuteCommand();
  17999. _sqlSugar.CommitTran();
  18000. jw = JsonView(true, "保存成功!");
  18001. }
  18002. catch (Exception ex)
  18003. {
  18004. _sqlSugar.RollbackTran();
  18005. jw = JsonView(false, "保存失败!" + ex.Message);
  18006. }
  18007. return Ok(jw);
  18008. }
  18009. /// <summary>
  18010. /// 报批行程生成
  18011. /// </summary>
  18012. /// <param name="dto"></param>
  18013. /// <returns></returns>
  18014. [HttpPost]
  18015. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18016. {
  18017. var jw = JsonView(false);
  18018. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18019. if (group == null)
  18020. {
  18021. jw.Msg = "暂无该团组!";
  18022. return Ok(jw);
  18023. }
  18024. //黑屏代码数据
  18025. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  18026. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18027. {
  18028. jw.Msg = "黑屏代码有误!";
  18029. return Ok(jw);
  18030. }
  18031. foreach (DataRow row in dtBlack.Rows)
  18032. {
  18033. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18034. {
  18035. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18036. return Ok(jw);
  18037. }
  18038. }
  18039. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18040. var resultArr = new ArrayList();
  18041. if (officialActivitiesArr.Count == 0)
  18042. {
  18043. jw.Msg = "暂无公务出访信息!";
  18044. return Ok(jw);
  18045. }
  18046. try
  18047. {
  18048. _sqlSugar.BeginTran();
  18049. DeleteApprovalJourney(new
  18050. Domain.Dtos.Groups.DeleteApprovalJourney
  18051. {
  18052. Diid = dto.Diid,
  18053. uesrId = dto.Userid
  18054. });
  18055. var stay = "-";
  18056. var cityPath = "-";
  18057. //添加城市路径以及住宿地
  18058. //黑屏代码获取时间区间
  18059. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18060. var empty = "【未收入该三字码!请机票同事录入】";
  18061. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18062. for (int i = 0; i < timeArr.Count; i++)
  18063. {
  18064. stay = "-";
  18065. cityPath = "-";
  18066. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18067. DateTime NewData = DateTime.Parse(timeArr[i]);
  18068. 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();
  18069. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18070. if (tbSelect.Length > 0)
  18071. {
  18072. List<string> threeCodeStr = new List<string>();
  18073. bool isTrade = false;
  18074. string trip = string.Empty;
  18075. var rowLast = tbSelect.Last();
  18076. var rowFirst = tbSelect.First();
  18077. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18078. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18079. var takeOffTime = DateTime.Parse(timeArr[i]);
  18080. var fallToTime = DateTime.Parse(timeArr[i]);
  18081. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18082. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18083. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18084. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18085. foreach (var item in tbSelect)
  18086. {
  18087. var start = string.Empty;
  18088. var end = string.Empty;
  18089. var threeCode = item["Three"].ToString() ?? "";
  18090. if (threeCode.Length == 6)
  18091. {
  18092. start = threeCode.Substring(0, 3);
  18093. end = threeCode.Substring(3, 3);
  18094. if (threeCodeStr.Count == 0)
  18095. {
  18096. threeCodeStr.Add(start);
  18097. threeCodeStr.Add(end);
  18098. }
  18099. else
  18100. {
  18101. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18102. {
  18103. threeCodeStr.Add(end);
  18104. }
  18105. else
  18106. {
  18107. threeCodeStr.Add(start);
  18108. threeCodeStr.Add(end);
  18109. }
  18110. }
  18111. }
  18112. //处理机票信息
  18113. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18114. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18115. if (start_Object == null)
  18116. {
  18117. start_Object = new Res_ThreeCode()
  18118. {
  18119. AirPort = empty,
  18120. AirPort_En = empty,
  18121. City = empty,
  18122. Country = empty,
  18123. Four = empty,
  18124. Three = empty,
  18125. };
  18126. }
  18127. if (end_Object == null)
  18128. {
  18129. end_Object = new Res_ThreeCode()
  18130. {
  18131. AirPort = empty,
  18132. AirPort_En = empty,
  18133. City = empty,
  18134. Country = empty,
  18135. Four = empty,
  18136. Three = empty,
  18137. };
  18138. }
  18139. //机型判断
  18140. string airModel = item["AirModel"].ToString();
  18141. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18142. string flightTime = item["FlightTime"].ToString();
  18143. if (flightTime!.Contains(":"))
  18144. {
  18145. flightTime = flightTime.Replace(":", "小时");
  18146. flightTime += "分钟";
  18147. }
  18148. if (flightTime.Contains("H"))
  18149. {
  18150. flightTime = flightTime.Replace("H", "小时");
  18151. }
  18152. if (flightTime.Contains("M"))
  18153. {
  18154. flightTime = flightTime.Replace("M", "分钟");
  18155. }
  18156. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18157. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18158. {
  18159. flightTime = flightDataTime.Hour > 0
  18160. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18161. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18162. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18163. }
  18164. //航班号
  18165. string flightcode = item["Fliagtcode"].ToString();
  18166. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18167. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18168. if (aircompany == null)
  18169. {
  18170. aircompany = new Res_AirCompany
  18171. {
  18172. CnName = hsEmpty,
  18173. EnName = hsEmpty,
  18174. ShortCode = hsEmpty,
  18175. };
  18176. }
  18177. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18178. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18179. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18180. if (isTrade)
  18181. {
  18182. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18183. }
  18184. else
  18185. {
  18186. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18187. }
  18188. }
  18189. chiarr.Add(new Grp_ApprovalTravelDetails
  18190. {
  18191. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18192. CreateTime = DateTime.Now,
  18193. CreateUserId = dto.Userid,
  18194. ParentId = 0,
  18195. Details = trip
  18196. });
  18197. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18198. var last = threeCodeStr.Last();
  18199. foreach (var item in threeCodeStr)
  18200. {
  18201. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18202. if (item.Equals(last))
  18203. {
  18204. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18205. }
  18206. }
  18207. cityPath = cityPath.Trim('-');
  18208. }
  18209. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18210. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18211. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18212. appro.Diid = dto.Diid;
  18213. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18214. appro.Id = thisId;
  18215. appro.CreateUserId = dto.Userid;
  18216. appro.CreateTime = DateTime.Now;
  18217. foreach (var item in gwinfo)
  18218. {
  18219. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18220. chi.Details = "拜访" + item.Client;
  18221. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18222. {
  18223. chi.Details += "," + item.ReqSample;
  18224. }
  18225. chi.ParentId = thisId;
  18226. chi.Time = item.Time;
  18227. chiarr.Add(chi);
  18228. }
  18229. if (chiarr.Count < 5)
  18230. {
  18231. for (int j = chiarr.Count; j < 5; j++)
  18232. {
  18233. chiarr.Add(new
  18234. Grp_ApprovalTravelDetails());
  18235. }
  18236. }
  18237. resultArr.Add(new
  18238. {
  18239. appro.Id,
  18240. appro.Date,
  18241. appro.Diid,
  18242. chiList = chiarr.Select(x1 => new
  18243. {
  18244. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  18245. x1.Details,
  18246. x1.ParentId,
  18247. x1.Id
  18248. })
  18249. });
  18250. }
  18251. _sqlSugar.CommitTran();
  18252. jw = JsonView(true, "生成成功!", resultArr);
  18253. }
  18254. catch (Exception ex)
  18255. {
  18256. jw.Code = 400;
  18257. jw.Msg = "生成失败!" + ex.Message;
  18258. }
  18259. return Ok(jw);
  18260. }
  18261. /// <summary>
  18262. /// 报批行程word导出
  18263. /// </summary>
  18264. /// <param name="dto"></param>
  18265. /// <returns></returns>
  18266. [HttpPost]
  18267. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18268. {
  18269. var jw = JsonView(false);
  18270. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18271. if (group == null)
  18272. {
  18273. jw.Msg = "暂无该团组!";
  18274. return Ok(jw);
  18275. }
  18276. //模板路径
  18277. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18278. //载入模板
  18279. Document doc = new Document(tempPath);
  18280. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18281. //获取所填表格的序数
  18282. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18283. Aspose.Words.Tables.Row titleRowClone = null;
  18284. Aspose.Words.Tables.Row CenterRowClone = null;
  18285. int index = 0;
  18286. int indexChi = 0;
  18287. int SetIndex = 0;
  18288. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18289. //获取数据,放到datatable
  18290. foreach (var item in ApprovalTravelArr)
  18291. {
  18292. if (index > 0)
  18293. {
  18294. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18295. tableOne.AppendChild(titleRowClone);
  18296. }
  18297. var textTime = item.Date;
  18298. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18299. SetCells(tableOne, doc, SetIndex, 0, textTime);
  18300. SetIndex++;
  18301. if (ChiRep.Count > 0)
  18302. {
  18303. foreach (var itemChi in ChiRep)
  18304. {
  18305. var txtTime = itemChi.Time;
  18306. var txtDetail = itemChi.Details;
  18307. if (indexChi > 0)
  18308. {
  18309. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18310. tableOne.AppendChild(CenterRowClone);
  18311. }
  18312. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18313. {
  18314. SetCells(tableOne, doc, SetIndex, 0, "");
  18315. SetCells(tableOne, doc, SetIndex, 1, "");
  18316. indexChi++;
  18317. SetIndex++;
  18318. break;
  18319. }
  18320. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  18321. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  18322. indexChi++;
  18323. SetIndex++;
  18324. }
  18325. }
  18326. else
  18327. {
  18328. if (indexChi > 0)
  18329. {
  18330. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  18331. tableOne.AppendChild(CenterRowClone);
  18332. }
  18333. SetCells(tableOne, doc, SetIndex, 0, "");
  18334. SetCells(tableOne, doc, SetIndex, 1, "");
  18335. indexChi++;
  18336. SetIndex++;
  18337. }
  18338. index++;
  18339. }
  18340. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  18341. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18342. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18343. jw.Code = 200;
  18344. jw.Msg = "";
  18345. return Ok(jw);
  18346. }
  18347. private string intToString(int numberVal)
  18348. {
  18349. string numberval = numberVal.ToString();
  18350. Dictionary<char, string> Number = new Dictionary<char, string>();
  18351. Number.Add('1', "一");
  18352. Number.Add('2', "二");
  18353. Number.Add('3', "三");
  18354. Number.Add('4', "四");
  18355. Number.Add('5', "五");
  18356. Number.Add('6', "六");
  18357. Number.Add('7', "七");
  18358. Number.Add('8', "八");
  18359. Number.Add('9', "九");
  18360. string stringNumberVal = string.Empty;
  18361. for (int i = 0; i < numberval.Length; i++)
  18362. {
  18363. if (i == 0)
  18364. {
  18365. stringNumberVal += Number[numberval[i]];
  18366. }
  18367. else if (i >= 1)
  18368. {
  18369. if (numberval[i] == '0')
  18370. {
  18371. stringNumberVal = "十";
  18372. }
  18373. else
  18374. {
  18375. stringNumberVal += "十" + Number[numberval[i]];
  18376. }
  18377. }
  18378. }
  18379. return stringNumberVal;
  18380. }
  18381. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  18382. {
  18383. //获取table中的某个单元格,从0开始
  18384. Cell lshCell = table.Rows[rows].Cells[cells];
  18385. //将单元格中段落移除
  18386. foreach (Node item in lshCell.Paragraphs)
  18387. {
  18388. lshCell.Paragraphs.Remove(item);
  18389. }
  18390. if (val.Contains("\r\n"))
  18391. {
  18392. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18393. foreach (var item in spArr)
  18394. {
  18395. //新建一个段落
  18396. Paragraph p = new Paragraph(doc);
  18397. var r = new Run(doc, item);
  18398. //把设置的值赋给之前新建的段落
  18399. p.AppendChild(r);
  18400. //将此段落加到单元格内
  18401. lshCell.AppendChild(p);
  18402. }
  18403. }
  18404. else
  18405. {
  18406. //新建一个段落
  18407. Paragraph p = new Paragraph(doc);
  18408. var r = new Run(doc, val);
  18409. //把设置的值赋给之前新建的段落
  18410. p.AppendChild(r);
  18411. //将此段落加到单元格内
  18412. lshCell.AppendChild(p);
  18413. }
  18414. }
  18415. [HttpPost]
  18416. public async Task<IActionResult> ServerHttp(string paramStr)
  18417. {
  18418. paramStr = paramStr.TrimEnd('\'');
  18419. paramStr = paramStr.TrimStart('\'');
  18420. JsonView jw = JsonView(false);
  18421. JObject param = JObject.Parse(paramStr);
  18422. if (!param.ContainsKey("url"))
  18423. {
  18424. jw.Msg = "url null";
  18425. return Ok(jw);
  18426. }
  18427. string url = param["url"]!.ToString();
  18428. var methon = "get";
  18429. Dictionary<string, string> headValues = null;
  18430. string bodyStr = string.Empty;
  18431. if (param.ContainsKey("methon"))
  18432. {
  18433. methon = param["methon"]!.ToString().ToLower();
  18434. }
  18435. if (param.ContainsKey("header"))
  18436. {
  18437. var header = param["header"]!.ToString();
  18438. JObject headerJobject = JObject.Parse(header);
  18439. headValues = new Dictionary<string, string>();
  18440. foreach (JProperty item in headerJobject.Properties())
  18441. {
  18442. var value = item.Value.ToString();
  18443. var head = item.Path;
  18444. headValues.Add(head, value);
  18445. }
  18446. }
  18447. HttpClient client = new HttpClient();
  18448. string responseString = string.Empty;
  18449. StringContent content = null;
  18450. if (headValues != null)
  18451. {
  18452. foreach (var item in headValues.Keys)
  18453. {
  18454. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18455. {
  18456. if (param.ContainsKey("body"))
  18457. {
  18458. bodyStr = param["body"]!.ToString();
  18459. }
  18460. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18461. }
  18462. else
  18463. {
  18464. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18465. }
  18466. }
  18467. }
  18468. try
  18469. {
  18470. if (methon == "get")
  18471. {
  18472. responseString = await client.GetStringAsync(url);
  18473. }
  18474. else if (methon == "post")
  18475. {
  18476. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18477. {
  18478. Content = content
  18479. };
  18480. var response = await client.SendAsync(request);
  18481. try
  18482. {
  18483. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18484. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18485. {
  18486. using (StreamReader reader = new StreamReader(gzipStream))
  18487. {
  18488. responseString = await reader.ReadToEndAsync();
  18489. }
  18490. }
  18491. }
  18492. catch (Exception)
  18493. {
  18494. responseString = await response.Content.ReadAsStringAsync();
  18495. }
  18496. }
  18497. else
  18498. {
  18499. responseString = "methon error";
  18500. }
  18501. jw = JsonView(true, "success", responseString);
  18502. }
  18503. catch (Exception ex)
  18504. {
  18505. jw.Msg = "error " + ex.Message;
  18506. jw.Data = ex.StackTrace;
  18507. }
  18508. finally
  18509. {
  18510. client.Dispose();
  18511. }
  18512. return Ok(jw);
  18513. }
  18514. #endregion
  18515. #region 团组接待意见调查
  18516. /// <summary>
  18517. /// 团组接待意见调查 - 信息管理
  18518. /// 基础数据(团组)
  18519. /// </summary>
  18520. /// <returns></returns>
  18521. [HttpGet]
  18522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18523. public async Task<IActionResult> OpinionaireInit()
  18524. {
  18525. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18526. .Select(x => new
  18527. {
  18528. x.Id,
  18529. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18530. })
  18531. .OrderByDescending(x => x.Id)
  18532. .ToListAsync();
  18533. return Ok(JsonView(groupData, groupData.Count));
  18534. }
  18535. /// <summary>
  18536. /// 团组接待意见调查 - 信息管理
  18537. /// 列表
  18538. /// </summary>
  18539. /// <param name="groupId"></param>
  18540. /// <returns></returns>
  18541. [HttpGet("{groupId}")]
  18542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18543. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18544. {
  18545. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18546. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18547. .Select(x => new
  18548. {
  18549. x.Id,
  18550. x.TourGuideName,
  18551. x.CityName,
  18552. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18553. x.CreateTime
  18554. })
  18555. .OrderBy(x => x.Id)
  18556. .ToListAsync();
  18557. return Ok(JsonView(data));
  18558. }
  18559. /// <summary>
  18560. /// 团组接待意见调查 - 信息管理
  18561. /// 保存
  18562. /// </summary>
  18563. /// <param name="dto"></param>
  18564. /// <returns></returns>
  18565. [HttpPost]
  18566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18567. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18568. {
  18569. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18570. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18571. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18572. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18573. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18574. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18575. _opinionaireRep.BeginTran();
  18576. if (addData != null && addData.Count > 0)
  18577. {
  18578. foreach (var item in addData)
  18579. {
  18580. item.CreateUserId = currUserInfo.UserId;
  18581. item.DiId = dto.DiId;
  18582. }
  18583. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18584. }
  18585. if (updData != null && updData.Count > 0)
  18586. {
  18587. var upd = await _opinionaireRep._sqlSugar
  18588. .Updateable(updData)
  18589. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18590. .WhereColumns(x => new { x.Id })
  18591. .ExecuteCommandAsync();
  18592. }
  18593. _opinionaireRep.CommitTran();
  18594. return Ok(JsonView("操作成功!"));
  18595. }
  18596. /// <summary>
  18597. /// 团组接待意见调查 - 信息管理
  18598. /// 删除
  18599. /// </summary>
  18600. /// <param name="id"></param>
  18601. /// <returns></returns>
  18602. [HttpDelete("{id}")]
  18603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18604. public async Task<IActionResult> OpinionaireManageDel(int id)
  18605. {
  18606. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18607. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18608. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18609. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18610. if (!del) return Ok(JsonView("操作失败!"));
  18611. return Ok(JsonView("操作成功!"));
  18612. }
  18613. /// <summary>
  18614. /// 团组接待意见调查 - 用户
  18615. /// 列表
  18616. /// </summary>
  18617. /// <param name="diId"></param>
  18618. /// <returns></returns>
  18619. [HttpGet("{diId}")]
  18620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18621. public async Task<IActionResult> OpinionaireUserList(int diId)
  18622. {
  18623. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18624. var sql = string.Format(@"
  18625. SELECT
  18626. o.Id,
  18627. o.DiId,
  18628. di.TeamName AS 'GroupName',
  18629. di.VisitPNumber AS 'PeopleNumber',
  18630. di.ClientName AS 'LeadGroup',
  18631. di.VisitCountry AS 'Travel',
  18632. di.VisitDays AS 'Days',
  18633. o.CityName,
  18634. o.TourGuideName,
  18635. o.Catering,
  18636. o.CateringReason,
  18637. o.Stay,
  18638. o.StayReason,
  18639. o.[Route],
  18640. o.RouteReason,
  18641. o.OfficialActivity,
  18642. o.OfficialActivityReason,
  18643. o.TourGuide,
  18644. o.TourGuideReason,
  18645. o.[Translate],
  18646. o.TranslateReason,
  18647. o.Trip,
  18648. o.TripReason,
  18649. o.ESFileName,
  18650. o.SignatureDate,
  18651. o.Remark
  18652. FROM
  18653. Grp_Opinionaire o
  18654. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18655. WHERE
  18656. o.IsDel = 0
  18657. AND o.DiId = {0}
  18658. ORDER BY
  18659. o.Id ASC", diId);
  18660. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18661. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18662. return Ok(JsonView(data));
  18663. }
  18664. /// <summary>
  18665. /// 团组接待意见调查 - 用户
  18666. /// 保存
  18667. /// </summary>
  18668. /// <param name="dto"></param>
  18669. /// <returns></returns>
  18670. [HttpPost]
  18671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18672. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18673. {
  18674. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18675. foreach (var item in dto)
  18676. {
  18677. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18678. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18679. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18680. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18681. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18682. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18683. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18684. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18685. }
  18686. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18687. if (!Directory.Exists(filePathBase))
  18688. {
  18689. Directory.CreateDirectory(filePathBase);
  18690. }
  18691. #region 上传文件
  18692. var filePaths = new List<string>();
  18693. foreach (var item in dto)
  18694. {
  18695. var file = item.File;
  18696. // 将文件保存到指定位置
  18697. var filePath = Path.Combine(filePathBase, file.FileName);
  18698. using (var stream = new FileStream(filePath, FileMode.Create))
  18699. {
  18700. await file.CopyToAsync(stream);
  18701. }
  18702. //验证文件是否上传成功
  18703. if (!System.IO.File.Exists(filePath))
  18704. {
  18705. foreach (var filePathStr in filePaths)
  18706. {
  18707. System.IO.File.Delete(filePathStr);
  18708. }
  18709. return Ok(JsonView(false, "文件上传失败!"));
  18710. }
  18711. item.ESFileName = file.FileName;
  18712. }
  18713. #endregion
  18714. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18715. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18716. .UpdateColumns(x => new
  18717. {
  18718. x.Catering,
  18719. x.CateringReason,
  18720. x.Stay,
  18721. x.StayReason,
  18722. x.Route,
  18723. x.RouteReason,
  18724. x.OfficialActivity,
  18725. x.OfficialActivityReason,
  18726. x.TourGuide,
  18727. x.TourGuideReason,
  18728. x.Translate,
  18729. x.TranslateReason,
  18730. x.Trip,
  18731. x.TripReason,
  18732. x.ESFileName,
  18733. x.SignatureDate,
  18734. x.Remark
  18735. })
  18736. .WhereColumns(x => new { x.Id })
  18737. .ExecuteCommandAsync();
  18738. if (upd < 1)
  18739. {
  18740. foreach (var filePathStr in filePaths)
  18741. {
  18742. System.IO.File.Delete(filePathStr);
  18743. }
  18744. return Ok(JsonView(false));
  18745. }
  18746. return Ok(JsonView(true));
  18747. }
  18748. #endregion
  18749. #region 团组餐厅相关信息
  18750. /// <summary>
  18751. /// 团组相关餐厅信息
  18752. /// 基础数据(团组)
  18753. /// </summary>
  18754. /// <returns></returns>
  18755. [HttpGet]
  18756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18757. public async Task<IActionResult> RestaurantInit()
  18758. {
  18759. return Ok(await _restaurantRep.InitAsync());
  18760. }
  18761. /// <summary>
  18762. /// 团组相关餐厅信息
  18763. /// Item
  18764. /// </summary>
  18765. /// <param name="dto"></param>
  18766. /// <returns></returns>
  18767. [HttpPost]
  18768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18769. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18770. {
  18771. int portType = dto.PortType,
  18772. groupId = dto.GroupId;
  18773. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18774. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18775. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  18776. }
  18777. /// <summary>
  18778. /// 团组相关餐厅信息
  18779. /// List
  18780. /// </summary>
  18781. /// <param name="dto"></param>
  18782. /// <returns></returns>
  18783. [HttpPost]
  18784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18785. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18786. {
  18787. int portType = dto.PortType,
  18788. groupId = dto.GroupId;
  18789. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18790. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18791. var sql = string.Format(@" SELECT
  18792. ri.Id,
  18793. ri.GroupId,
  18794. ri.Date,
  18795. ri.StartTime,
  18796. ri.EndTime,
  18797. CASE WHEN ri.Type = 1 THEN '早餐'
  18798. WHEN ri.Type = 2 THEN '午餐'
  18799. WHEN ri.Type = 3 THEN '晚餐'
  18800. ELSE '其他'
  18801. END AS 'Type',
  18802. ri.Name,
  18803. ri.Address,
  18804. ri.Tel,
  18805. ri.Remark,
  18806. ri.CreateTime,
  18807. u.CnName AS CreateUserName
  18808. FROM
  18809. Grp_RestaurantInfo ri
  18810. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18811. WHERE
  18812. ri.IsDel = 0
  18813. AND ri.GroupId = {0}
  18814. ORDER BY
  18815. ri.Date ASC
  18816. ", groupId);
  18817. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18818. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18819. return Ok(JsonView(infos));
  18820. }
  18821. /// <summary>
  18822. /// 团组相关餐厅信息
  18823. /// Info
  18824. /// </summary>
  18825. /// <param name="dto"></param>
  18826. /// <returns></returns>
  18827. [HttpPost]
  18828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18829. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18830. {
  18831. int portType = dto.PortType,
  18832. id = dto.Id;
  18833. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18834. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18835. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18836. }
  18837. /// <summary>
  18838. /// 团组相关餐厅信息
  18839. /// Op
  18840. /// </summary>
  18841. /// <param name="dto"></param>
  18842. /// <returns></returns>
  18843. [HttpPost]
  18844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18845. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18846. {
  18847. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18848. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18849. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18850. return Ok(await _restaurantRep.OpAsync(dto));
  18851. }
  18852. /// <summary>
  18853. /// 团组相关餐厅信息
  18854. /// Del
  18855. /// </summary>
  18856. /// <param name="dto"></param>
  18857. /// <returns></returns>
  18858. [HttpPost]
  18859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18860. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18861. {
  18862. int userId = dto.DeleteUserId;
  18863. var id = dto.Id;
  18864. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18865. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18866. return Ok(await _restaurantRep.DelAsync(dto));
  18867. }
  18868. #endregion
  18869. // /// <summary>
  18870. // ///
  18871. // /// </summary>
  18872. // /// <param name="_dto"></param>
  18873. // /// <returns></returns>
  18874. // [HttpPost]
  18875. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18876. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18877. // {
  18878. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18879. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18880. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18881. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18882. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18883. // dic_psg.Add("客人", 974);
  18884. // dic_psg.Add("司机", 975);
  18885. // dic_psg.Add("导游", 976);
  18886. // dic_psg.Add("公司内部人员", 977);
  18887. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18888. // foreach (var item in list_visa)
  18889. // {
  18890. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18891. // temp.Id = item.Id;
  18892. // temp.DIId = item.DIId;
  18893. // temp.VisaClient = item.VisaClient;
  18894. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18895. // temp.VisaCurrency = item.VisaCurrency;
  18896. // temp.IsThird = item.IsThird;
  18897. // if (dic_psg.ContainsKey(item.PassengerType))
  18898. // {
  18899. // temp.PassengerType = dic_psg[item.PassengerType];
  18900. // }
  18901. // else {
  18902. // temp.PassengerType = -1;
  18903. // }
  18904. // temp.VisaNumber = item.VisaNumber;
  18905. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18906. // temp.CreateUserId = item.Operators;
  18907. // DateTime dt_ct;
  18908. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18909. // if (b_ct)
  18910. // {
  18911. // temp.CreateTime = dt_ct;
  18912. // }
  18913. // else
  18914. // {
  18915. // temp.CreateTime = DateTime.Now;
  18916. // }
  18917. // temp.DeleteTime = "";
  18918. // temp.DeleteUserId = 0;
  18919. // temp.Remark = item.Remark;
  18920. // if (string.IsNullOrEmpty(temp.Remark)) {
  18921. // temp.Remark = "";
  18922. // }
  18923. // temp.IsDel = item.IsDel;
  18924. // temp.VisaDescription = item.VisaAttachment;
  18925. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18926. //([Id]
  18927. // ,[DIId]
  18928. // ,[VisaClient]
  18929. // ,[VisaPrice]
  18930. // ,[VisaCurrency]
  18931. // ,[IsThird]
  18932. // ,[PassengerType]
  18933. // ,[VisaNumber]
  18934. // ,[VisaFreeNumber]
  18935. // ,[CreateUserId]
  18936. // ,[CreateTime]
  18937. // ,[DeleteTime]
  18938. // ,[DeleteUserId]
  18939. // ,[Remark]
  18940. // ,[IsDel]
  18941. // ,[visaDescription])
  18942. // VALUES
  18943. // ({0},{1},'{2}',{3},{4}
  18944. //,{5},{6},{7},{8},{9}
  18945. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18946. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18947. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18948. //);
  18949. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18950. // }
  18951. // return Ok(JsonView(true, "操作成功!"));
  18952. // }
  18953. /// <summary>
  18954. /// 123132123
  18955. /// </summary>
  18956. /// <param name="_dto"></param>
  18957. /// <returns></returns>
  18958. [HttpPost]
  18959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18960. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18961. {
  18962. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18963. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18964. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18965. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18966. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18967. dicDetail.Add(789, 1034);
  18968. dicDetail.Add(790, 1035);
  18969. dicDetail.Add(791, 1036);
  18970. dicDetail.Add(792, 1037);
  18971. dicDetail.Add(793, 1038);
  18972. dicDetail.Add(794, 1039);
  18973. dicDetail.Add(795, 1040);
  18974. dicDetail.Add(796, 1041);
  18975. dicDetail.Add(797, 1042);
  18976. dicDetail.Add(798, 1043);
  18977. dicDetail.Add(801, 1044);
  18978. dicDetail.Add(802, 1045);
  18979. dicDetail.Add(803, 1046);
  18980. Dictionary<int, int> dic = new Dictionary<int, int>();
  18981. dic.Add(806, 1027);
  18982. dic.Add(807, 1028);
  18983. dic.Add(808, 1029);
  18984. dic.Add(809, 1030);
  18985. dic.Add(810, 1031);
  18986. dic.Add(811, 1032);
  18987. dic.Add(812, 1033);
  18988. foreach (var item in list_visa)
  18989. {
  18990. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18991. temp.Coefficient = item.coefficient;
  18992. DateTime dtCrt;
  18993. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18994. if (b1)
  18995. {
  18996. temp.CreateTime = dtCrt;
  18997. }
  18998. else
  18999. {
  19000. temp.CreateTime = DateTime.Now;
  19001. }
  19002. temp.CreateUserId = item.Operators;
  19003. temp.DeleteTime = "";
  19004. temp.DeleteUserId = 0;
  19005. temp.DiId = int.Parse(item.DIID);
  19006. temp.FilePath = item.FilePath;
  19007. temp.IsDel = item.IsDel;
  19008. temp.Price = item.Price;
  19009. temp.PriceCount = 1;
  19010. temp.PriceCurrency = item.Currency;
  19011. int detailId = 0;
  19012. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19013. {
  19014. detailId = dicDetail[item.PriceTypeDetail];
  19015. }
  19016. temp.PriceDetailType = detailId;
  19017. temp.PriceDt = DateTime.Now;
  19018. temp.PriceName = item.PriceName;
  19019. temp.PriceSum = item.Price;
  19020. int tid = 0;
  19021. if (dic.ContainsKey(item.PriceType))
  19022. {
  19023. tid = dic[item.PriceType];
  19024. }
  19025. temp.PriceType = tid;
  19026. temp.Remark = item.Remark;
  19027. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19028. }
  19029. return Ok(JsonView(true, "操作成功!"));
  19030. }
  19031. [HttpPost]
  19032. public IActionResult TimeTest()
  19033. {
  19034. var jw = JsonView(false, "error");
  19035. _sqlSugar.BeginTran();
  19036. try
  19037. {
  19038. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19039. .Select(x => new Crm_NewClientData
  19040. {
  19041. Id = x.Id,
  19042. Client = x.Client,
  19043. Contact = x.Contact,
  19044. Location = x.Location,
  19045. })
  19046. .ToList();
  19047. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19048. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19049. Stopwatch stopwatch = new Stopwatch();
  19050. // 开始计时
  19051. stopwatch.Start();
  19052. foreach (var item in clientList)
  19053. {
  19054. EncryptionProcessor.DecryptProperties(item);
  19055. }
  19056. stopwatch.Stop();
  19057. jw.Code = 200;
  19058. jw.Data = stopwatch.ElapsedMilliseconds;
  19059. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19060. }
  19061. catch (Exception ex)
  19062. {
  19063. jw.Code = 400;
  19064. jw.Msg = ex.Message;
  19065. }
  19066. return Ok(jw);
  19067. }
  19068. }
  19069. }