GroupsController.cs 233 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. namespace OASystem.API.Controllers
  44. {
  45. /// <summary>
  46. /// 团组相关
  47. /// </summary>
  48. //[Authorize]
  49. [Route("api/[controller]/[action]")]
  50. public class GroupsController : ControllerBase
  51. {
  52. private readonly GrpScheduleRepository _grpScheduleRep;
  53. private readonly IMapper _mapper;
  54. private readonly DelegationInfoRepository _groupRepository;
  55. private readonly TaskAssignmentRepository _taskAssignmentRep;
  56. private readonly AirTicketResRepository _airTicketResRep;
  57. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  58. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  59. private readonly DelegationEnDataRepository _delegationEnDataRep;
  60. private readonly DelegationVisaRepository _delegationVisaRep;
  61. private readonly VisaPriceRepository _visaPriceRep;
  62. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  63. private readonly HotelPriceRepository _hotelPriceRep;
  64. private readonly CustomersRepository _customersRep;
  65. private readonly MessageRepository _message;
  66. private readonly SqlSugarClient _sqlSugar;
  67. private readonly TourClientListRepository _tourClientListRep;
  68. #region 成本相关
  69. private readonly CheckBoxsRepository _checkBoxs;
  70. private readonly GroupCostRepository _GroupCostRepository;
  71. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  72. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  73. #endregion
  74. private readonly SetDataRepository _setDataRep;
  75. private string url;
  76. private string path;
  77. private readonly EnterExitCostRepository _enterExitCostRep;
  78. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  79. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  80. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  81. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  82. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  83. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  84. TourClientListRepository tourClientListRep)
  85. {
  86. _mapper = mapper;
  87. _grpScheduleRep = grpScheduleRep;
  88. _groupRepository = groupRepository;
  89. _taskAssignmentRep = taskAssignmentRep;
  90. _airTicketResRep = airTicketResRep;
  91. _sqlSugar = sqlSugar;
  92. url = AppSettingsHelper.Get("ExcelBaseUrl");
  93. path = AppSettingsHelper.Get("ExcelBasePath");
  94. if (!System.IO.Directory.Exists(path))
  95. {
  96. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  97. }
  98. _decreasePaymentsRep = decreasePaymentsRep;
  99. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  100. _delegationEnDataRep = delegationEnDataRep;
  101. _enterExitCostRep = enterExitCostRep;
  102. _delegationVisaRep = delegationVisaRep;
  103. _message = message;
  104. _visaPriceRep = visaPriceRep;
  105. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  106. _checkBoxs = checkBoxs;
  107. _GroupCostRepository = GroupCostRepository;
  108. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  109. _GroupCostParameterRepository = GroupCostParameterRepository;
  110. _hotelPriceRep = hotelPriceRep;
  111. _customersRep = customersRep;
  112. _setDataRep = setDataRep;
  113. _tourClientListRep = tourClientListRep;
  114. }
  115. #region 流程管控
  116. /// <summary>
  117. /// 获取团组流程管控信息
  118. /// </summary>
  119. /// <param name="paras">参数Json字符串</param>
  120. /// <returns></returns>
  121. [HttpPost]
  122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  123. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  124. {
  125. if (string.IsNullOrEmpty(_jsonDto.Paras))
  126. {
  127. return Ok(JsonView(false, "参数为空"));
  128. }
  129. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  130. if (_ScheduleDto != null)
  131. {
  132. if (_ScheduleDto.SearchType == 2)//获取列表
  133. {
  134. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  135. return Ok(JsonView(_grpScheduleViewList));
  136. }
  137. else//获取对象
  138. {
  139. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  140. if (_grpScheduleView != null)
  141. {
  142. return Ok(JsonView(_grpScheduleView));
  143. }
  144. }
  145. }
  146. else
  147. {
  148. return Ok(JsonView(false, "参数反序列化失败"));
  149. }
  150. return Ok(JsonView(false, "暂无数据!"));
  151. }
  152. /// <summary>
  153. /// 修改团组流程管控详细表数据
  154. /// </summary>
  155. /// <param name="paras"></param>
  156. /// <returns></returns>
  157. [HttpPost]
  158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  159. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  160. {
  161. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  162. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  163. .SetColumns(it => it.Duty == _detail.Duty)
  164. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  165. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  166. .SetColumns(it => it.JobContent == _detail.JobContent)
  167. .SetColumns(it => it.Remark == _detail.Remark)
  168. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  169. .Where(s => s.Id == dto.Id)
  170. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  171. .ExecuteCommandAsync();
  172. if (result > 0)
  173. {
  174. return Ok(JsonView(true, "保存成功!"));
  175. }
  176. return Ok(JsonView(false, "保存失败!"));
  177. }
  178. /// <summary>
  179. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  180. /// </summary>
  181. /// <param name="dto"></param>
  182. /// <returns></returns>
  183. [HttpPost]
  184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  185. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  186. {
  187. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  188. _detail.IsDel = 1;
  189. _detail.DeleteUserId = dto.Duty;
  190. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  191. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  192. .SetColumns(it => it.IsDel == _detail.IsDel)
  193. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  194. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  195. .Where(it => it.Id == dto.Id)
  196. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  197. //.WhereColumns(s => s.Id == dto.Id)
  198. .ExecuteCommandAsync();
  199. if (result > 0)
  200. {
  201. return Ok(JsonView(true, "删除成功!"));
  202. }
  203. return Ok(JsonView(false, "删除失败!"));
  204. }
  205. /// <summary>
  206. /// 增加团组流程管控详细表数据
  207. /// </summary>
  208. /// <param name="dto"></param>
  209. /// <returns></returns>
  210. [HttpPost]
  211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  212. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  213. {
  214. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  215. if (DateTime.Now < _detail.ExpectBeginDt)
  216. {
  217. _detail.StepStatus = 0;
  218. }
  219. else
  220. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  221. _detail.StepStatus = 1;
  222. }
  223. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  224. if (result > 0)
  225. {
  226. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  227. return Ok(JsonView(true, "添加成功!", _result));
  228. }
  229. return Ok(JsonView(false, "添加失败!"));
  230. }
  231. #endregion
  232. #region 团组基本信息
  233. /// <summary>
  234. /// 接团信息列表
  235. /// </summary>
  236. /// <param name="dto">团组列表请求dto</param>
  237. /// <returns></returns>
  238. [HttpPost]
  239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  240. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  241. {
  242. var groupData = await _groupRepository.GetGroupList(dto);
  243. if (groupData.Code != 0)
  244. {
  245. return Ok(JsonView(false, groupData.Msg));
  246. }
  247. return Ok(JsonView(groupData.Data));
  248. }
  249. /// <summary>
  250. /// 接团信息列表 Page
  251. /// </summary>
  252. /// <param name="dto">团组列表请求dto</param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  257. {
  258. #region 参数验证
  259. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  260. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  261. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  262. #region 页面操作权限验证
  263. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  264. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  265. #endregion
  266. #endregion
  267. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  268. {
  269. string sqlWhere = string.Empty;
  270. if (dto.IsSure == 0) //未完成
  271. {
  272. sqlWhere += string.Format(@" And IsSure = 0");
  273. }
  274. else if (dto.IsSure == 1) //已完成
  275. {
  276. sqlWhere += string.Format(@" And IsSure = 1");
  277. }
  278. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  279. {
  280. string tj = dto.SearchCriteria;
  281. 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}%')",
  282. tj, tj, tj, tj, tj);
  283. }
  284. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  285. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  286. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  287. From (
  288. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  289. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  290. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  291. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  292. From Grp_DelegationInfo gdi
  293. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  294. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  295. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  296. Where gdi.IsDel = 0 {0}
  297. ) temp ", sqlWhere);
  298. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  299. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  300. var _view = new
  301. {
  302. PageFuncAuth = pageFunAuthView,
  303. Data = _DelegationList
  304. };
  305. return Ok(JsonView(true, "查询成功!", _view, total));
  306. }
  307. else
  308. {
  309. return Ok(JsonView(false, "查询失败"));
  310. }
  311. }
  312. /// <summary>
  313. /// 接团信息详情
  314. /// </summary>
  315. /// <param name="dto">团组info请求dto</param>
  316. /// <returns></returns>
  317. [HttpPost]
  318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  319. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  320. {
  321. var groupData = await _groupRepository.GetGroupInfo(dto);
  322. if (groupData.Code != 0)
  323. {
  324. return Ok(JsonView(false, groupData.Msg));
  325. }
  326. return Ok(JsonView(groupData.Data));
  327. }
  328. /// <summary>
  329. /// 接团信息 编辑添加
  330. /// 基础信息数据源
  331. /// </summary>
  332. /// <param name="dto"></param>
  333. /// <returns></returns>
  334. [HttpPost]
  335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  336. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  337. {
  338. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  339. if (groupData.Code != 0)
  340. {
  341. return Ok(JsonView(false, groupData.Msg));
  342. }
  343. return Ok(JsonView(groupData.Data));
  344. }
  345. /// <summary>
  346. /// 接团信息 操作(增改)
  347. /// </summary>
  348. /// <param name="dto"></param>
  349. /// <returns></returns>
  350. [HttpPost]
  351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  352. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  353. {
  354. try
  355. {
  356. var groupData = await _groupRepository.GroupOperation(dto);
  357. if (groupData.Code != 0)
  358. {
  359. return Ok(JsonView(false, groupData.Msg));
  360. }
  361. return Ok(JsonView(true));
  362. }
  363. catch (Exception ex)
  364. {
  365. Logs("[response]" + JsonConvert.SerializeObject(dto));
  366. Logs(ex.Message);
  367. return Ok(JsonView(false, ex.Message));
  368. }
  369. }
  370. /// <summary>
  371. /// 接团信息 操作(删除)
  372. /// </summary>
  373. /// <param name="dto"></param>
  374. /// <returns></returns>
  375. [HttpPost]
  376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  377. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  378. {
  379. try
  380. {
  381. var groupData = await _groupRepository.GroupDel(dto);
  382. if (groupData.Code != 0)
  383. {
  384. return Ok(JsonView(false, groupData.Msg));
  385. }
  386. return Ok(JsonView(true));
  387. }
  388. catch (Exception ex)
  389. {
  390. Logs("[response]" + JsonConvert.SerializeObject(dto));
  391. Logs(ex.Message);
  392. return Ok(JsonView(false, ex.Message));
  393. }
  394. }
  395. /// <summary>
  396. /// 获取团组销售报价号
  397. /// 团组添加时 使用
  398. /// </summary>
  399. /// <returns></returns>
  400. [HttpPost]
  401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  402. public async Task<IActionResult> GetGroupSalesQuoteNo()
  403. {
  404. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  405. if (groupData.Code != 0)
  406. {
  407. return Ok(JsonView(false, groupData.Msg));
  408. }
  409. object salesQuoteNo = new
  410. {
  411. SalesQuoteNo = groupData.Data
  412. };
  413. return Ok(JsonView(salesQuoteNo));
  414. }
  415. /// <summary>
  416. /// 设置确认出团
  417. /// </summary>
  418. /// <param name="dto"></param>
  419. /// <returns></returns>
  420. [HttpPost]
  421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  422. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  423. {
  424. var groupData = await _groupRepository.ConfirmationGroup(dto);
  425. if (groupData.Code != 0)
  426. {
  427. return Ok(JsonView(false, groupData.Msg));
  428. }
  429. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  430. return Ok(JsonView(true, "操作成功!", groupData.Data));
  431. }
  432. /// <summary>
  433. /// 获取团组名称data And 签证国别Data
  434. /// </summary>
  435. /// <param name="dto"></param>
  436. /// <returns></returns>
  437. [HttpPost]
  438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  439. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  440. {
  441. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  442. if (groupData.Code != 0)
  443. {
  444. return Ok(JsonView(false, groupData.Msg));
  445. }
  446. return Ok(JsonView(groupData.Data));
  447. }
  448. /// <summary>
  449. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  450. /// </summary>
  451. /// <returns></returns>
  452. [HttpPost]
  453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  454. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  455. {
  456. try
  457. {
  458. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  459. if (groupData.Code != 0)
  460. {
  461. return Ok(JsonView(false, groupData.Msg));
  462. }
  463. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  464. }
  465. catch (Exception ex)
  466. {
  467. return Ok(JsonView(false, "程序错误!"));
  468. throw;
  469. }
  470. }
  471. #endregion
  472. #region 团组&签证
  473. /// <summary>
  474. /// 根据团组Id获取签证客户信息List
  475. /// </summary>
  476. /// <param name="dto">请求dto</param>
  477. /// <returns></returns>
  478. [HttpPost]
  479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  480. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  481. {
  482. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  483. if (groupData.Code != 0)
  484. {
  485. return Ok(JsonView(false, groupData.Msg));
  486. }
  487. return Ok(JsonView(groupData.Data));
  488. }
  489. /// <summary>
  490. /// IOS获取团组签证拍照上传进度01(团组列表)
  491. /// </summary>
  492. /// <param name="dto">请求dto</param>
  493. /// <returns></returns>
  494. [HttpPost]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  497. {
  498. if (dto == null)
  499. {
  500. return Ok(JsonView(false, "参数为空"));
  501. }
  502. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  503. return Ok(JsonView(visaList));
  504. }
  505. /// <summary>
  506. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  507. /// </summary>
  508. /// <returns></returns>
  509. [HttpPost]
  510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  511. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  512. {
  513. if (dto == null)
  514. {
  515. return Ok(JsonView(false, "请求错误:"));
  516. }
  517. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  518. return Ok(JsonView(list));
  519. }
  520. /// <summary>
  521. /// IOS获取团组签证拍照上传进度03(相册)
  522. /// </summary>
  523. /// <returns></returns>
  524. [HttpPost]
  525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  526. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  527. {
  528. if (dto == null)
  529. {
  530. return Ok(JsonView(false, "请求错误:"));
  531. }
  532. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  533. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  534. list.ForEach(s => s.url = url);
  535. return Ok(JsonView(list));
  536. }
  537. /// <summary>
  538. /// IOS获取团组签证拍照上传进度04(图片上传)
  539. /// </summary>
  540. /// <param name="dto"></param>
  541. /// <returns></returns>
  542. [HttpPost]
  543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  544. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  545. {
  546. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  547. //if (!string.IsNullOrEmpty(result))
  548. //{
  549. //}
  550. //else {
  551. // return Ok(JsonView(false, "上传失败"));
  552. //}
  553. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  554. int sucNum = 0;
  555. try
  556. {
  557. foreach (var item in dto.base64DataList)
  558. {
  559. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  560. string result = decodeBase64ToImage(item, imageName);
  561. if (!string.IsNullOrEmpty(result))
  562. {
  563. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  564. pic.CreateUserId = dto.CreateUserId;
  565. pic.PicName = imageName;
  566. pic.PicPath = result;
  567. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  568. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  569. if (insertResult > 0)
  570. {
  571. sucNum++;
  572. }
  573. }
  574. }
  575. }
  576. catch (Exception ex)
  577. {
  578. return Ok(JsonView(false, ex.Message));
  579. }
  580. string msg = string.Format(@"成功上传{0}张", sucNum);
  581. return Ok(JsonView(true, msg));
  582. }
  583. private string decodeBase64ToImage(string base64DataURL, string imgName)
  584. {
  585. string filename = "";//声明一个string类型的相对路径
  586. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  587. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  588. try//会有异常抛出,try,catch一下
  589. {
  590. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  591. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  592. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  593. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  594. //文件名称
  595. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  596. //上传的文件的路径
  597. string filePath = "";
  598. if (!Directory.Exists(fileDir))
  599. {
  600. Directory.CreateDirectory(fileDir);
  601. }
  602. //上传的文件的路径
  603. filePath = fileDir + filename;
  604. //string url = HttpRuntime.AppDomainAppPath.ToString();
  605. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  606. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  607. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  608. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  609. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  610. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  611. ms.Close();//关闭当前流,并释放所有与之关联的资源
  612. bitmap.Dispose();
  613. }
  614. catch (Exception e)
  615. {
  616. string massage = e.Message;
  617. Logs("IOS图片上传Error:" + massage);
  618. //filename = e.Message;
  619. }
  620. return filename;//返回相对路径
  621. }
  622. /// <summary>
  623. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  624. /// </summary>
  625. /// <param name="dto"></param>
  626. /// <returns></returns>
  627. [HttpPost]
  628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  629. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  630. {
  631. if (dto == null)
  632. {
  633. return Ok(JsonView(false, "请求错误:"));
  634. }
  635. string msg = "参数错误";
  636. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  637. {
  638. try
  639. {
  640. //_delegationVisaRep.BeginTran();
  641. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  642. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  643. .Where(s => s.Id == dto.visaProgressCustomerId)
  644. .ExecuteCommandAsync();
  645. if (updCount > 0 && dto.publishCode == 1)
  646. {
  647. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  648. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  649. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  650. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  651. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  652. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  653. if (groupData == null)
  654. {
  655. _delegationVisaRep.RollbackTran();
  656. }
  657. string title = string.Format(@"[签证进度更新]");
  658. string content = string.Format(@"测试文本");
  659. bool rst = await _message.AddMsg(new MessageDto()
  660. {
  661. Type = 5,
  662. IssuerId = dto.publisher,
  663. Title = title,
  664. Content = content,
  665. ReleaseTime = DateTime.Now,
  666. UIdList = new List<int> {
  667. 234
  668. }
  669. });
  670. if (rst)
  671. {
  672. return Ok(JsonView(true, "发送通知成功"));
  673. }
  674. }
  675. //_delegationVisaRep.CommitTran();
  676. }
  677. catch (Exception)
  678. {
  679. //_delegationVisaRep.RollbackTran();
  680. }
  681. }
  682. return Ok(JsonView(true, msg));
  683. }
  684. #endregion
  685. #region 团组任务分配
  686. /// <summary>
  687. /// 团组任务分配初始化
  688. /// </summary>
  689. /// <param name="dto"></param>
  690. /// <returns></returns>
  691. [HttpPost]
  692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  693. public async Task<IActionResult> GetTaskAssignmen()
  694. {
  695. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  696. if (groupData.Code != 0)
  697. {
  698. return Ok(JsonView(false, groupData.Msg));
  699. }
  700. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  701. }
  702. /// <summary>
  703. /// 团组任务分配查询
  704. /// </summary>
  705. /// <param name="dto"></param>
  706. /// <returns></returns>
  707. [HttpPost]
  708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  709. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  710. {
  711. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  712. if (groupData.Code != 0)
  713. {
  714. return Ok(JsonView(false, groupData.Msg));
  715. }
  716. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  717. }
  718. /// <summary>
  719. /// 团组任务分配操作
  720. /// </summary>
  721. /// <param name="dto"></param>
  722. /// <returns></returns>
  723. [HttpPost]
  724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  725. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  726. {
  727. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  728. if (groupData.Code != 0)
  729. {
  730. return Ok(JsonView(false, groupData.Msg));
  731. }
  732. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  733. }
  734. #endregion
  735. #region 团组费用审核
  736. /// <summary>
  737. /// 费用审核
  738. /// 团组列表 Page
  739. /// </summary>
  740. /// <param name="_dto">团组列表请求dto</param>
  741. /// <returns></returns>
  742. [HttpPost]
  743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  744. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  745. {
  746. #region 参数验证
  747. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  748. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  749. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  750. #region 页面操作权限验证
  751. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  752. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  753. #endregion
  754. #endregion
  755. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  756. {
  757. string sqlWhere = string.Empty;
  758. if (_dto.IsSure == 0) //未完成
  759. {
  760. sqlWhere += string.Format(@" And IsSure = 0");
  761. }
  762. else if (_dto.IsSure == 1) //已完成
  763. {
  764. sqlWhere += string.Format(@" And IsSure = 1");
  765. }
  766. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  767. {
  768. string tj = _dto.SearchCriteria;
  769. 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}%')",
  770. tj, tj, tj, tj, tj);
  771. }
  772. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  773. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  774. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  775. From (
  776. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  777. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  778. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  779. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  780. From Grp_DelegationInfo gdi
  781. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  782. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  783. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  784. Where gdi.IsDel = 0 {0}
  785. ) temp ", sqlWhere);
  786. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  787. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  788. var _view = new
  789. {
  790. PageFuncAuth = pageFunAuthView,
  791. Data = _DelegationList
  792. };
  793. return Ok(JsonView(true, "查询成功!", _view, total));
  794. }
  795. else
  796. {
  797. return Ok(JsonView(false, "查询失败"));
  798. }
  799. }
  800. /// <summary>
  801. /// 获取团组费用审核
  802. /// </summary>
  803. /// <param name="paras">参数Json字符串</param>
  804. /// <returns></returns>
  805. [HttpPost]
  806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  807. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  808. {
  809. try
  810. {
  811. #region 参数验证
  812. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  813. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  814. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  815. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  816. #region 页面操作权限验证
  817. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  818. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  819. #endregion
  820. #endregion
  821. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  822. #region 费用清单
  823. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  824. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  825. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  826. List<Grp_CreditCardPayment> entityList = _groupRepository
  827. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  828. .Where(exp.ToExpression())
  829. .ToList();
  830. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  831. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  832. /*
  833. * 76://酒店预订
  834. */
  835. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  836. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  837. .ToListAsync();
  838. /*
  839. * 79://车/导游地接
  840. */
  841. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  842. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  843. .ToListAsync();
  844. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  845. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  846. .ToListAsync();
  847. /*
  848. * 80: //签证
  849. */
  850. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  851. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  852. .ToListAsync();
  853. /*
  854. *81: //邀请/公务活动
  855. */
  856. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  857. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  858. .ToListAsync();
  859. /*
  860. * 82: //团组客户保险
  861. */
  862. /*
  863. * Label = 98 其他款项
  864. */
  865. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  866. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  867. .ToListAsync();
  868. /*
  869. * Lable = 85 机票预订
  870. */
  871. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  872. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  873. .ToListAsync();
  874. /*
  875. * 98 机票预定
  876. */
  877. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  878. /*
  879. * 285://收款退还
  880. */
  881. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys= await _groupRepository
  882. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  883. .ToListAsync();
  884. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0) .ToListAsync();
  885. /*
  886. * 币种信息
  887. */
  888. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  889. /*
  890. * 车/导游地接 费用类型
  891. */
  892. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  893. /*
  894. * 用户信息
  895. */
  896. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  897. /*
  898. * 费用模块
  899. */
  900. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  901. string priceModule = string.Empty;
  902. if (sdPriceName != null)
  903. {
  904. priceModule = sdPriceName.Name;
  905. }
  906. /*
  907. * 处理详情数据
  908. */
  909. foreach (var entity in entityList)
  910. {
  911. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  912. _detail.Id = entity.Id;
  913. _detail.PriceName = priceModule;
  914. /*
  915. * 应付款金额
  916. */
  917. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  918. string PaymentCurrency_WaitPay = "Unknown";
  919. string hotelCurrncyCode = "Unknown";
  920. string hotelCurrncyName = "Unknown";
  921. if (sdPaymentCurrency_WaitPay != null)
  922. {
  923. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  924. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  925. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  926. }
  927. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1() + " " + PaymentCurrency_WaitPay;
  928. /*
  929. * 此次付款金额
  930. */
  931. decimal CurrPayStr = 0;
  932. if (entity.PayPercentage == 0)
  933. {
  934. if (entity.PayThenMoney != 0)
  935. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  936. }
  937. else
  938. {
  939. CurrPayStr = (entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * entity.DayRate)).ConvertToDecimal1();
  940. }
  941. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  942. /*
  943. * 剩余尾款
  944. */
  945. decimal BalanceStr = 0;
  946. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  947. BalanceStr = 0;
  948. else
  949. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  950. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  951. /*
  952. * Bus名称
  953. */
  954. _detail.BusName = "待增加";
  955. /*
  956. *费用所属
  957. */
  958. switch (entity.CTable)
  959. {
  960. case 76://酒店预订
  961. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  962. if (hotelReservations != null)
  963. {
  964. _detail.PriceMsgContent = "信用卡金额:" + _detail.WaitPay + " " + hotelCurrncyCode + "(" + hotelCurrncyName + ")<br/>" +
  965. "房间说明:" + hotelReservations.Remark;
  966. _detail.PriceNameContent = hotelReservations.HotelName;
  967. }
  968. break;
  969. case 79://车/导游地接
  970. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  971. if (touristGuideGroundReservations != null)
  972. {
  973. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  974. {
  975. _detail.BusName = touristGuideGroundReservations.BusName;
  976. }
  977. _detail.PriceNameContent = touristGuideGroundReservations.Area;
  978. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  979. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  980. string priceMsg = string.Empty;
  981. foreach (var item in touristGuideGroundReservationsContents)
  982. {
  983. string typeName = "Unknown";
  984. string carCurrencyCode = "Unknown";
  985. string carCurrencyName = "Unknown";
  986. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  987. if (carTypeData != null) typeName = carTypeData.Name;
  988. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  989. if (currencyData != null) {
  990. carCurrencyCode = currencyData.Name;
  991. carCurrencyName = currencyData.Remark;
  992. }
  993. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  994. "明细:" + item.PriceContent + "<br/>" +
  995. "备注:" + item.Remark + "<br/><br/>";
  996. }
  997. _detail.PriceMsgContent = priceMsg;
  998. }
  999. break;
  1000. case 80: //签证
  1001. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1002. if (visaInfo != null)
  1003. {
  1004. _detail.PriceNameContent = visaInfo.VisaClient;
  1005. _detail.PriceMsgContent = "备注:" + visaInfo.Remark;
  1006. }
  1007. break;
  1008. case 81: //邀请/公务活动
  1009. Grp_InvitationOfficialActivities invitationOfficialActivities = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1010. if (invitationOfficialActivities != null)
  1011. {
  1012. string ioaCurrencyCode = "Unknown";
  1013. string ioaCurrencyName= "Unknown";
  1014. var currencyData = currencyItems.Where(s => s.Id == invitationOfficialActivities.Currency && s.IsDel == 0).FirstOrDefault();
  1015. if (currencyData != null)
  1016. {
  1017. ioaCurrencyCode = currencyData.Name;
  1018. ioaCurrencyName = currencyData.Remark;
  1019. }
  1020. _detail.PriceNameContent = invitationOfficialActivities.InviterArea;
  1021. _detail.PriceMsgContent = "邀请费用:" + invitationOfficialActivities.InviteCosts + " "+ ioaCurrencyCode + "("+ ioaCurrencyName+ ")<br/>" +
  1022. "活动费用:- <br/>" +
  1023. "备注:" + invitationOfficialActivities.Remark + "<br/>";
  1024. }
  1025. break;
  1026. case 82: //团组客户保险
  1027. Grp_Customers customers = _Customers.Where(s => s.Id == entity.Id && s.IsDel == 0).FirstOrDefault();
  1028. if (customers != null)
  1029. {
  1030. _detail.PriceNameContent = customers.ClientName;
  1031. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1032. }
  1033. break;
  1034. case 85: //机票预订
  1035. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1036. if (jpRes != null)
  1037. {
  1038. string FlightsDescription = jpRes.FlightsDescription;
  1039. string PriceDescription = jpRes.PriceDescription;
  1040. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1041. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1042. }
  1043. break;
  1044. case 98://其他款项
  1045. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1046. if (gdpRes != null)
  1047. {
  1048. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1049. _detail.PriceNameContent = gdpRes.PriceName;
  1050. }
  1051. break;
  1052. case 285://收款退还
  1053. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1054. if (refundAndOtherMoney != null)
  1055. {
  1056. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1057. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1058. }
  1059. break;
  1060. case 751://酒店早餐
  1061. break;
  1062. default:
  1063. break;
  1064. }
  1065. /*
  1066. * 申请人
  1067. */
  1068. string operatorName = " - ";
  1069. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1070. if (_opUser != null)
  1071. {
  1072. operatorName = _opUser.CnName;
  1073. }
  1074. _detail.OperatorName = operatorName;
  1075. /*
  1076. * 审核人
  1077. */
  1078. string auditOperatorName = "Unknown";
  1079. if (entity.AuditGMOperate == 0)
  1080. auditOperatorName = " - ";
  1081. else if (entity.AuditGMOperate == 4)
  1082. auditOperatorName = "自动审核";
  1083. else
  1084. {
  1085. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1086. if (_adUser != null)
  1087. {
  1088. auditOperatorName = _adUser.CnName;
  1089. }
  1090. }
  1091. _detail.AuditOperatorName = auditOperatorName;
  1092. /*
  1093. * 超预算比例
  1094. */
  1095. string overBudgetStr = "";
  1096. if (entity.ExceedBudget == -1)
  1097. overBudgetStr = sdPriceName.Name + "尚无预算";
  1098. else if (entity.ExceedBudget == 0)
  1099. overBudgetStr = "未超预算";
  1100. else
  1101. overBudgetStr = entity.ExceedBudget.ToString("P");
  1102. _detail.OverBudget = overBudgetStr;
  1103. /*
  1104. * 费用总计
  1105. */
  1106. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1107. {
  1108. CurrencyId = entity.PaymentCurrency,
  1109. CurrencyName = PaymentCurrency_WaitPay,
  1110. AmountPayable = entity.PayMoney,
  1111. ThisPayment = CurrPayStr,
  1112. BalancePayment = BalanceStr,
  1113. AuditedFunds = CurrPayStr
  1114. });
  1115. _detail.IsAuditGM = entity.IsAuditGM;
  1116. detailList.Add(_detail);
  1117. }
  1118. #endregion
  1119. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1120. /*
  1121. * 下方描述处理
  1122. */
  1123. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1124. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1125. if (ccpCurrencyPrice != null)
  1126. {
  1127. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1128. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1129. }
  1130. else
  1131. {
  1132. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1133. }
  1134. string amountPayableStr = string.Format(@"应付款总金额: ");
  1135. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1136. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1137. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1138. foreach (var item in nonDuplicat)
  1139. {
  1140. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1141. if (strs.Count > 0)
  1142. {
  1143. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1144. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1145. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1146. //单独处理此次付款金额
  1147. if (item.CurrencyId == 836) //人名币
  1148. {
  1149. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1150. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1151. }
  1152. else
  1153. {
  1154. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|","0.00", item.CurrencyName);
  1155. }
  1156. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1157. //单独处理已审核费用
  1158. if (item.CurrencyId == 836) //人名币
  1159. {
  1160. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1161. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1162. }
  1163. else
  1164. {
  1165. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1166. }
  1167. }
  1168. }
  1169. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1170. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1171. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1172. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1173. var _view1 = new
  1174. {
  1175. PageFuncAuth = pageFunAuthView,
  1176. Data = _view
  1177. };
  1178. return Ok(JsonView(_view1));
  1179. }
  1180. catch (Exception ex)
  1181. {
  1182. return Ok(JsonView(false, ex.Message));
  1183. }
  1184. }
  1185. /// <summary>
  1186. /// 费用审核
  1187. /// 修改团组费用审核状态
  1188. /// </summary>
  1189. /// <param name="_dto">参数Json字符串</param>
  1190. /// <returns></returns>
  1191. [HttpPost]
  1192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1193. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1194. {
  1195. #region 参数验证
  1196. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1197. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1198. #endregion
  1199. #region 页面操作权限验证
  1200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1201. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1202. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1203. #endregion
  1204. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1205. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1206. DateTime dtNow = DateTime.Now;
  1207. _groupRepository.BeginTran();
  1208. int rst = 0;
  1209. foreach (var item in idList)
  1210. {
  1211. int CreditId = int.Parse(item);
  1212. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1213. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1214. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1215. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1216. .Where(s => s.Id == CreditId)
  1217. .ExecuteCommandAsync();
  1218. if (result < 1)
  1219. {
  1220. rst = -1;
  1221. _groupRepository.RollbackTran();
  1222. return Ok(JsonView(false, "操作失败并回滚!"));
  1223. }
  1224. else
  1225. {
  1226. }
  1227. }
  1228. _groupRepository.CommitTran();
  1229. if (rst == 0)
  1230. {
  1231. return Ok(JsonView(true, "操作成功!"));
  1232. }
  1233. return Ok(JsonView(false, "操作失败!"));
  1234. }
  1235. #endregion
  1236. #region 机票费用录入
  1237. /// <summary>
  1238. /// 机票录入当前登录人可操作团组
  1239. /// </summary>
  1240. /// <param name="dto"></param>
  1241. /// <returns></returns>
  1242. [HttpPost]
  1243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1244. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1245. {
  1246. try
  1247. {
  1248. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1249. if (groupData.Code != 0)
  1250. {
  1251. return Ok(JsonView(false, groupData.Msg));
  1252. }
  1253. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1254. }
  1255. catch (Exception ex)
  1256. {
  1257. return Ok(JsonView(false, "程序错误!"));
  1258. throw;
  1259. }
  1260. }
  1261. /// <summary>
  1262. /// 机票费用录入列表
  1263. /// </summary>
  1264. /// <param name="dto"></param>
  1265. /// <returns></returns>
  1266. [HttpPost]
  1267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1268. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1269. {
  1270. try
  1271. {
  1272. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1273. if (groupData.Code != 0)
  1274. {
  1275. return Ok(JsonView(false, groupData.Msg));
  1276. }
  1277. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1278. }
  1279. catch (Exception ex)
  1280. {
  1281. return Ok(JsonView(false, "程序错误!"));
  1282. throw;
  1283. }
  1284. }
  1285. /// <summary>
  1286. /// 根据id查询费用录入信息
  1287. /// </summary>
  1288. /// <param name="dto"></param>
  1289. /// <returns></returns>
  1290. [HttpPost]
  1291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1292. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1293. {
  1294. try
  1295. {
  1296. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1297. if (groupData.Code != 0)
  1298. {
  1299. return Ok(JsonView(false, groupData.Msg));
  1300. }
  1301. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1302. }
  1303. catch (Exception ex)
  1304. {
  1305. return Ok(JsonView(false, "程序错误!"));
  1306. throw;
  1307. }
  1308. }
  1309. /// <summary>
  1310. /// 机票费用录入操作(Status:1.新增,2.修改)
  1311. /// </summary>
  1312. /// <param name="dto"></param>
  1313. /// <returns></returns>
  1314. [HttpPost]
  1315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1316. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1317. {
  1318. try
  1319. {
  1320. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  1321. if (groupData.Code != 0)
  1322. {
  1323. return Ok(JsonView(false, groupData.Msg));
  1324. }
  1325. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1326. }
  1327. catch (Exception ex)
  1328. {
  1329. return Ok(JsonView(false, "程序错误!"));
  1330. throw;
  1331. }
  1332. }
  1333. /// <summary>
  1334. /// 根据舱位类型查询接团客户名单信息
  1335. /// </summary>
  1336. /// <param name="dto"></param>
  1337. /// <returns></returns>
  1338. [HttpPost]
  1339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1340. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1341. {
  1342. try
  1343. {
  1344. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1345. if (crm_Groups.Count != 0)
  1346. {
  1347. List<dynamic> Customer = new List<dynamic>();
  1348. foreach (var item in crm_Groups)
  1349. {
  1350. var data = new
  1351. {
  1352. Id = item.Id,
  1353. Pinyin = item.Pinyin,
  1354. Name = item.LastName + item.FirstName
  1355. };
  1356. Customer.Add(data);
  1357. }
  1358. return Ok(JsonView(true, "查询成功!", Customer));
  1359. }
  1360. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1361. }
  1362. catch (Exception ex)
  1363. {
  1364. return Ok(JsonView(false, "程序错误!"));
  1365. throw;
  1366. }
  1367. }
  1368. /// <summary>
  1369. /// 机票费用录入,删除
  1370. /// </summary>
  1371. /// <param name="dto"></param>
  1372. /// <returns></returns>
  1373. [HttpPost]
  1374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1375. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1376. {
  1377. try
  1378. {
  1379. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1380. if (!res)
  1381. {
  1382. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1383. {
  1384. IsDel = 1,
  1385. DeleteUserId = dto.DeleteUserId,
  1386. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1387. }).ExecuteCommandAsync();
  1388. return Ok(JsonView(false, "删除失败"));
  1389. }
  1390. return Ok(JsonView(true, "删除成功!"));
  1391. }
  1392. catch (Exception ex)
  1393. {
  1394. return Ok(JsonView(false, "程序错误!"));
  1395. throw;
  1396. }
  1397. }
  1398. /// <summary>
  1399. /// 导出机票录入报表
  1400. /// </summary>
  1401. /// <param name="dto"></param>
  1402. /// <returns></returns>
  1403. [HttpPost]
  1404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1405. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  1406. {
  1407. try
  1408. {
  1409. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  1410. if (groupData.Code != 0)
  1411. {
  1412. return Ok(JsonView(false, groupData.Msg));
  1413. }
  1414. else
  1415. {
  1416. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  1417. if (AirTicketReservations.Count != 0)
  1418. {
  1419. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  1420. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  1421. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  1422. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  1423. WorkbookDesigner designer = new WorkbookDesigner();
  1424. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  1425. decimal countCost = 0;
  1426. foreach (var item in AirTicketReservations)
  1427. {
  1428. if (item.BankType == "其他")
  1429. {
  1430. item.BankNo = "--";
  1431. }
  1432. else
  1433. {
  1434. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  1435. }
  1436. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  1437. item.Price = System.Decimal.Round(item.Price, 2);
  1438. countCost += Convert.ToDecimal(item.Price);
  1439. }
  1440. designer.SetDataSource("Export", AirTicketReservations);
  1441. designer.SetDataSource("ExportDiCode", diCode);
  1442. designer.SetDataSource("ExportDiName", diName);
  1443. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  1444. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  1445. designer.Process();
  1446. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1447. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  1448. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  1449. return Ok(JsonView(true, "成功", url = rst));
  1450. }
  1451. else
  1452. {
  1453. return Ok(JsonView(false, "暂无数据!"));
  1454. }
  1455. }
  1456. }
  1457. catch (Exception ex)
  1458. {
  1459. return Ok(JsonView(false, "程序错误!"));
  1460. throw;
  1461. }
  1462. }
  1463. Dictionary<string, string> transDic = new Dictionary<string, string>();
  1464. /// <summary>
  1465. /// 行程单导出
  1466. /// </summary>
  1467. /// <param name="dto"></param>
  1468. /// <returns></returns>
  1469. [HttpPost]
  1470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1471. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  1472. {
  1473. try
  1474. {
  1475. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  1476. if (groupData.Code != 0)
  1477. {
  1478. return Ok(JsonView(false, groupData.Msg));
  1479. }
  1480. else
  1481. {
  1482. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  1483. if (dto.Language == "CN")
  1484. {
  1485. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  1486. DocumentBuilder builder = new DocumentBuilder(doc);
  1487. int tableIndex = 0;//表格索引
  1488. //得到文档中的第一个表格
  1489. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1490. foreach (var item in _AirTicketReservations)
  1491. {
  1492. #region 处理固定数据
  1493. string[] FlightsCode = item.FlightsCode.Split('/');
  1494. if (FlightsCode.Length != 0)
  1495. {
  1496. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1497. if (_AirCompany != null)
  1498. {
  1499. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1500. }
  1501. else
  1502. {
  1503. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1504. }
  1505. }
  1506. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1507. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1508. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1509. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1510. string name = "";
  1511. foreach (string clientName in nameArray)
  1512. {
  1513. if (!name.Contains(clientName))
  1514. {
  1515. name += clientName + ",";
  1516. }
  1517. }
  1518. if (!string.IsNullOrWhiteSpace(name))
  1519. {
  1520. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1521. }
  1522. else
  1523. {
  1524. table.Range.Bookmarks["ClientName"].Text = "--";
  1525. }
  1526. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1527. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1528. table.Range.Bookmarks["JointTicket"].Text = "--";
  1529. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1530. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1531. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1532. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1533. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1534. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1535. #endregion
  1536. #region 循环数据处理
  1537. List<AirInfo> airs = new List<AirInfo>();
  1538. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1539. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1540. for (int i = 0; i < FlightsCode.Length; i++)
  1541. {
  1542. AirInfo air = new AirInfo();
  1543. string[] tempstr = DayArray[i]
  1544. .Replace("\r\n", string.Empty)
  1545. .Replace("\\r\\n", string.Empty)
  1546. .TrimStart().TrimEnd()
  1547. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1548. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1549. string starCity = "";
  1550. if (star_Three != null)
  1551. {
  1552. starCity = star_Three.AirPort;
  1553. }
  1554. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1555. string EndCity = "";
  1556. if (End_Three != null)
  1557. {
  1558. EndCity = End_Three.AirPort;
  1559. }
  1560. air.Destination = starCity + "/" + EndCity;
  1561. air.Flight = FlightsCode[i];
  1562. air.SeatingClass = item.CTypeName;
  1563. string dateTime = tempstr[2];
  1564. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1565. air.FlightDate = DateTemp;
  1566. air.DepartureTime = tempstr[5];
  1567. air.LandingTime = tempstr[6];
  1568. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1569. air.TicketStatus = "--";
  1570. air.Luggage = "--";
  1571. air.DepartureTerminal = "--";
  1572. air.LandingTerminal = "--";
  1573. airs.Add(air);
  1574. }
  1575. int row = 13;
  1576. for (int i = 0; i < airs.Count; i++)
  1577. {
  1578. if (airs.Count > 2)
  1579. {
  1580. for (int j = 0; j < airs.Count - 2; j++)
  1581. {
  1582. var CopyRow = table.Rows[12].Clone(true);
  1583. table.Rows.Add(CopyRow);
  1584. }
  1585. }
  1586. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1587. int index = 0;
  1588. foreach (PropertyInfo property in properties)
  1589. {
  1590. string value = property.GetValue(airs[i]).ToString();
  1591. Cell ishcel0 = table.Rows[row].Cells[index];
  1592. Paragraph p = new Paragraph(doc);
  1593. string s = value;
  1594. p.AppendChild(new Run(doc, s));
  1595. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1596. ishcel0.AppendChild(p);
  1597. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1598. index++;
  1599. }
  1600. row++;
  1601. }
  1602. #endregion
  1603. Paragraph lastParagraph = new Paragraph(doc);
  1604. //第一个表格末尾加段落
  1605. table.ParentNode.InsertAfter(lastParagraph, table);
  1606. //复制第一个表格
  1607. Table cloneTable = (Table)table.Clone(true);
  1608. //在文档末尾段落后面加入复制的表格
  1609. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1610. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1611. {
  1612. int rownewsIndex = 13;
  1613. for (int i = 0; i < 2; i++)
  1614. {
  1615. var CopyRow = table.Rows[12].Clone(true);
  1616. table.Rows.RemoveAt(13);
  1617. table.Rows.Add(CopyRow);
  1618. rownewsIndex++;
  1619. }
  1620. }
  1621. else
  1622. {
  1623. table.Rows.RemoveAt(12);
  1624. }
  1625. cloneTable.Rows.RemoveAt(12);
  1626. }
  1627. if (_AirTicketReservations.Count != 0)
  1628. {
  1629. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1630. if (FlightsCode.Length != 0)
  1631. {
  1632. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1633. if (_AirCompany != null)
  1634. {
  1635. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1636. }
  1637. else
  1638. {
  1639. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1640. }
  1641. }
  1642. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1643. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1644. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1645. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1646. string name = "";
  1647. foreach (string clientName in nameArray)
  1648. {
  1649. if (!name.Contains(clientName))
  1650. {
  1651. name += clientName + ",";
  1652. }
  1653. }
  1654. if (!string.IsNullOrWhiteSpace(name))
  1655. {
  1656. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1657. }
  1658. else
  1659. {
  1660. table.Range.Bookmarks["ClientName"].Text = "--";
  1661. }
  1662. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1663. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1664. table.Range.Bookmarks["JointTicket"].Text = "--";
  1665. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1666. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1667. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1668. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1669. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1670. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1671. }
  1672. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1673. //保存合并后的文档
  1674. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1675. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1676. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1677. return Ok(JsonView(true, "成功!", rst));
  1678. }
  1679. else
  1680. {
  1681. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1682. DocumentBuilder builder = new DocumentBuilder(doc);
  1683. int tableIndex = 0;//表格索引
  1684. //得到文档中的第一个表格
  1685. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1686. List<string> texts = new List<string>();
  1687. foreach (var item in _AirTicketReservations)
  1688. {
  1689. string[] FlightsCode = item.FlightsCode.Split('/');
  1690. if (FlightsCode.Length != 0)
  1691. {
  1692. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1693. if (_AirCompany != null)
  1694. {
  1695. if (!transDic.ContainsKey(_AirCompany.CnName))
  1696. {
  1697. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1698. }
  1699. }
  1700. else
  1701. {
  1702. if (!transDic.ContainsKey("--"))
  1703. {
  1704. transDic.Add("--", "--");
  1705. }
  1706. }
  1707. }
  1708. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1709. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1710. string name = "";
  1711. foreach (string clientName in nameArray)
  1712. {
  1713. name += clientName + ",";
  1714. }
  1715. if (!texts.Contains(name))
  1716. {
  1717. texts.Add(name);
  1718. }
  1719. List<AirInfo> airs = new List<AirInfo>();
  1720. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1721. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1722. for (int i = 0; i < FlightsCode.Length; i++)
  1723. {
  1724. AirInfo air = new AirInfo();
  1725. string[] tempstr = DayArray[i]
  1726. .Replace("\r\n", string.Empty)
  1727. .Replace("\\r\\n", string.Empty)
  1728. .TrimStart().TrimEnd()
  1729. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1730. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1731. if (star_Three != null)
  1732. {
  1733. if (!transDic.ContainsKey(star_Three.AirPort))
  1734. {
  1735. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1736. }
  1737. }
  1738. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1739. if (End_Three != null)
  1740. {
  1741. if (!transDic.ContainsKey(End_Three.AirPort))
  1742. {
  1743. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1744. }
  1745. }
  1746. if (!texts.Contains(item.CTypeName))
  1747. {
  1748. texts.Add(item.CTypeName);
  1749. }
  1750. }
  1751. }
  1752. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1753. if (transData.Count > 0)
  1754. {
  1755. foreach (TranslateResult item in transData)
  1756. {
  1757. if (!transDic.ContainsKey(item.Query))
  1758. {
  1759. transDic.Add(item.Query, item.Translation);
  1760. }
  1761. }
  1762. }
  1763. foreach (var item in _AirTicketReservations)
  1764. {
  1765. #region 处理固定数据
  1766. string[] FlightsCode = item.FlightsCode.Split('/');
  1767. if (FlightsCode.Length != 0)
  1768. {
  1769. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1770. if (_AirCompany != null)
  1771. {
  1772. string str = "--";
  1773. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1774. if (!string.IsNullOrEmpty(translateResult))
  1775. {
  1776. str = translateResult;
  1777. str = _airTicketResRep.Processing(str);
  1778. }
  1779. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1780. }
  1781. else
  1782. {
  1783. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1784. }
  1785. }
  1786. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1787. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1788. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1789. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1790. string names = "";
  1791. foreach (string clientName in nameArray)
  1792. {
  1793. names += clientName + ",";
  1794. }
  1795. if (!string.IsNullOrWhiteSpace(names))
  1796. {
  1797. string str = "--";
  1798. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1799. if (!string.IsNullOrEmpty(translateResult))
  1800. {
  1801. str = translateResult;
  1802. str = _airTicketResRep.Processing(str);
  1803. }
  1804. table.Range.Bookmarks["ClientName"].Text = str;
  1805. }
  1806. else
  1807. {
  1808. table.Range.Bookmarks["ClientName"].Text = "--";
  1809. }
  1810. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1811. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1812. table.Range.Bookmarks["JointTicket"].Text = "--";
  1813. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1814. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1815. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1816. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1817. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1818. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1819. #endregion
  1820. #region 循环数据处理
  1821. List<AirInfo> airs = new List<AirInfo>();
  1822. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1823. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1824. for (int i = 0; i < FlightsCode.Length; i++)
  1825. {
  1826. AirInfo air = new AirInfo();
  1827. string[] tempstr = DayArray[i]
  1828. .Replace("\r\n", string.Empty)
  1829. .Replace("\\r\\n", string.Empty)
  1830. .TrimStart().TrimEnd()
  1831. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1832. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1833. string starCity = "";
  1834. if (star_Three != null)
  1835. {
  1836. string str2 = "--";
  1837. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1838. if (!string.IsNullOrEmpty(translateResult2))
  1839. {
  1840. str2 = translateResult2;
  1841. str2 = _airTicketResRep.Processing(str2);
  1842. }
  1843. starCity = str2;
  1844. }
  1845. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1846. string EndCity = "";
  1847. if (End_Three != null)
  1848. {
  1849. string str1 = "--";
  1850. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1851. if (!string.IsNullOrEmpty(translateResult1))
  1852. {
  1853. str1 = translateResult1;
  1854. str1 = _airTicketResRep.Processing(str1);
  1855. }
  1856. EndCity = str1;
  1857. }
  1858. air.Destination = starCity + "/" + EndCity;
  1859. air.Flight = FlightsCode[i];
  1860. string str = "--";
  1861. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1862. if (!string.IsNullOrEmpty(translateResult))
  1863. {
  1864. str = translateResult;
  1865. str = _airTicketResRep.Processing(str);
  1866. }
  1867. air.SeatingClass = str;
  1868. string dateTime = tempstr[2];
  1869. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1870. air.FlightDate = DateTemp;
  1871. air.DepartureTime = tempstr[5];
  1872. air.LandingTime = tempstr[6];
  1873. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1874. air.TicketStatus = "--";
  1875. air.Luggage = "--";
  1876. air.DepartureTerminal = "--";
  1877. air.LandingTerminal = "--";
  1878. airs.Add(air);
  1879. }
  1880. int row = 13;
  1881. for (int i = 0; i < airs.Count; i++)
  1882. {
  1883. if (airs.Count > 2)
  1884. {
  1885. for (int j = 0; j < airs.Count - 2; j++)
  1886. {
  1887. var CopyRow = table.Rows[12].Clone(true);
  1888. table.Rows.Add(CopyRow);
  1889. }
  1890. }
  1891. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1892. int index = 0;
  1893. foreach (PropertyInfo property in properties)
  1894. {
  1895. string value = property.GetValue(airs[i]).ToString();
  1896. Cell ishcel0 = table.Rows[row].Cells[index];
  1897. Paragraph p = new Paragraph(doc);
  1898. string s = value;
  1899. p.AppendChild(new Run(doc, s));
  1900. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1901. ishcel0.AppendChild(p);
  1902. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1903. //ishcel0.CellFormat.VerticalAlignment=
  1904. index++;
  1905. }
  1906. row++;
  1907. }
  1908. #endregion
  1909. Paragraph lastParagraph = new Paragraph(doc);
  1910. //第一个表格末尾加段落
  1911. table.ParentNode.InsertAfter(lastParagraph, table);
  1912. //复制第一个表格
  1913. Table cloneTable = (Table)table.Clone(true);
  1914. //在文档末尾段落后面加入复制的表格
  1915. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1916. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1917. {
  1918. int rownewsIndex = 13;
  1919. for (int i = 0; i < 2; i++)
  1920. {
  1921. var CopyRow = table.Rows[12].Clone(true);
  1922. table.Rows.RemoveAt(13);
  1923. table.Rows.Add(CopyRow);
  1924. rownewsIndex++;
  1925. }
  1926. }
  1927. else
  1928. {
  1929. table.Rows.RemoveAt(12);
  1930. }
  1931. cloneTable.Rows.RemoveAt(12);
  1932. }
  1933. if (_AirTicketReservations.Count != 0)
  1934. {
  1935. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1936. if (FlightsCode.Length != 0)
  1937. {
  1938. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1939. if (_AirCompany != null)
  1940. {
  1941. string str = "--";
  1942. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1943. if (!string.IsNullOrEmpty(translateResult))
  1944. {
  1945. str = translateResult;
  1946. str = _airTicketResRep.Processing(str);
  1947. }
  1948. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1949. }
  1950. else
  1951. {
  1952. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1953. }
  1954. }
  1955. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1956. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1957. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1958. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1959. string names = "";
  1960. foreach (string clientName in nameArray)
  1961. {
  1962. names += clientName + ",";
  1963. }
  1964. if (!string.IsNullOrWhiteSpace(names))
  1965. {
  1966. string str = "--";
  1967. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1968. if (!string.IsNullOrEmpty(translateResult))
  1969. {
  1970. str = translateResult;
  1971. str = _airTicketResRep.Processing(str);
  1972. }
  1973. table.Range.Bookmarks["ClientName"].Text = str;
  1974. }
  1975. else
  1976. {
  1977. table.Range.Bookmarks["ClientName"].Text = "--";
  1978. }
  1979. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1980. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1981. table.Range.Bookmarks["JointTicket"].Text = "--";
  1982. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1983. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1984. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1985. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1986. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1987. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1988. }
  1989. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1990. //保存合并后的文档
  1991. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1992. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1993. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1994. return Ok(JsonView(true, "成功!", rst));
  1995. }
  1996. }
  1997. }
  1998. catch (Exception ex)
  1999. {
  2000. return Ok(JsonView(false, "程序错误!"));
  2001. throw;
  2002. }
  2003. }
  2004. #endregion
  2005. #region 团组增减款项
  2006. /// <summary>
  2007. /// 团组增减款项下拉框绑定
  2008. /// </summary>
  2009. /// <param name="dto"></param>
  2010. /// <returns></returns>
  2011. [HttpPost]
  2012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2013. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2014. {
  2015. try
  2016. {
  2017. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  2018. if (groupData.Code != 0)
  2019. {
  2020. return Ok(JsonView(false, groupData.Msg));
  2021. }
  2022. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2023. }
  2024. catch (Exception ex)
  2025. {
  2026. return Ok(JsonView(false, "程序错误!"));
  2027. throw;
  2028. }
  2029. }
  2030. /// <summary>
  2031. /// 根据团组Id查询团组增减款项
  2032. /// </summary>
  2033. /// <param name="dto"></param>
  2034. /// <returns></returns>
  2035. [HttpPost]
  2036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2037. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2038. {
  2039. try
  2040. {
  2041. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  2042. if (groupData.Code != 0)
  2043. {
  2044. return Ok(JsonView(false, groupData.Msg));
  2045. }
  2046. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2047. }
  2048. catch (Exception ex)
  2049. {
  2050. return Ok(JsonView(false, "程序错误!"));
  2051. throw;
  2052. }
  2053. }
  2054. /// <summary>
  2055. /// 团组增减款项操作(Status:1.新增,2.修改)
  2056. /// </summary>
  2057. /// <param name="dto"></param>
  2058. /// <returns></returns>
  2059. [HttpPost]
  2060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2061. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2062. {
  2063. try
  2064. {
  2065. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2066. if (groupData.Code != 0)
  2067. {
  2068. return Ok(JsonView(false, groupData.Msg));
  2069. }
  2070. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2071. }
  2072. catch (Exception ex)
  2073. {
  2074. return Ok(JsonView(false, "程序错误!"));
  2075. throw;
  2076. }
  2077. }
  2078. /// <summary>
  2079. /// 团组增减款项操作 删除
  2080. /// </summary>
  2081. /// <param name="dto"></param>
  2082. /// <returns></returns>
  2083. [HttpPost]
  2084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2085. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2086. {
  2087. try
  2088. {
  2089. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  2090. if (!res)
  2091. {
  2092. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
  2093. {
  2094. IsDel = 1,
  2095. DeleteUserId = dto.DeleteUserId,
  2096. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2097. }).ExecuteCommandAsync();
  2098. return Ok(JsonView(false, "删除失败"));
  2099. }
  2100. return Ok(JsonView(true, "删除成功!"));
  2101. }
  2102. catch (Exception ex)
  2103. {
  2104. return Ok(JsonView(false, "程序错误!"));
  2105. throw;
  2106. }
  2107. }
  2108. /// <summary>
  2109. /// 根据团组增减款项Id查询
  2110. /// </summary>
  2111. /// <param name="dto"></param>
  2112. /// <returns></returns>
  2113. [HttpPost]
  2114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2115. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2116. {
  2117. try
  2118. {
  2119. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  2120. if (groupData.Code != 0)
  2121. {
  2122. return Ok(JsonView(false, groupData.Msg));
  2123. }
  2124. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2125. }
  2126. catch (Exception ex)
  2127. {
  2128. return Ok(JsonView(false, "程序错误!"));
  2129. throw;
  2130. }
  2131. }
  2132. #endregion
  2133. #region 文件上传、删除
  2134. /// <summary>
  2135. /// region 文件上传 可以带参数
  2136. /// </summary>
  2137. /// <param name="file"></param>
  2138. /// <returns></returns>
  2139. [HttpPost]
  2140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2141. public async Task<IActionResult> UploadProject(IFormFile file)
  2142. {
  2143. try
  2144. {
  2145. var TypeName = Request.Headers["TypeName"].ToString();
  2146. if (file != null)
  2147. {
  2148. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2149. //文件名称
  2150. string projectFileName = file.FileName;
  2151. //上传的文件的路径
  2152. string filePath = "";
  2153. if (TypeName == "A")//A代表团组增减款项
  2154. {
  2155. if (!Directory.Exists(fileDir))
  2156. {
  2157. Directory.CreateDirectory(fileDir);
  2158. }
  2159. //上传的文件的路径
  2160. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2161. }
  2162. else if (TypeName == "B")//B代表商邀相关文件
  2163. {
  2164. if (!Directory.Exists(fileDir))
  2165. {
  2166. Directory.CreateDirectory(fileDir);
  2167. }
  2168. //上传的文件的路径
  2169. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2170. }
  2171. using (FileStream fs = System.IO.File.Create(filePath))
  2172. {
  2173. file.CopyTo(fs);
  2174. fs.Flush();
  2175. }
  2176. return Ok(JsonView(true, "上传成功!", projectFileName));
  2177. }
  2178. else
  2179. {
  2180. return Ok(JsonView(false, "上传失败!"));
  2181. }
  2182. }
  2183. catch (Exception ex)
  2184. {
  2185. return Ok(JsonView(false, "程序错误!"));
  2186. throw;
  2187. }
  2188. }
  2189. /// <summary>
  2190. /// 删除指定文件
  2191. /// </summary>
  2192. /// <param name="dto"></param>
  2193. /// <returns></returns>
  2194. [HttpPost]
  2195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2196. public async Task<IActionResult> DelFile(DelFileDto dto)
  2197. {
  2198. try
  2199. {
  2200. var TypeName = Request.Headers["TypeName"].ToString();
  2201. string filePath = "";
  2202. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2203. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2204. int id = 0;
  2205. if (TypeName == "A")
  2206. {
  2207. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2208. // 删除该文件
  2209. System.IO.File.Delete(filePath);
  2210. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2211. }
  2212. else if (TypeName == "B")
  2213. {
  2214. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2215. // 删除该文件
  2216. System.IO.File.Delete(filePath);
  2217. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2218. }
  2219. if (id != 0)
  2220. {
  2221. return Ok(JsonView(true, "成功!"));
  2222. }
  2223. else
  2224. {
  2225. return Ok(JsonView(false, "失败!"));
  2226. }
  2227. }
  2228. catch (Exception ex)
  2229. {
  2230. return Ok(JsonView(false, "程序错误!"));
  2231. throw;
  2232. }
  2233. }
  2234. #endregion
  2235. #region 商邀费用录入
  2236. /// <summary>
  2237. /// 根据团组Id查询商邀费用列表
  2238. /// </summary>
  2239. /// <param name="dto"></param>
  2240. /// <returns></returns>
  2241. [HttpPost]
  2242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2243. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2244. {
  2245. try
  2246. {
  2247. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2248. if (groupData.Code != 0)
  2249. {
  2250. return Ok(JsonView(false, groupData.Msg));
  2251. }
  2252. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2253. }
  2254. catch (Exception ex)
  2255. {
  2256. return Ok(JsonView(false, "程序错误!"));
  2257. throw;
  2258. }
  2259. }
  2260. /// <summary>
  2261. /// 根据商邀费用ID查询C表和商邀费用数据
  2262. /// </summary>
  2263. /// <param name="dto"></param>
  2264. /// <returns></returns>
  2265. [HttpPost]
  2266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2267. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2268. {
  2269. try
  2270. {
  2271. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2272. if (groupData.Code != 0)
  2273. {
  2274. return Ok(JsonView(false, groupData.Msg));
  2275. }
  2276. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2277. }
  2278. catch (Exception ex)
  2279. {
  2280. return Ok(JsonView(false, "程序错误!"));
  2281. throw;
  2282. }
  2283. }
  2284. /// <summary>
  2285. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2286. /// </summary>
  2287. /// <param name="dto"></param>
  2288. /// <returns></returns>
  2289. [HttpPost]
  2290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2291. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2292. {
  2293. try
  2294. {
  2295. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
  2296. if (groupData.Code != 0)
  2297. {
  2298. return Ok(JsonView(false, groupData.Msg));
  2299. }
  2300. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2301. }
  2302. catch (Exception ex)
  2303. {
  2304. return Ok(JsonView(false, "程序错误!"));
  2305. throw;
  2306. }
  2307. }
  2308. /// <summary>
  2309. /// 商邀删除
  2310. /// </summary>
  2311. /// <param name="dto"></param>
  2312. /// <returns></returns>
  2313. [HttpPost]
  2314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2315. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2316. {
  2317. try
  2318. {
  2319. var res = await _InvitationOfficialActivitiesRep.SoftDeleteByIdAsync<Grp_InvitationOfficialActivities>(dto.Id.ToString(), dto.DeleteUserId);
  2320. if (!res)
  2321. {
  2322. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 81).SetColumns(a => new Grp_CreditCardPayment()
  2323. {
  2324. IsDel = 1,
  2325. DeleteUserId = dto.DeleteUserId,
  2326. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2327. }).ExecuteCommandAsync();
  2328. return Ok(JsonView(false, "删除失败"));
  2329. }
  2330. return Ok(JsonView(true, "删除成功!"));
  2331. }
  2332. catch (Exception ex)
  2333. {
  2334. return Ok(JsonView(false, "程序错误!"));
  2335. throw;
  2336. }
  2337. }
  2338. #endregion
  2339. #region 团组英文资料
  2340. /// <summary>
  2341. /// 查询团组英文所有资料
  2342. /// </summary>
  2343. /// <param name="dto"></param>
  2344. /// <returns></returns>
  2345. [HttpPost]
  2346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2347. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  2348. {
  2349. try
  2350. {
  2351. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  2352. if (groupData.Code != 0)
  2353. {
  2354. return Ok(JsonView(false, groupData.Msg));
  2355. }
  2356. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2357. }
  2358. catch (Exception ex)
  2359. {
  2360. return Ok(JsonView(false, "程序错误!"));
  2361. throw;
  2362. }
  2363. }
  2364. /// <summary>
  2365. /// 团组英文资料操作(Status:1.新增,2.修改)
  2366. /// </summary>
  2367. /// <param name="dto"></param>
  2368. /// <returns></returns>
  2369. [HttpPost]
  2370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2371. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  2372. {
  2373. try
  2374. {
  2375. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  2376. if (groupData.Code != 0)
  2377. {
  2378. return Ok(JsonView(false, groupData.Msg));
  2379. }
  2380. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2381. }
  2382. catch (Exception ex)
  2383. {
  2384. return Ok(JsonView(false, "程序错误!"));
  2385. throw;
  2386. }
  2387. }
  2388. /// <summary>
  2389. /// 团组英文资料Id查询数据
  2390. /// </summary>
  2391. /// <param name="dto"></param>
  2392. /// <returns></returns>
  2393. [HttpPost]
  2394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2395. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  2396. {
  2397. try
  2398. {
  2399. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  2400. if (_DelegationEnData != null)
  2401. {
  2402. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  2403. }
  2404. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  2405. }
  2406. catch (Exception ex)
  2407. {
  2408. return Ok(JsonView(false, "程序错误!"));
  2409. throw;
  2410. }
  2411. }
  2412. /// <summary>
  2413. /// 团组英文资料删除
  2414. /// </summary>
  2415. /// <param name="dto"></param>
  2416. /// <returns></returns>
  2417. [HttpPost]
  2418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2419. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  2420. {
  2421. try
  2422. {
  2423. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  2424. if (!res)
  2425. {
  2426. return Ok(JsonView(false, "删除失败"));
  2427. }
  2428. return Ok(JsonView(true, "删除成功!"));
  2429. }
  2430. catch (Exception ex)
  2431. {
  2432. return Ok(JsonView(false, "程序错误!"));
  2433. throw;
  2434. }
  2435. }
  2436. #endregion
  2437. #region 导出邀请函
  2438. /// <summary>
  2439. /// 导出邀请函页面初始化
  2440. /// </summary>
  2441. /// <param name="dto"></param>
  2442. /// <returns></returns>
  2443. [HttpPost]
  2444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2445. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  2446. {
  2447. try
  2448. {
  2449. List<Grp_DelegationInfo> grp_Delegations = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToListAsync();
  2450. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  2451. if (dto.DiId == 0)
  2452. {
  2453. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  2454. }
  2455. else
  2456. {
  2457. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2458. }
  2459. return Ok(JsonView(true, "查询成功!", new
  2460. {
  2461. deleClient = crm_Deles,
  2462. delegations = grp_Delegations
  2463. }));
  2464. }
  2465. catch (Exception ex)
  2466. {
  2467. return Ok(JsonView(false, "程序错误!"));
  2468. throw;
  2469. }
  2470. }
  2471. /// <summary>
  2472. /// 导出邀请函
  2473. /// </summary>
  2474. /// <param name="dto"></param>
  2475. /// <returns></returns>
  2476. [HttpPost]
  2477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2478. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  2479. {
  2480. try
  2481. {
  2482. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2483. List<Crm_DeleClient> crm_DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  2484. List<string> texts = new List<string>();
  2485. if (crm_DeleClients.Count != 0)
  2486. {
  2487. foreach (Crm_DeleClient item in crm_DeleClients)
  2488. {
  2489. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  2490. {
  2491. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  2492. }
  2493. else
  2494. {
  2495. string name = item.LastName + item.FirstName;
  2496. texts.Add(name);
  2497. }
  2498. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  2499. {
  2500. if (!transDic.ContainsKey(item.Job))
  2501. {
  2502. texts.Add(item.Job);
  2503. }
  2504. }
  2505. if (item.CrmCompanyId != 0)
  2506. {
  2507. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == item.CrmCompanyId && a.IsDel == 0);
  2508. if (!transDic.ContainsKey(crm_Customer.CompanyFullName))
  2509. {
  2510. texts.Add(crm_Customer.CompanyFullName);
  2511. }
  2512. }
  2513. }
  2514. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2515. if (transData.Count > 0)
  2516. {
  2517. foreach (TranslateResult item in transData)
  2518. {
  2519. if (!transDic.ContainsKey(item.Query))
  2520. {
  2521. transDic.Add(item.Query, item.Translation);
  2522. }
  2523. }
  2524. }
  2525. List<guestList> list = new List<guestList>();
  2526. foreach (Crm_DeleClient dele in crm_DeleClients)
  2527. {
  2528. guestList guestList = new guestList();
  2529. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  2530. {
  2531. guestList.Name = dele.Pinyin;
  2532. }
  2533. else
  2534. {
  2535. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  2536. guestList.Name = Name;
  2537. }
  2538. if (dele.Sex == 0)
  2539. {
  2540. guestList.Sex = "Male";
  2541. }
  2542. else if (dele.Sex == 1)
  2543. {
  2544. guestList.Sex = "Female";
  2545. }
  2546. guestList.DOB = dele.BirthDay.Replace('-', '.');
  2547. Crm_CustomerCompany crm_Customer = await _sqlSugar.Queryable<Crm_CustomerCompany>().FirstAsync(a => a.Id == dele.CrmCompanyId && a.IsDel == 0);
  2548. string jobName = transDic.Where(s => s.Key == crm_Customer.CompanyFullName).FirstOrDefault().Value + " " + transDic.Where(s => s.Key == dele.Job).FirstOrDefault().Value;
  2549. guestList.Job = jobName;
  2550. list.Add(guestList);
  2551. }
  2552. //载入模板
  2553. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  2554. DocumentBuilder builder = new DocumentBuilder(doc);
  2555. //获取word里所有表格
  2556. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  2557. //获取所填表格的序数
  2558. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  2559. var rowStart = tableOne.Rows[0]; //获取第1行
  2560. //循环赋值
  2561. for (int i = 0; i < list.Count; i++)
  2562. {
  2563. builder.MoveToCell(0, i + 1, 0, 0);
  2564. builder.Write(list[i].Name.ToString());
  2565. builder.MoveToCell(0, i + 1, 1, 0);
  2566. builder.Write(list[i].Sex.ToString());
  2567. builder.MoveToCell(0, i + 1, 2, 0);
  2568. builder.Write(list[i].DOB.ToString());
  2569. builder.MoveToCell(0, i + 1, 3, 0);
  2570. builder.Write(list[i].Job.ToString());
  2571. }
  2572. //删除多余行
  2573. while (tableOne.Rows.Count > list.Count + 1)
  2574. {
  2575. tableOne.Rows.RemoveAt(list.Count + 1);
  2576. }
  2577. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2578. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  2579. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  2580. doc.Save(filePath);
  2581. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件" + fileName;
  2582. return Ok(JsonView(true, "成功!", Url));
  2583. }
  2584. else
  2585. {
  2586. return Ok(JsonView(false, "失败,该团组没有客户名单!"));
  2587. }
  2588. }
  2589. catch (Exception ex)
  2590. {
  2591. return Ok(JsonView(false, "程序错误!"));
  2592. throw;
  2593. }
  2594. }
  2595. #endregion
  2596. #region 团组经理模块 出入境费用
  2597. ///// <summary>
  2598. ///// 团组模块 - 出入境费用
  2599. ///// </summary>
  2600. ///// <returns></returns>
  2601. //[HttpPost]
  2602. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2603. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  2604. //{
  2605. // try
  2606. // {
  2607. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  2608. // if (data.Code != 0)
  2609. // {
  2610. // return Ok(JsonView(false, data.Msg));
  2611. // }
  2612. // return Ok(JsonView(true, "查询成功!"));
  2613. // }
  2614. // catch (Exception ex)
  2615. // {
  2616. // return Ok(JsonView(false, ex.Message));
  2617. // throw;
  2618. // }
  2619. //}
  2620. /// <summary>
  2621. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  2622. /// </summary>
  2623. /// <returns></returns>
  2624. [HttpPost]
  2625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2626. public async Task<IActionResult> SetDayAndCostAreaChange()
  2627. {
  2628. try
  2629. {
  2630. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  2631. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  2632. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  2633. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  2634. foreach (var item in unite) //处理交集数据
  2635. {
  2636. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  2637. }
  2638. foreach (var item in merge) //处理差集数据
  2639. {
  2640. int nationalTravelFeeId = 0;
  2641. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  2642. if (cityData != null) nationalTravelFeeId = cityData.Id;
  2643. else
  2644. {
  2645. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  2646. if (countryData != null) nationalTravelFeeId = countryData.Id;
  2647. }
  2648. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  2649. }
  2650. //只更新dayAndCost 的 nationalTravelFeeId;
  2651. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  2652. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  2653. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  2654. }
  2655. catch (Exception ex)
  2656. {
  2657. return Ok(JsonView(false, ex.Message));
  2658. throw;
  2659. }
  2660. }
  2661. /// <summary>
  2662. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  2663. /// </summary>
  2664. /// <returns></returns>
  2665. [HttpPost]
  2666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2667. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  2668. {
  2669. try
  2670. {
  2671. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  2672. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  2673. //SetDataInfoView
  2674. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  2675. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  2676. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  2677. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  2678. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  2679. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  2680. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  2681. return Ok(JsonView(true, "查询成功!", new
  2682. {
  2683. GroupNameData = groupNameData.Data,
  2684. CurrencyData = _CurrencyData,
  2685. WordTypeData = _WordTypeData,
  2686. ExcelTypeData = _ExcelTypeData
  2687. //NationalTravelFeeData = nationalTravelFeeData
  2688. }));
  2689. }
  2690. catch (Exception ex)
  2691. {
  2692. return Ok(JsonView(false, ex.Message));
  2693. throw;
  2694. }
  2695. }
  2696. /// <summary>
  2697. /// 团组模块 - 出入境费用 - Info
  2698. /// </summary>
  2699. /// <returns></returns>
  2700. [HttpPost]
  2701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2702. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  2703. {
  2704. try
  2705. {
  2706. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  2707. if (data.Code != 0)
  2708. {
  2709. return Ok(JsonView(false, data.Msg));
  2710. }
  2711. return Ok(JsonView(true, "查询成功!", data.Data));
  2712. }
  2713. catch (Exception ex)
  2714. {
  2715. return Ok(JsonView(false, ex.Message));
  2716. }
  2717. }
  2718. /// <summary>
  2719. /// 团组模块 - 出入境费用 - Add And Update
  2720. /// </summary>
  2721. /// <returns></returns>
  2722. [HttpPost]
  2723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2724. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  2725. {
  2726. try
  2727. {
  2728. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2729. if (data.Code != 0)
  2730. {
  2731. return Ok(JsonView(false, data.Msg));
  2732. }
  2733. return Ok(JsonView(true, data.Msg, data.Data));
  2734. }
  2735. catch (Exception ex)
  2736. {
  2737. return Ok(JsonView(false, ex.Message));
  2738. }
  2739. }
  2740. /// <summary>
  2741. /// 团组模块 - 出入境费用 - 明细表导出
  2742. /// </summary>
  2743. /// <returns></returns>
  2744. [HttpPost]
  2745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2746. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  2747. {
  2748. try
  2749. {
  2750. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  2751. if (data.Code != 0)
  2752. {
  2753. return Ok(JsonView(false, data.Msg));
  2754. }
  2755. return Ok(JsonView(true, data.Msg, data.Data));
  2756. }
  2757. catch (Exception ex)
  2758. {
  2759. return Ok(JsonView(false, ex.Message));
  2760. }
  2761. }
  2762. /// <summary>
  2763. /// 团组模块 - 出入境费用 - 子项删除
  2764. /// </summary>
  2765. /// <returns></returns>
  2766. [HttpPost]
  2767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2768. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  2769. {
  2770. try
  2771. {
  2772. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  2773. if (data.Code != 0)
  2774. {
  2775. return Ok(JsonView(false, data.Msg));
  2776. }
  2777. return Ok(JsonView(true, "操作成功!", data.Data));
  2778. }
  2779. catch (Exception ex)
  2780. {
  2781. return Ok(JsonView(false, ex.Message));
  2782. }
  2783. }
  2784. /// <summary>
  2785. /// 团组模块 - 出入境国家费用标准 List
  2786. /// </summary>
  2787. /// <returns></returns>
  2788. [HttpPost]
  2789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2790. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  2791. {
  2792. try
  2793. {
  2794. Stopwatch sw = new Stopwatch();
  2795. sw.Start();
  2796. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  2797. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2798. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2799. Where gntf.Isdel = 0");
  2800. var nationalTravelFeeData = await _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToListAsync();
  2801. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  2802. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  2803. //foreach (var item in nationalTravel)
  2804. //{
  2805. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  2806. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  2807. // if (otherData != null)
  2808. // {
  2809. // cityData.Remove(otherData);
  2810. // cityData.Add(otherData);
  2811. // }
  2812. // nationalTravelFeeData1.Add(new
  2813. // {
  2814. // Country = item.Country,
  2815. // CityData = cityData
  2816. // });
  2817. //}
  2818. sw.Stop();
  2819. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  2820. }
  2821. catch (Exception ex)
  2822. {
  2823. return Ok(JsonView(false, ex.Message));
  2824. throw;
  2825. }
  2826. }
  2827. /// <summary>
  2828. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  2829. /// </summary>
  2830. /// <returns></returns>
  2831. [HttpPost]
  2832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2833. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  2834. {
  2835. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  2836. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  2837. List<string> countryData = new List<string>();
  2838. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  2839. countryData = countryData.Distinct().ToList();
  2840. List<dynamic> dataSource = new List<dynamic>();
  2841. foreach (var item in countryData)
  2842. {
  2843. List<string> cityData1 = new List<string>();
  2844. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  2845. var countryData2 = new
  2846. {
  2847. CountryName = item,
  2848. CityData = cityData1
  2849. };
  2850. dataSource.Add(countryData2);
  2851. }
  2852. return Ok(JsonView(true, "查询成功!", dataSource));
  2853. }
  2854. /// <summary>
  2855. /// 团组模块 - 出入境国家费用标准 Page List
  2856. /// </summary>
  2857. /// <returns></returns>
  2858. [HttpPost]
  2859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2860. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  2861. {
  2862. int portId = dto.PortType;
  2863. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2864. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  2865. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  2866. string whereSql = string.Empty;
  2867. if (!string.IsNullOrEmpty(dto.Country))
  2868. {
  2869. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  2870. }
  2871. if (!string.IsNullOrEmpty(dto.City))
  2872. {
  2873. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  2874. }
  2875. string pageSql = string.Format(@"Select * From (
  2876. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  2877. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  2878. From Grp_NationalTravelFee gntf
  2879. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2880. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2881. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  2882. RefAsync<int> total = 0;
  2883. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  2884. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  2885. }
  2886. /// <summary>
  2887. /// 团组模块 - 出入境国家费用标准 根据城市查询
  2888. /// </summary>
  2889. /// <returns></returns>
  2890. [HttpPost]
  2891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2892. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  2893. {
  2894. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  2895. int portId = dto.PortType;
  2896. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  2897. string whereSql = string.Empty;
  2898. if (!string.IsNullOrEmpty(dto.Country))
  2899. {
  2900. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  2901. }
  2902. if (!string.IsNullOrEmpty(dto.City))
  2903. {
  2904. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  2905. }
  2906. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  2907. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  2908. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  2909. From Grp_NationalTravelFee gntf
  2910. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  2911. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  2912. Where gntf.Isdel = 0 {0} ", whereSql);
  2913. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  2914. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  2915. }
  2916. /// <summary>
  2917. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  2918. /// </summary>
  2919. /// <returns></returns>
  2920. [HttpPost]
  2921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2922. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  2923. {
  2924. try
  2925. {
  2926. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  2927. if (data.Code != 0)
  2928. {
  2929. return Ok(JsonView(false, data.Msg));
  2930. }
  2931. return Ok(JsonView(true, "操作成功!", data.Data));
  2932. }
  2933. catch (Exception ex)
  2934. {
  2935. return Ok(JsonView(false, ex.Message));
  2936. }
  2937. }
  2938. /// <summary>
  2939. /// 团组模块 - 出入境国家费用标准 - Del
  2940. /// </summary>
  2941. /// <returns></returns>
  2942. [HttpPost]
  2943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2944. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  2945. {
  2946. try
  2947. {
  2948. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  2949. {
  2950. Id = dto.Id,
  2951. DeleteUserId = dto.DeleteUserId,
  2952. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  2953. IsDel = 1
  2954. };
  2955. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  2956. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  2957. .WhereColumns(it => new { it.Id })
  2958. .ExecuteCommandAsync();
  2959. if (delStatus <= 0)
  2960. {
  2961. return Ok(JsonView(false, "删除失败!"));
  2962. }
  2963. return Ok(JsonView(true, "操作成功!"));
  2964. }
  2965. catch (Exception ex)
  2966. {
  2967. return Ok(JsonView(false, ex.Message));
  2968. }
  2969. }
  2970. #endregion
  2971. #region 签证费用录入
  2972. /// <summary>
  2973. /// 根据diid查询签证费用列表
  2974. /// </summary>
  2975. /// <param name="dto"></param>
  2976. /// <returns></returns>
  2977. [HttpPost]
  2978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2979. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  2980. {
  2981. try
  2982. {
  2983. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  2984. if (groupData.Code != 0)
  2985. {
  2986. return Ok(JsonView(false, groupData.Msg));
  2987. }
  2988. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2989. }
  2990. catch (Exception ex)
  2991. {
  2992. return Ok(JsonView(false, ex.Message));
  2993. }
  2994. }
  2995. /// <summary>
  2996. /// 根据签证费用Id查询单条数据及c表数据
  2997. /// </summary>
  2998. /// <param name="dto"></param>
  2999. /// <returns></returns>
  3000. [HttpPost]
  3001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3002. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  3003. {
  3004. try
  3005. {
  3006. Result groupData = await _visaPriceRep.PostVisaById(dto);
  3007. if (groupData.Code != 0)
  3008. {
  3009. return Ok(JsonView(false, groupData.Msg));
  3010. }
  3011. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3012. }
  3013. catch (Exception ex)
  3014. {
  3015. return Ok(JsonView(false, ex.Message));
  3016. }
  3017. }
  3018. /// <summary>
  3019. /// 签证费用删除
  3020. /// </summary>
  3021. /// <param name="dto"></param>
  3022. /// <returns></returns>
  3023. [HttpPost]
  3024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3025. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  3026. {
  3027. try
  3028. {
  3029. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  3030. if (!res)
  3031. {
  3032. return Ok(JsonView(false, "删除失败"));
  3033. }
  3034. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
  3035. {
  3036. IsDel = 1,
  3037. DeleteUserId = dto.DeleteUserId,
  3038. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3039. }).ExecuteCommandAsync();
  3040. return Ok(JsonView(true, "删除成功!"));
  3041. }
  3042. catch (Exception ex)
  3043. {
  3044. return Ok(JsonView(false, "程序错误!"));
  3045. throw;
  3046. }
  3047. }
  3048. /// <summary>
  3049. /// 签证费用录入下拉框初始化
  3050. /// </summary>
  3051. /// <returns></returns>
  3052. [HttpPost]
  3053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3054. public async Task<IActionResult> VisaPriceAddSelect()
  3055. {
  3056. try
  3057. {
  3058. //支付方式
  3059. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  3060. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  3061. //币种
  3062. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  3063. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  3064. //乘客类型
  3065. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  3066. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  3067. //卡类型
  3068. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  3069. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  3070. var data = new
  3071. {
  3072. Payment = _Payment,
  3073. CurrencyList = _CurrencyList,
  3074. PassengerType = _PassengerType,
  3075. BankCard = _BankCard
  3076. };
  3077. return Ok(JsonView(true, "查询成功!", data));
  3078. }
  3079. catch (Exception ex)
  3080. {
  3081. return Ok(JsonView(false, "程序错误!"));
  3082. throw;
  3083. }
  3084. }
  3085. /// <summary>
  3086. /// 签证费用录入操作(Status:1.新增,2.修改)
  3087. /// </summary>
  3088. /// <param name="dto"></param>
  3089. /// <returns></returns>
  3090. [HttpPost]
  3091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3092. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  3093. {
  3094. try
  3095. {
  3096. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  3097. if (groupData.Code != 0)
  3098. {
  3099. return Ok(JsonView(false, groupData.Msg));
  3100. }
  3101. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3102. }
  3103. catch (Exception ex)
  3104. {
  3105. return Ok(JsonView(false, ex.Message));
  3106. }
  3107. }
  3108. #endregion
  3109. #region op费用录入
  3110. /// <summary>
  3111. /// 根据diid查询op费用列表
  3112. /// </summary>
  3113. /// <param name="dto"></param>
  3114. /// <returns></returns>
  3115. [HttpPost]
  3116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3117. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  3118. {
  3119. try
  3120. {
  3121. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  3122. if (groupData.Code != 0)
  3123. {
  3124. return Ok(JsonView(false, groupData.Msg));
  3125. }
  3126. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3127. }
  3128. catch (Exception ex)
  3129. {
  3130. return Ok(JsonView(false, ex.Message));
  3131. }
  3132. }
  3133. /// <summary>
  3134. /// 根据op费用Id查询单条数据及c表数据
  3135. /// </summary>
  3136. /// <param name="dto"></param>
  3137. /// <returns></returns>
  3138. [HttpPost]
  3139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3140. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  3141. {
  3142. try
  3143. {
  3144. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  3145. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  3146. var data = new
  3147. {
  3148. CarTouristGuideGround = _groupData,
  3149. CreditCardPayment = _creditCardPayment
  3150. };
  3151. return Ok(JsonView(true, "查询成功!", data));
  3152. }
  3153. catch (Exception ex)
  3154. {
  3155. return Ok(JsonView(false, "程序错误!"));
  3156. }
  3157. }
  3158. /// <summary>
  3159. /// op费用删除
  3160. /// </summary>
  3161. /// <param name="dto"></param>
  3162. /// <returns></returns>
  3163. [HttpPost]
  3164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3165. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  3166. {
  3167. try
  3168. {
  3169. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3170. if (!res)
  3171. {
  3172. return Ok(JsonView(false, "删除失败"));
  3173. }
  3174. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  3175. {
  3176. IsDel = 1,
  3177. DeleteUserId = dto.DeleteUserId,
  3178. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3179. }).ExecuteCommandAsync();
  3180. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  3181. {
  3182. IsDel = 1,
  3183. DeleteUserId = dto.DeleteUserId,
  3184. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3185. }).ExecuteCommandAsync();
  3186. return Ok(JsonView(true, "删除成功!"));
  3187. }
  3188. catch (Exception ex)
  3189. {
  3190. return Ok(JsonView(false, "程序错误!"));
  3191. throw;
  3192. }
  3193. }
  3194. /// <summary>
  3195. /// op费用录入操作(Status:1.新增,2.修改)
  3196. /// </summary>
  3197. /// <param name="dto"></param>
  3198. /// <returns></returns>
  3199. [HttpPost]
  3200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3201. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  3202. {
  3203. try
  3204. {
  3205. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  3206. if (groupData.Code != 0)
  3207. {
  3208. return Ok(JsonView(false, groupData.Msg));
  3209. }
  3210. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3211. }
  3212. catch (Exception ex)
  3213. {
  3214. return Ok(JsonView(false, ex.Message));
  3215. }
  3216. }
  3217. /// <summary>
  3218. /// 填写费用详细页面初始化绑定
  3219. /// </summary>
  3220. /// <param name="dto"></param>
  3221. /// <returns></returns>
  3222. [HttpPost]
  3223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3224. public async Task<IActionResult> CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  3225. {
  3226. try
  3227. {
  3228. Result groupData = await _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  3229. if (groupData.Code != 0)
  3230. {
  3231. return Ok(JsonView(false, groupData.Msg));
  3232. }
  3233. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3234. }
  3235. catch (Exception ex)
  3236. {
  3237. return Ok(JsonView(false, ex.Message));
  3238. }
  3239. }
  3240. /// <summary>
  3241. /// 根据op费用Id查询详细数据
  3242. /// </summary>
  3243. /// <param name="dto"></param>
  3244. /// <returns></returns>
  3245. [HttpPost]
  3246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3247. public async Task<IActionResult> OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  3248. {
  3249. try
  3250. {
  3251. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  3252. if (groupData.Code != 0)
  3253. {
  3254. return Ok(JsonView(false, groupData.Msg));
  3255. }
  3256. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3257. }
  3258. catch (Exception ex)
  3259. {
  3260. return Ok(JsonView(false, ex.Message));
  3261. }
  3262. }
  3263. /// <summary>
  3264. /// OP费用录入填写详情
  3265. /// </summary>
  3266. /// <param name="dto"></param>
  3267. /// <returns></returns>
  3268. [HttpPost]
  3269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3270. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  3271. {
  3272. try
  3273. {
  3274. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  3275. if (groupData.Code != 0)
  3276. {
  3277. return Ok(JsonView(false, groupData.Msg));
  3278. }
  3279. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3280. }
  3281. catch (Exception ex)
  3282. {
  3283. return Ok(JsonView(false, ex.Message));
  3284. }
  3285. }
  3286. #endregion
  3287. #region 团组成本
  3288. /// <summary>
  3289. /// 团组成本数据初始化
  3290. /// </summary>
  3291. /// <param name="dto"></param>
  3292. /// <returns></returns>
  3293. [HttpPost]
  3294. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  3295. {
  3296. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  3297. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  3298. WHEN COUNT(*) >= 0 THEN 'True'
  3299. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  3300. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  3301. ").ToList(); //团组列表
  3302. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  3303. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  3304. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  3305. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  3306. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  3307. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  3308. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  3309. //GroupCostParameter.Add(new
  3310. // Grp_GroupCostParameter());
  3311. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  3312. return Ok(JsonView(new
  3313. {
  3314. groupList,
  3315. groupInfo,
  3316. groupChecks,
  3317. groupCost = groupCostMap,
  3318. hotelNumber,
  3319. GroupCostParameter = GroupCostParameterMap,
  3320. }));
  3321. }
  3322. /// <summary>
  3323. /// 团组成本信息保存
  3324. /// </summary>
  3325. /// <param name="dto"></param>
  3326. /// <returns></returns>
  3327. [HttpPost]
  3328. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  3329. {
  3330. if (dto.Diid <= 0 || dto.Userid <= 0)
  3331. {
  3332. return Ok(JsonView(false));
  3333. }
  3334. JsonView jw = null;
  3335. bool isTrue = false;
  3336. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  3337. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  3338. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  3339. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  3340. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  3341. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  3342. try
  3343. {
  3344. _sqlSugar.BeginTran();
  3345. isTrue = await _GroupCostRepository.
  3346. SaveGroupCostList(Grp_groups, dto.Diid); //列表
  3347. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  3348. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  3349. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  3350. _sqlSugar.CommitTran();
  3351. jw = JsonView(true, "保存成功!", isTrue);
  3352. }
  3353. catch (Exception)
  3354. {
  3355. _sqlSugar.RollbackTran();
  3356. jw = JsonView(false);
  3357. }
  3358. return Ok(jw);
  3359. }
  3360. /// <summary>
  3361. /// 司兼导数据
  3362. /// </summary>
  3363. /// <param name="dto"></param>
  3364. /// <returns></returns>
  3365. [HttpPost]
  3366. public IActionResult GetCarGuides(CarGuidesDto dto)
  3367. {
  3368. JsonView jw = null;
  3369. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  3370. jw = JsonView(true, "获取成功!", Data);
  3371. return Ok(jw);
  3372. }
  3373. /// <summary>
  3374. /// 导游数据
  3375. /// </summary>
  3376. /// <param name="dto"></param>
  3377. /// <returns></returns>
  3378. [HttpPost]
  3379. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  3380. {
  3381. JsonView jw = null;
  3382. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  3383. // 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
  3384. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  3385. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  3386. jw = JsonView(true, "获取成功!", Data);
  3387. return Ok(jw);
  3388. }
  3389. /// <summary>
  3390. /// 成本车数据
  3391. /// </summary>
  3392. /// <param name="dto"></param>
  3393. /// <returns></returns>
  3394. [HttpPost]
  3395. public IActionResult GetCarInfo(CarGuidesDto dto)
  3396. {
  3397. JsonView jw = null;
  3398. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  3399. jw = JsonView(true, "获取成功!", Data);
  3400. return Ok(jw);
  3401. }
  3402. /// <summary>
  3403. /// 景点数据
  3404. /// </summary>
  3405. /// <param name="dto"></param>
  3406. /// <returns></returns>
  3407. [HttpPost]
  3408. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  3409. {
  3410. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  3411. return Ok(JsonView(true, "获取成功!", Data));
  3412. }
  3413. /// <summary>
  3414. /// 成本通知
  3415. /// </summary>
  3416. /// <param name="dto"></param>
  3417. /// <returns></returns>
  3418. [HttpPost]
  3419. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  3420. {
  3421. if (dto.Diid < 0)
  3422. {
  3423. return Ok(JsonView(false));
  3424. }
  3425. JsonView jw = null;
  3426. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  3427. if (GroupCostParameter != null)
  3428. {
  3429. int IsShare = 0;
  3430. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  3431. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  3432. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id,IsShare);
  3433. string msg = string.Empty;
  3434. if (isTrue)
  3435. {
  3436. if (IsShare == 0)
  3437. {
  3438. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  3439. }
  3440. else
  3441. {
  3442. msg = "通知成功,其他模块操作人员可见此成本信息!";
  3443. }
  3444. jw = JsonView(isTrue, msg);
  3445. }
  3446. else
  3447. {
  3448. msg = "修改失败!";
  3449. jw = JsonView(isTrue, msg);
  3450. }
  3451. }
  3452. else
  3453. {
  3454. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  3455. }
  3456. return Ok(jw);
  3457. }
  3458. #endregion
  3459. #region 酒店预定 保留
  3460. /// <summary>
  3461. /// 酒店预订页面初始化绑定
  3462. /// </summary>
  3463. /// <param name="dto"></param>
  3464. /// <returns></returns>
  3465. [HttpPost]
  3466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3467. public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
  3468. {
  3469. try
  3470. {
  3471. Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
  3472. if (groupData.Code != 0)
  3473. {
  3474. return Ok(JsonView(false, groupData.Msg));
  3475. }
  3476. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3477. }
  3478. catch (Exception ex)
  3479. {
  3480. return Ok(JsonView(false, ex.Message));
  3481. }
  3482. }
  3483. /// <summary>
  3484. /// 根据团组Id查询酒店费用列表
  3485. /// </summary>
  3486. /// <param name="dto"></param>
  3487. /// <returns></returns>
  3488. [HttpPost]
  3489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3490. public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  3491. {
  3492. try
  3493. {
  3494. Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
  3495. if (groupData.Code != 0)
  3496. {
  3497. return Ok(JsonView(false, groupData.Msg));
  3498. }
  3499. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3500. }
  3501. catch (Exception ex)
  3502. {
  3503. return Ok(JsonView(false, ex.Message));
  3504. }
  3505. }
  3506. /// <summary>
  3507. /// 根据酒店费用Id查询酒店费用详细
  3508. /// </summary>
  3509. /// <param name="dto"></param>
  3510. /// <returns></returns>
  3511. [HttpPost]
  3512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3513. public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
  3514. {
  3515. try
  3516. {
  3517. Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
  3518. if (groupData.Code != 0)
  3519. {
  3520. return Ok(JsonView(false, groupData.Msg));
  3521. }
  3522. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3523. }
  3524. catch (Exception ex)
  3525. {
  3526. return Ok(JsonView(false, ex.Message));
  3527. }
  3528. }
  3529. /// <summary>
  3530. /// 计算酒店付款总金额
  3531. /// </summary>
  3532. /// <param name="dto"></param>
  3533. /// <returns></returns>
  3534. [HttpPost]
  3535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3536. public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
  3537. {
  3538. try
  3539. {
  3540. Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
  3541. if (groupData.Code != 0)
  3542. {
  3543. return Ok(JsonView(false, groupData.Msg));
  3544. }
  3545. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3546. }
  3547. catch (Exception ex)
  3548. {
  3549. return Ok(JsonView(false, ex.Message));
  3550. }
  3551. }
  3552. /// <summary>
  3553. /// 酒店费用操作(Status:1.新增,2.修改)
  3554. /// </summary>
  3555. /// <param name="dto"></param>
  3556. /// <returns></returns>
  3557. [HttpPost]
  3558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3559. public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
  3560. {
  3561. try
  3562. {
  3563. Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
  3564. if (groupData.Code != 0)
  3565. {
  3566. return Ok(JsonView(false, groupData.Msg));
  3567. }
  3568. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3569. }
  3570. catch (Exception ex)
  3571. {
  3572. return Ok(JsonView(false, ex.Message));
  3573. }
  3574. }
  3575. /// <summary>
  3576. /// 文件上传
  3577. /// </summary>
  3578. /// <param name="file"></param>
  3579. /// <returns></returns>
  3580. [HttpPost]
  3581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3582. public async Task<IActionResult> UploadHotel(IFormFile file)
  3583. {
  3584. try
  3585. {
  3586. if (file != null)
  3587. {
  3588. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3589. //文件名称
  3590. string projectFileName = file.FileName;
  3591. //上传的文件的路径
  3592. string filePath = "";
  3593. if (!Directory.Exists(fileDir))
  3594. {
  3595. Directory.CreateDirectory(fileDir);
  3596. }
  3597. //上传的文件的路径
  3598. filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
  3599. using (FileStream fs = System.IO.File.Create(filePath))
  3600. {
  3601. file.CopyTo(fs);
  3602. fs.Flush();
  3603. }
  3604. return Ok(JsonView(true, "上传成功!", projectFileName));
  3605. }
  3606. else
  3607. {
  3608. return Ok(JsonView(false, "上传失败!"));
  3609. }
  3610. }
  3611. catch (Exception ex)
  3612. {
  3613. return Ok(JsonView(false, "程序错误!"));
  3614. throw;
  3615. }
  3616. }
  3617. /// <summary>
  3618. /// 删除指定文件
  3619. /// </summary>
  3620. /// <param name="dto"></param>
  3621. /// <returns></returns>
  3622. [HttpPost]
  3623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3624. public async Task<IActionResult> DelFileHotel(DelFileDto dto)
  3625. {
  3626. try
  3627. {
  3628. string filePath = "";
  3629. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3630. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3631. //int id = 0;
  3632. filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
  3633. // 删除该文件
  3634. try
  3635. {
  3636. System.IO.File.Delete(filePath);
  3637. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3638. {
  3639. Attachment = "",
  3640. }).ExecuteCommandAsync();
  3641. if (result != 0)
  3642. {
  3643. return Ok(JsonView(true, "成功!"));
  3644. }
  3645. else
  3646. {
  3647. return Ok(JsonView(false, "失败!"));
  3648. }
  3649. }
  3650. catch (Exception)
  3651. {
  3652. var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
  3653. {
  3654. Attachment = "",
  3655. }).ExecuteCommandAsync();
  3656. if (result != 0)
  3657. {
  3658. return Ok(JsonView(true, "成功!"));
  3659. }
  3660. else
  3661. {
  3662. return Ok(JsonView(false, "失败!"));
  3663. }
  3664. throw;
  3665. }
  3666. }
  3667. catch (Exception ex)
  3668. {
  3669. return Ok(JsonView(false, "程序错误!"));
  3670. throw;
  3671. }
  3672. }
  3673. /// <summary>
  3674. /// 生成VOUCHER
  3675. /// </summary>
  3676. /// <param name=""></param>
  3677. /// <returns></returns>
  3678. [HttpPost]
  3679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3680. public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
  3681. {
  3682. Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
  3683. //判断数据是否完整
  3684. if (h != null)
  3685. {
  3686. if (!string.IsNullOrEmpty(h.DetermineNo))
  3687. {
  3688. string strFileName = "HotelStatement/";
  3689. Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
  3690. if (dele != null)
  3691. strFileName += dele.TourCode;
  3692. //载入模板
  3693. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  3694. Document doc = new Document(sss);
  3695. DocumentBuilder builder = new DocumentBuilder(doc);
  3696. try
  3697. {
  3698. #region 替换Word模板书签内容
  3699. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  3700. //入住卷预定号码
  3701. if (doc.Range.Bookmarks["VNO"] != null)
  3702. {
  3703. Bookmark mark = doc.Range.Bookmarks["VNO"];
  3704. mark.Text = h.CheckNumber;
  3705. }
  3706. //酒店时间
  3707. if (doc.Range.Bookmarks["Date"] != null)
  3708. {
  3709. Bookmark mark = doc.Range.Bookmarks["Date"];
  3710. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3711. }
  3712. //团号
  3713. if (doc.Range.Bookmarks["TNo"] != null)
  3714. {
  3715. Bookmark mark = doc.Range.Bookmarks["TNo"];
  3716. mark.Text = dele.TourCode;
  3717. }
  3718. //预定号码
  3719. if (doc.Range.Bookmarks["BookingId"] != null)
  3720. {
  3721. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  3722. mark.Text = h.ReservationsNo;
  3723. }
  3724. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  3725. {
  3726. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  3727. mark.Text = h.DetermineNo;
  3728. }
  3729. //酒店城市
  3730. if (doc.Range.Bookmarks["City"] != null)
  3731. {
  3732. Bookmark mark = doc.Range.Bookmarks["City"];
  3733. mark.Text = h.City;
  3734. }
  3735. //酒店名称
  3736. if (doc.Range.Bookmarks["HName"] != null)
  3737. {
  3738. Bookmark mark = doc.Range.Bookmarks["HName"];
  3739. mark.Text = h.HotelName;
  3740. }
  3741. //酒店地址
  3742. if (doc.Range.Bookmarks["Address"] != null)
  3743. {
  3744. Bookmark mark = doc.Range.Bookmarks["Address"];
  3745. mark.Text = h.HotelAddress;
  3746. }
  3747. //酒店电话
  3748. if (doc.Range.Bookmarks["Tel"] != null)
  3749. {
  3750. Bookmark mark = doc.Range.Bookmarks["Tel"];
  3751. mark.Text = h.HotelTel;
  3752. }
  3753. //酒店传真
  3754. if (doc.Range.Bookmarks["Fax"] != null)
  3755. {
  3756. Bookmark mark = doc.Range.Bookmarks["Fax"];
  3757. if (!string.IsNullOrWhiteSpace(h.HotelFax))
  3758. {
  3759. mark.Text = h.HotelFax;
  3760. }
  3761. }
  3762. //入住时间
  3763. if (doc.Range.Bookmarks["CIn"] != null)
  3764. {
  3765. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3766. Bookmark mark = doc.Range.Bookmarks["CIn"];
  3767. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  3768. }
  3769. //退房时间
  3770. if (doc.Range.Bookmarks["COut"] != null)
  3771. {
  3772. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3773. Bookmark mark = doc.Range.Bookmarks["COut"];
  3774. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3775. }
  3776. //客户名称
  3777. if (doc.Range.Bookmarks["GName"] != null)
  3778. {
  3779. Bookmark mark = doc.Range.Bookmarks["GName"];
  3780. mark.Text = h.GuestName;
  3781. }
  3782. //房间介绍
  3783. if (doc.Range.Bookmarks["ROOM"] != null)
  3784. {
  3785. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  3786. mark.Text = h.RoomExplanation;
  3787. }
  3788. //报价描述
  3789. if (doc.Range.Bookmarks["NOTE"] != null)
  3790. {
  3791. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  3792. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
  3793. if (ss != null)
  3794. mark.Text = ss.Name;
  3795. }
  3796. //入住时间
  3797. if (doc.Range.Bookmarks["CheckIn"] != null)
  3798. {
  3799. DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
  3800. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  3801. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  3802. }
  3803. //退房时间
  3804. if (doc.Range.Bookmarks["CheckOut"] != null)
  3805. {
  3806. DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
  3807. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  3808. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  3809. }
  3810. //日期
  3811. if (doc.Range.Bookmarks["DT"] != null)
  3812. {
  3813. Bookmark mark = doc.Range.Bookmarks["DT"];
  3814. mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
  3815. }
  3816. //名称
  3817. if (doc.Range.Bookmarks["VName"] != null)
  3818. {
  3819. Bookmark mark = doc.Range.Bookmarks["VName"];
  3820. mark.Text = h.HotelName;
  3821. }
  3822. //号码
  3823. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  3824. {
  3825. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  3826. mark.Text = h.CheckNumber;
  3827. }
  3828. #endregion
  3829. //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  3830. strFileName += "VOUCHER.doc";
  3831. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  3832. doc.Save(fileDir);
  3833. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  3834. return Ok(JsonView(true, "成功!", Url));
  3835. }
  3836. catch (Exception ex)
  3837. {
  3838. throw;
  3839. }
  3840. }
  3841. else
  3842. {
  3843. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3844. }
  3845. }
  3846. else
  3847. {
  3848. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  3849. }
  3850. }
  3851. /// <summary>
  3852. /// 导出确认单
  3853. /// </summary>
  3854. /// <param name=""></param>
  3855. /// <returns></returns>
  3856. [HttpPost]
  3857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3858. public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
  3859. {
  3860. //团组信息
  3861. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
  3862. //酒店数据
  3863. List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
  3864. //利datatable存储
  3865. DataTable dt = new DataTable();
  3866. dt.Columns.Add("CheckInDate", typeof(string));
  3867. dt.Columns.Add("City", typeof(string));
  3868. dt.Columns.Add("Hotel", typeof(string));
  3869. dt.Columns.Add("Room", typeof(string));
  3870. for (int i = 0; i < listhoteldata.Count; i++)
  3871. {
  3872. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  3873. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  3874. while (dayStart < dayEnd)
  3875. {
  3876. string temp = "";
  3877. DataRow row = dt.NewRow();
  3878. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  3879. row["City"] = listhoteldata[i].City;
  3880. row["Hotel"] = listhoteldata[i].HotelName;
  3881. if (listhoteldata[i].SingleRoomCount > 0)
  3882. {
  3883. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  3884. }
  3885. if (listhoteldata[i].DoubleRoomCount > 0)
  3886. {
  3887. temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
  3888. }
  3889. if (listhoteldata[i].SuiteRoomCount > 0)
  3890. {
  3891. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  3892. }
  3893. if (listhoteldata[i].OtherRoomCount > 0)
  3894. {
  3895. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  3896. }
  3897. row["Room"] = temp;
  3898. dt.Rows.Add(row);
  3899. dayStart = dayStart.AddDays(1);
  3900. }
  3901. }
  3902. Dictionary<string, string> dic = new Dictionary<string, string>();
  3903. dic.Add("Dele", di.TeamName);
  3904. dic.Add("City", di.VisitCountry);
  3905. //模板路径
  3906. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  3907. //载入模板
  3908. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  3909. DocumentBuilder builder = new DocumentBuilder(doc);
  3910. foreach (var key in dic.Keys)
  3911. {
  3912. builder.MoveToBookmark(key);
  3913. builder.Write(dic[key]);
  3914. }
  3915. //获取word里所有表格
  3916. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3917. //获取所填表格的序数
  3918. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3919. var rowStart = tableOne.Rows[0]; //获取第1行
  3920. try
  3921. {
  3922. //循环赋值
  3923. for (int i = 0; i < dt.Rows.Count; i++)
  3924. {
  3925. builder.MoveToCell(0, i + 1, 0, 0);
  3926. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  3927. builder.MoveToCell(0, i + 1, 1, 0);
  3928. builder.Write(dt.Rows[i]["City"].ToString());
  3929. builder.MoveToCell(0, i + 1, 2, 0);
  3930. builder.Write(dt.Rows[i]["Hotel"].ToString());
  3931. builder.MoveToCell(0, i + 1, 3, 0);
  3932. builder.Write(dt.Rows[i]["Room"].ToString());
  3933. }
  3934. }
  3935. catch
  3936. {
  3937. }
  3938. //删除多余行
  3939. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  3940. {
  3941. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  3942. }
  3943. string strFileName = di.TeamName + "酒店确认单.doc";
  3944. try
  3945. {
  3946. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  3947. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  3948. return Ok(JsonView(true, "成功", Url));
  3949. }
  3950. catch (Exception)
  3951. {
  3952. return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
  3953. throw;
  3954. }
  3955. }
  3956. /// <summary>
  3957. /// 酒店费用删除
  3958. /// </summary>
  3959. /// <param name="dto"></param>
  3960. /// <returns></returns>
  3961. [HttpPost]
  3962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3963. public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
  3964. {
  3965. try
  3966. {
  3967. var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3968. if (!res)
  3969. {
  3970. return Ok(JsonView(false, "删除失败"));
  3971. }
  3972. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
  3973. {
  3974. IsDel = 1,
  3975. DeleteUserId = dto.DeleteUserId,
  3976. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3977. }).ExecuteCommandAsync();
  3978. return Ok(JsonView(true, "删除成功!"));
  3979. }
  3980. catch (Exception ex)
  3981. {
  3982. return Ok(JsonView(false, "程序错误!"));
  3983. throw;
  3984. }
  3985. }
  3986. #endregion
  3987. #region 酒店预订 新 雷怡 2023-12-28 17:45
  3988. /// <summary>
  3989. /// 酒店预订
  3990. /// 酒店费用列表 根据团组Id查询
  3991. /// </summary>
  3992. /// <param name="_dto"></param>
  3993. /// <returns></returns>
  3994. [HttpPost]
  3995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3996. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  3997. {
  3998. try
  3999. {
  4000. #region 参数验证
  4001. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4002. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4003. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4004. #region 团组操作权限验证 76 酒店预定模块
  4005. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4006. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4007. #endregion
  4008. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4009. #region 页面操作权限验证
  4010. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4011. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  4012. #endregion
  4013. #endregion
  4014. Result _view = await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId);
  4015. if (_view.Code != 0)
  4016. {
  4017. return Ok(JsonView(false, _view.Msg));
  4018. }
  4019. return Ok(JsonView(true, _view.Msg, _view.Data));
  4020. }
  4021. catch (Exception ex)
  4022. {
  4023. return Ok(JsonView(false, ex.Message));
  4024. }
  4025. }
  4026. /// <summary>
  4027. /// 酒店预订
  4028. /// 基础数据
  4029. /// </summary>
  4030. /// <param name="_dto"></param>
  4031. /// <returns></returns>
  4032. [HttpPost]
  4033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4034. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  4035. {
  4036. try
  4037. {
  4038. #region 参数验证
  4039. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4040. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4041. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4042. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4043. #region 页面操作权限验证
  4044. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4045. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  4046. #endregion
  4047. #region 团组操作权限验证 76 酒店预定模块
  4048. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4049. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4050. #endregion
  4051. #endregion
  4052. Result data = await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId);
  4053. if (data.Code != 0)
  4054. {
  4055. return Ok(JsonView(false, data.Msg));
  4056. }
  4057. return Ok(JsonView(true, data.Msg, data.Data));
  4058. }
  4059. catch (Exception ex)
  4060. {
  4061. return Ok(JsonView(false, "Catch:"+ex.Message));
  4062. }
  4063. }
  4064. /// <summary>
  4065. /// 酒店预订
  4066. /// 创建 入住卷号码
  4067. /// </summary>
  4068. /// <param name="_dto"></param>
  4069. /// <returns></returns>
  4070. [HttpPost]
  4071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4072. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  4073. {
  4074. try
  4075. {
  4076. #region 参数验证
  4077. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4078. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4079. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4080. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4081. #region 页面操作权限验证
  4082. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4083. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  4084. #endregion
  4085. #region 团组操作权限验证 76 酒店预定模块
  4086. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4087. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4088. #endregion
  4089. #endregion
  4090. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  4091. if (data.Code != 0)
  4092. {
  4093. return Ok(JsonView(false, data.Msg));
  4094. }
  4095. return Ok(JsonView(true, data.Msg, data.Data));
  4096. }
  4097. catch (Exception ex)
  4098. {
  4099. return Ok(JsonView(false, ex.Message));
  4100. }
  4101. }
  4102. /// <summary>
  4103. /// 酒店预订
  4104. /// 详情
  4105. /// </summary>
  4106. /// <param name="_dto"></param>
  4107. /// <returns></returns>
  4108. [HttpPost]
  4109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4110. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  4111. {
  4112. try
  4113. {
  4114. #region 参数验证
  4115. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4116. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4117. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4118. #region 团组操作权限验证 76 酒店预定模块
  4119. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4120. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4121. #endregion
  4122. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4123. #region 页面操作权限验证
  4124. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4125. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  4126. #endregion
  4127. #endregion
  4128. Result data = await _hotelPriceRep._Details(_dto.PortType,_dto.Id);
  4129. if (data.Code != 0)
  4130. {
  4131. return Ok(JsonView(false, data.Msg));
  4132. }
  4133. return Ok(JsonView(true, data.Msg, data.Data));
  4134. }
  4135. catch (Exception ex)
  4136. {
  4137. return Ok(JsonView(false, ex.Message));
  4138. }
  4139. }
  4140. /// <summary>
  4141. /// 酒店预订
  4142. /// Add Or Edit
  4143. /// </summary>
  4144. /// <param name="_dto"></param>
  4145. /// <returns></returns>
  4146. [HttpPost]
  4147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4148. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  4149. {
  4150. try
  4151. {
  4152. #region 参数验证
  4153. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4154. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4155. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4156. #region 团组操作权限验证 76 酒店预定模块
  4157. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4158. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4159. #endregion
  4160. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4161. #region 页面操作权限验证
  4162. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4163. if (_dto.Id == 0) // Add
  4164. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  4165. else if (_dto.Id > 0) // Edit
  4166. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  4167. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  4168. #endregion
  4169. #endregion
  4170. Result data = await _hotelPriceRep._AddOrEdit(_dto);
  4171. if (data.Code != 0)
  4172. {
  4173. return Ok(JsonView(false, data.Msg));
  4174. }
  4175. return Ok(JsonView(true, data.Msg, data.Data));
  4176. }
  4177. catch (Exception ex)
  4178. {
  4179. return Ok(JsonView(false, ex.Message));
  4180. }
  4181. }
  4182. /// <summary>
  4183. /// 酒店预订
  4184. /// Del
  4185. /// </summary>
  4186. /// <param name="_dto"></param>
  4187. /// <returns></returns>
  4188. [HttpPost]
  4189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4190. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  4191. {
  4192. try
  4193. {
  4194. #region 参数验证
  4195. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4196. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4197. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4198. #region 团组操作权限验证 76 酒店预定模块
  4199. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4200. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4201. #endregion
  4202. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4203. #region 页面操作权限验证
  4204. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4205. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  4206. #endregion
  4207. #endregion
  4208. Result data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  4209. if (data.Code != 0)
  4210. {
  4211. return Ok(JsonView(false, data.Msg));
  4212. }
  4213. return Ok(JsonView(true, data.Msg, data.Data));
  4214. }
  4215. catch (Exception ex)
  4216. {
  4217. return Ok(JsonView(false, ex.Message));
  4218. }
  4219. }
  4220. /// <summary>
  4221. /// 酒店预订
  4222. /// 生成VOUCHER
  4223. /// </summary>
  4224. /// <param name="_dto"></param>
  4225. /// <returns></returns>
  4226. [HttpPost]
  4227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4228. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  4229. {
  4230. try
  4231. {
  4232. #region 参数验证
  4233. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4234. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4235. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4236. #region 团组操作权限验证 76 酒店预定模块
  4237. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4238. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4239. #endregion
  4240. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4241. #region 页面操作权限验证
  4242. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4243. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  4244. #endregion
  4245. #endregion
  4246. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  4247. //判断数据是否完整
  4248. if (hr != null)
  4249. {
  4250. if (!string.IsNullOrEmpty(hr.DetermineNo))
  4251. {
  4252. string strFileName = "HotelStatement/";
  4253. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  4254. if (dele != null)
  4255. strFileName += dele.TourCode;
  4256. //载入模板
  4257. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  4258. Document doc = new Document(sss);
  4259. DocumentBuilder builder = new DocumentBuilder(doc);
  4260. #region 替换Word模板书签内容
  4261. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  4262. //入住卷预定号码
  4263. if (doc.Range.Bookmarks["VNO"] != null)
  4264. {
  4265. Bookmark mark = doc.Range.Bookmarks["VNO"];
  4266. mark.Text = hr.CheckNumber;
  4267. }
  4268. //酒店时间
  4269. if (doc.Range.Bookmarks["Date"] != null)
  4270. {
  4271. Bookmark mark = doc.Range.Bookmarks["Date"];
  4272. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  4273. }
  4274. //团号
  4275. if (doc.Range.Bookmarks["TNo"] != null)
  4276. {
  4277. Bookmark mark = doc.Range.Bookmarks["TNo"];
  4278. mark.Text = dele.TourCode;
  4279. }
  4280. //预定号码
  4281. if (doc.Range.Bookmarks["BookingId"] != null)
  4282. {
  4283. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  4284. mark.Text = hr.ReservationsNo;
  4285. }
  4286. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  4287. {
  4288. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  4289. mark.Text = hr.DetermineNo;
  4290. }
  4291. //酒店城市
  4292. if (doc.Range.Bookmarks["City"] != null)
  4293. {
  4294. Bookmark mark = doc.Range.Bookmarks["City"];
  4295. mark.Text = hr.City;
  4296. }
  4297. //酒店名称
  4298. if (doc.Range.Bookmarks["HName"] != null)
  4299. {
  4300. Bookmark mark = doc.Range.Bookmarks["HName"];
  4301. mark.Text = hr.HotelName;
  4302. }
  4303. //酒店地址
  4304. if (doc.Range.Bookmarks["Address"] != null)
  4305. {
  4306. Bookmark mark = doc.Range.Bookmarks["Address"];
  4307. mark.Text = hr.HotelAddress;
  4308. }
  4309. //酒店电话
  4310. if (doc.Range.Bookmarks["Tel"] != null)
  4311. {
  4312. Bookmark mark = doc.Range.Bookmarks["Tel"];
  4313. mark.Text = hr.HotelTel;
  4314. }
  4315. //酒店传真
  4316. if (doc.Range.Bookmarks["Fax"] != null)
  4317. {
  4318. Bookmark mark = doc.Range.Bookmarks["Fax"];
  4319. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  4320. {
  4321. mark.Text = hr.HotelFax;
  4322. }
  4323. }
  4324. //入住时间
  4325. if (doc.Range.Bookmarks["CIn"] != null)
  4326. {
  4327. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  4328. Bookmark mark = doc.Range.Bookmarks["CIn"];
  4329. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  4330. }
  4331. //退房时间
  4332. if (doc.Range.Bookmarks["COut"] != null)
  4333. {
  4334. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  4335. Bookmark mark = doc.Range.Bookmarks["COut"];
  4336. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  4337. }
  4338. //客户名称
  4339. if (doc.Range.Bookmarks["GName"] != null)
  4340. {
  4341. Bookmark mark = doc.Range.Bookmarks["GName"];
  4342. mark.Text = hr.GuestName;
  4343. }
  4344. //房间介绍
  4345. if (doc.Range.Bookmarks["ROOM"] != null)
  4346. {
  4347. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  4348. mark.Text = hr.RoomExplanation;
  4349. }
  4350. //报价描述
  4351. if (doc.Range.Bookmarks["NOTE"] != null)
  4352. {
  4353. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  4354. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  4355. if (ss != null)
  4356. mark.Text = ss.Name;
  4357. }
  4358. //入住时间
  4359. if (doc.Range.Bookmarks["CheckIn"] != null)
  4360. {
  4361. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  4362. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  4363. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  4364. }
  4365. //退房时间
  4366. if (doc.Range.Bookmarks["CheckOut"] != null)
  4367. {
  4368. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  4369. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  4370. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  4371. }
  4372. //日期
  4373. if (doc.Range.Bookmarks["DT"] != null)
  4374. {
  4375. Bookmark mark = doc.Range.Bookmarks["DT"];
  4376. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  4377. }
  4378. //名称
  4379. if (doc.Range.Bookmarks["VName"] != null)
  4380. {
  4381. Bookmark mark = doc.Range.Bookmarks["VName"];
  4382. mark.Text = hr.HotelName;
  4383. }
  4384. //号码
  4385. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  4386. {
  4387. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  4388. mark.Text = hr.CheckNumber;
  4389. }
  4390. #endregion
  4391. strFileName += "VOUCHER.doc";
  4392. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  4393. doc.Save(fileDir);
  4394. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  4395. return Ok(JsonView(true, "操作成功!", Url));
  4396. }
  4397. else
  4398. {
  4399. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  4400. }
  4401. }
  4402. else
  4403. {
  4404. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  4405. }
  4406. }
  4407. catch (Exception ex)
  4408. {
  4409. return Ok(JsonView(false, ex.Message));
  4410. }
  4411. }
  4412. /// <summary>
  4413. /// 酒店预订
  4414. /// 确认单
  4415. /// </summary>
  4416. /// <param name="_dto"></param>
  4417. /// <returns></returns>
  4418. [HttpPost]
  4419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4420. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  4421. {
  4422. try
  4423. {
  4424. #region 参数验证
  4425. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4426. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  4427. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  4428. #region 团组操作权限验证 76 酒店预定模块
  4429. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  4430. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  4431. #endregion
  4432. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4433. #region 页面操作权限验证
  4434. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4435. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  4436. #endregion
  4437. #endregion
  4438. //团组信息
  4439. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  4440. //酒店数据
  4441. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  4442. if (listhoteldata.Count < 0)
  4443. {
  4444. return Ok(JsonView(false, "当前团组暂无酒店预订信息!"));
  4445. }
  4446. //利datatable存储
  4447. DataTable dt = new DataTable();
  4448. dt.Columns.Add("CheckInDate", typeof(string));
  4449. dt.Columns.Add("City", typeof(string));
  4450. dt.Columns.Add("Hotel", typeof(string));
  4451. dt.Columns.Add("Room", typeof(string));
  4452. for (int i = 0; i < listhoteldata.Count; i++)
  4453. {
  4454. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  4455. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  4456. while (dayStart < dayEnd)
  4457. {
  4458. string temp = "";
  4459. DataRow row = dt.NewRow();
  4460. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  4461. row["City"] = listhoteldata[i].City;
  4462. row["Hotel"] = listhoteldata[i].HotelName;
  4463. if (listhoteldata[i].SingleRoomCount > 0)
  4464. {
  4465. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  4466. }
  4467. if (listhoteldata[i].DoubleRoomCount > 0)
  4468. {
  4469. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  4470. }
  4471. if (listhoteldata[i].SuiteRoomCount > 0)
  4472. {
  4473. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  4474. }
  4475. if (listhoteldata[i].OtherRoomCount > 0)
  4476. {
  4477. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  4478. }
  4479. row["Room"] = temp;
  4480. dt.Rows.Add(row);
  4481. dayStart = dayStart.AddDays(1);
  4482. }
  4483. }
  4484. Dictionary<string, string> dic = new Dictionary<string, string>();
  4485. dic.Add("Dele", di.TeamName);
  4486. dic.Add("City", di.VisitCountry);
  4487. //模板路径
  4488. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  4489. //载入模板
  4490. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  4491. DocumentBuilder builder = new DocumentBuilder(doc);
  4492. foreach (var key in dic.Keys)
  4493. {
  4494. builder.MoveToBookmark(key);
  4495. builder.Write(dic[key]);
  4496. }
  4497. //获取word里所有表格
  4498. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4499. //获取所填表格的序数
  4500. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4501. var rowStart = tableOne.Rows[0]; //获取第1行
  4502. //循环赋值
  4503. for (int i = 0; i < dt.Rows.Count; i++)
  4504. {
  4505. builder.MoveToCell(0, i + 1, 0, 0);
  4506. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  4507. builder.MoveToCell(0, i + 1, 1, 0);
  4508. builder.Write(dt.Rows[i]["City"].ToString());
  4509. builder.MoveToCell(0, i + 1, 2, 0);
  4510. builder.Write(dt.Rows[i]["Hotel"].ToString());
  4511. builder.MoveToCell(0, i + 1, 3, 0);
  4512. builder.Write(dt.Rows[i]["Room"].ToString());
  4513. }
  4514. //删除多余行
  4515. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  4516. {
  4517. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  4518. }
  4519. string strFileName = di.TeamName + "酒店确认单.doc";
  4520. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  4521. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  4522. return Ok(JsonView(true, "成功", url));
  4523. }
  4524. catch (Exception ex)
  4525. {
  4526. return Ok(JsonView(false, ex.Message));
  4527. }
  4528. }
  4529. #endregion
  4530. #region 团组状态
  4531. /// <summary>
  4532. /// 团组状态列表 Page
  4533. /// </summary>
  4534. /// <param name="dto">团组列表请求dto</param>
  4535. /// <returns></returns>
  4536. [HttpPost]
  4537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4538. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  4539. {
  4540. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  4541. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  4542. {
  4543. string sqlWhere = string.Empty;
  4544. if (dto.IsSure == 0) //未完成
  4545. {
  4546. sqlWhere += string.Format(@" And IsSure = 0");
  4547. }
  4548. else if (dto.IsSure == 1) //已完成
  4549. {
  4550. sqlWhere += string.Format(@" And IsSure = 1");
  4551. }
  4552. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  4553. {
  4554. string tj = dto.SearchCriteria;
  4555. 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}%')",
  4556. tj, tj, tj, tj, tj);
  4557. }
  4558. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  4559. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  4560. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  4561. From (
  4562. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  4563. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  4564. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  4565. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  4566. From Grp_DelegationInfo gdi
  4567. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  4568. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  4569. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  4570. Where gdi.IsDel = 0 {0}
  4571. ) temp ", sqlWhere);
  4572. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  4573. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  4574. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  4575. }
  4576. else
  4577. {
  4578. return Ok(JsonView(false, "查询失败"));
  4579. }
  4580. }
  4581. /// <summary>
  4582. /// 团组状态
  4583. /// 设置操作完成
  4584. /// </summary>
  4585. /// <param name="dto">团组列表请求dto</param>
  4586. /// <returns></returns>
  4587. [HttpPost]
  4588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4589. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  4590. {
  4591. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  4592. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  4593. {
  4594. Id = dto.Id,
  4595. IsSure = 1
  4596. };
  4597. var result = await _sqlSugar.Updateable(_DelegationInfo)
  4598. .UpdateColumns(it => new { it.IsSure })
  4599. .WhereColumns(it => new { it.Id })
  4600. .ExecuteCommandAsync();
  4601. if (result > 0)
  4602. {
  4603. return Ok(JsonView(true, "操作完成!"));
  4604. }
  4605. return Ok(JsonView(false, "操作失败!"));
  4606. }
  4607. #endregion
  4608. #region 保险费用录入
  4609. /// <summary>
  4610. /// 根据团组Id查询保险费用列表
  4611. /// </summary>
  4612. /// <param name="dto"></param>
  4613. /// <returns></returns>
  4614. [HttpPost]
  4615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4616. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  4617. {
  4618. try
  4619. {
  4620. Result groupData = await _customersRep.CustomersByDiId(dto);
  4621. if (groupData.Code != 0)
  4622. {
  4623. return Ok(JsonView(false, groupData.Msg));
  4624. }
  4625. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4626. }
  4627. catch (Exception ex)
  4628. {
  4629. return Ok(JsonView(false, ex.Message));
  4630. }
  4631. }
  4632. /// <summary>
  4633. /// 根据保险费用Id查询保险费用详细
  4634. /// </summary>
  4635. /// <param name="dto"></param>
  4636. /// <returns></returns>
  4637. [HttpPost]
  4638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4639. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  4640. {
  4641. try
  4642. {
  4643. Result groupData = await _customersRep.CustomersById(dto);
  4644. if (groupData.Code != 0)
  4645. {
  4646. return Ok(JsonView(false, groupData.Msg));
  4647. }
  4648. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4649. }
  4650. catch (Exception ex)
  4651. {
  4652. return Ok(JsonView(false, ex.Message));
  4653. }
  4654. }
  4655. /// <summary>
  4656. /// 保险费用录入页面初始化绑定
  4657. /// </summary>
  4658. /// <param name="dto"></param>
  4659. /// <returns></returns>
  4660. [HttpPost]
  4661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4662. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  4663. {
  4664. try
  4665. {
  4666. Result groupData = await _customersRep.CustomersInitialize(dto);
  4667. if (groupData.Code != 0)
  4668. {
  4669. return Ok(JsonView(false, groupData.Msg));
  4670. }
  4671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4672. }
  4673. catch (Exception ex)
  4674. {
  4675. return Ok(JsonView(false, ex.Message));
  4676. }
  4677. }
  4678. /// <summary>
  4679. /// 保险费用操作(Status:1.新增,2.修改)
  4680. /// </summary>
  4681. /// <param name="dto"></param>
  4682. /// <returns></returns>
  4683. [HttpPost]
  4684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4685. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  4686. {
  4687. try
  4688. {
  4689. Result groupData = await _customersRep.OpCustomers(dto);
  4690. if (groupData.Code != 0)
  4691. {
  4692. return Ok(JsonView(false, groupData.Msg));
  4693. }
  4694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4695. }
  4696. catch (Exception ex)
  4697. {
  4698. return Ok(JsonView(false, ex.Message));
  4699. }
  4700. }
  4701. /// <summary>
  4702. /// 保险文件上传
  4703. /// </summary>
  4704. /// <param name="file"></param>
  4705. /// <returns></returns>
  4706. [HttpPost]
  4707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4708. public async Task<IActionResult> UploadCus(IFormFile file)
  4709. {
  4710. try
  4711. {
  4712. if (file != null)
  4713. {
  4714. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4715. //文件名称
  4716. string projectFileName = file.FileName;
  4717. //上传的文件的路径
  4718. string filePath = "";
  4719. if (!Directory.Exists(fileDir))
  4720. {
  4721. Directory.CreateDirectory(fileDir);
  4722. }
  4723. //上传的文件的路径
  4724. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  4725. using (FileStream fs = System.IO.File.Create(filePath))
  4726. {
  4727. file.CopyTo(fs);
  4728. fs.Flush();
  4729. }
  4730. return Ok(JsonView(true, "上传成功!", projectFileName));
  4731. }
  4732. else
  4733. {
  4734. return Ok(JsonView(false, "上传失败!"));
  4735. }
  4736. }
  4737. catch (Exception ex)
  4738. {
  4739. return Ok(JsonView(false, "程序错误!"));
  4740. throw;
  4741. }
  4742. }
  4743. /// <summary>
  4744. /// 保险删除指定文件
  4745. /// </summary>
  4746. /// <param name="dto"></param>
  4747. /// <returns></returns>
  4748. [HttpPost]
  4749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4750. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  4751. {
  4752. try
  4753. {
  4754. string filePath = "";
  4755. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4756. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4757. //int id = 0;
  4758. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  4759. // 删除该文件
  4760. try
  4761. {
  4762. System.IO.File.Delete(filePath);
  4763. 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()
  4764. {
  4765. Attachment = "",
  4766. }).ExecuteCommandAsync();
  4767. if (result != 0)
  4768. {
  4769. return Ok(JsonView(true, "成功!"));
  4770. }
  4771. else
  4772. {
  4773. return Ok(JsonView(false, "失败!"));
  4774. }
  4775. }
  4776. catch (Exception)
  4777. {
  4778. 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()
  4779. {
  4780. Attachment = "",
  4781. }).ExecuteCommandAsync();
  4782. if (result != 0)
  4783. {
  4784. return Ok(JsonView(true, "成功!"));
  4785. }
  4786. else
  4787. {
  4788. return Ok(JsonView(false, "失败!"));
  4789. }
  4790. }
  4791. }
  4792. catch (Exception ex)
  4793. {
  4794. return Ok(JsonView(false, "程序错误!"));
  4795. throw;
  4796. }
  4797. }
  4798. /// <summary>
  4799. /// 保险费用操作(删除)
  4800. /// </summary>
  4801. /// <param name="dto"></param>
  4802. /// <returns></returns>
  4803. [HttpPost]
  4804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4805. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  4806. {
  4807. try
  4808. {
  4809. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  4810. if (!res)
  4811. {
  4812. return Ok(JsonView(false, "删除失败"));
  4813. }
  4814. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  4815. {
  4816. IsDel = 1,
  4817. DeleteUserId = dto.DeleteUserId,
  4818. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4819. }).ExecuteCommandAsync();
  4820. return Ok(JsonView(true, "删除成功!"));
  4821. }
  4822. catch (Exception ex)
  4823. {
  4824. return Ok(JsonView(false, "程序错误!"));
  4825. throw;
  4826. }
  4827. }
  4828. #endregion
  4829. #region 接团客户名单 PageId 104
  4830. /// <summary>
  4831. /// 接团客户名单
  4832. /// 根据团组Id查询List
  4833. /// </summary>
  4834. /// <param name="dto"></param>
  4835. /// <returns></returns>
  4836. [HttpPost]
  4837. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  4838. {
  4839. #region 参数验证
  4840. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  4841. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  4842. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  4843. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4844. #region 页面操作权限验证
  4845. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4846. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  4847. #endregion
  4848. #endregion
  4849. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType,_dto.DiId);
  4850. if (viewData.Code != 0)
  4851. {
  4852. return Ok(JsonView(false, viewData.Msg));
  4853. }
  4854. return Ok(JsonView(viewData.Data));
  4855. }
  4856. /// <summary>
  4857. /// 接团客户名单
  4858. /// 基础数据 Init
  4859. /// </summary>
  4860. /// <param name="_dto"></param>
  4861. /// <returns></returns>
  4862. [HttpPost]
  4863. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  4864. {
  4865. #region 参数验证
  4866. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  4867. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  4868. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4869. #region 页面操作权限验证
  4870. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4871. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  4872. #endregion
  4873. #endregion
  4874. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  4875. if (viewData.Code != 0)
  4876. {
  4877. return Ok(JsonView(false, viewData.Msg));
  4878. }
  4879. return Ok(JsonView(viewData.Data));
  4880. }
  4881. /// <summary>
  4882. /// 接团客户名单
  4883. /// 根据 Id查询 Details
  4884. /// </summary>
  4885. /// <param name="dto"></param>
  4886. /// <returns></returns>
  4887. [HttpPost]
  4888. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  4889. {
  4890. #region 参数验证
  4891. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  4892. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  4893. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4894. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4895. #region 页面操作权限验证
  4896. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4897. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  4898. #endregion
  4899. #endregion
  4900. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  4901. if (viewData.Code != 0)
  4902. {
  4903. return Ok(JsonView(false, viewData.Msg));
  4904. }
  4905. return Ok(JsonView(viewData.Data));
  4906. }
  4907. /// <summary>
  4908. /// 接团客户名单
  4909. /// 根据 Id查询 Details
  4910. /// </summary>
  4911. /// <param name="dto"></param>
  4912. /// <returns></returns>
  4913. [HttpPost]
  4914. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  4915. {
  4916. #region 参数验证
  4917. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  4918. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  4919. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4920. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  4921. #region 页面操作权限验证
  4922. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4923. if (_dto.Id == 0) //添加
  4924. {
  4925. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  4926. }else if (_dto.Id >= 0) //修改
  4927. {
  4928. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  4929. }
  4930. #endregion
  4931. #endregion
  4932. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  4933. if (viewData.Code != 0)
  4934. {
  4935. return Ok(JsonView(false, viewData.Msg));
  4936. }
  4937. return Ok(JsonView(viewData.Data));
  4938. }
  4939. #endregion
  4940. }
  4941. }