GroupsController.cs 189 KB

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