GroupsController.cs 125 KB

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