GroupsController.cs 201 KB

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