GroupsController.cs 148 KB

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