GroupsController.cs 172 KB

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