GroupsController.cs 130 KB

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