GroupsController.cs 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765
  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. namespace OASystem.API.Controllers
  22. {
  23. /// <summary>
  24. /// 团组相关
  25. /// </summary>
  26. //[Authorize]
  27. [Route("api/[controller]/[action]")]
  28. public class GroupsController : ControllerBase
  29. {
  30. private readonly GrpScheduleRepository _grpScheduleRep;
  31. private readonly IMapper _mapper;
  32. private readonly DelegationInfoRepository _groupRepository;
  33. private readonly TaskAssignmentRepository _taskAssignmentRep;
  34. private readonly AirTicketResRepository _airTicketResRep;
  35. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  36. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  37. private readonly SqlSugarClient _sqlSugar;
  38. private string url;
  39. private string path;
  40. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  41. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  42. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep)
  43. {
  44. _mapper = mapper;
  45. _grpScheduleRep = grpScheduleRep;
  46. _groupRepository = groupRepository;
  47. _taskAssignmentRep = taskAssignmentRep;
  48. _airTicketResRep = airTicketResRep;
  49. _sqlSugar = sqlSugar;
  50. url = AppSettingsHelper.Get("ExcelBaseUrl");
  51. path = AppSettingsHelper.Get("ExcelBasePath");
  52. if (!System.IO.Directory.Exists(path))
  53. {
  54. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  55. }
  56. _decreasePaymentsRep = decreasePaymentsRep;
  57. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  58. }
  59. #region 流程管控
  60. /// <summary>
  61. /// 获取团组流程管控信息
  62. /// </summary>
  63. /// <param name="paras">参数Json字符串</param>
  64. /// <returns></returns>
  65. [HttpPost]
  66. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  67. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  68. {
  69. if (string.IsNullOrEmpty(_jsonDto.Paras))
  70. {
  71. return Ok(JsonView(false, "参数为空"));
  72. }
  73. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  74. if (_ScheduleDto != null)
  75. {
  76. if (_ScheduleDto.SearchType == 2)//获取列表
  77. {
  78. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  79. return Ok(JsonView(_grpScheduleViewList));
  80. }
  81. else//获取对象
  82. {
  83. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  84. if (_grpScheduleView != null)
  85. {
  86. return Ok(JsonView(_grpScheduleView));
  87. }
  88. }
  89. }
  90. else
  91. {
  92. return Ok(JsonView(false, "参数反序列化失败"));
  93. }
  94. return Ok(JsonView(false, "暂无数据!"));
  95. }
  96. /// <summary>
  97. /// 修改团组流程管控详细表数据
  98. /// </summary>
  99. /// <param name="paras"></param>
  100. /// <returns></returns>
  101. [HttpPost]
  102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  103. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  104. {
  105. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  106. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  107. .SetColumns(it => it.Duty == _detail.Duty)
  108. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  109. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  110. .SetColumns(it => it.JobContent == _detail.JobContent)
  111. .SetColumns(it => it.Remark == _detail.Remark)
  112. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  113. .Where(s => s.Id == dto.Id)
  114. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  115. .ExecuteCommandAsync();
  116. if (result > 0)
  117. {
  118. return Ok(JsonView(true, "保存成功!"));
  119. }
  120. return Ok(JsonView(false, "保存失败!"));
  121. }
  122. /// <summary>
  123. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  124. /// </summary>
  125. /// <param name="dto"></param>
  126. /// <returns></returns>
  127. [HttpPost]
  128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  129. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  130. {
  131. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  132. _detail.IsDel = 1;
  133. _detail.DeleteUserId = dto.Duty;
  134. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  135. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  136. .SetColumns(it => it.IsDel == _detail.IsDel)
  137. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  138. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  139. .Where(it => it.Id == dto.Id)
  140. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  141. //.WhereColumns(s => s.Id == dto.Id)
  142. .ExecuteCommandAsync();
  143. if (result > 0)
  144. {
  145. return Ok(JsonView(true, "删除成功!"));
  146. }
  147. return Ok(JsonView(false, "删除失败!"));
  148. }
  149. /// <summary>
  150. /// 增加团组流程管控详细表数据
  151. /// </summary>
  152. /// <param name="dto"></param>
  153. /// <returns></returns>
  154. [HttpPost]
  155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  156. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  157. {
  158. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  159. if (DateTime.Now < _detail.ExpectBeginDt)
  160. {
  161. _detail.StepStatus = 0;
  162. }
  163. else
  164. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  165. _detail.StepStatus = 1;
  166. }
  167. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  168. if (result > 0)
  169. {
  170. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  171. return Ok(JsonView(true, "添加成功!", _result));
  172. }
  173. return Ok(JsonView(false, "添加失败!"));
  174. }
  175. #endregion
  176. #region 团组基本信息
  177. /// <summary>
  178. /// 接团信息列表
  179. /// </summary>
  180. /// <param name="dto">团组列表请求dto</param>
  181. /// <returns></returns>
  182. [HttpPost]
  183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  184. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  185. {
  186. var groupData = await _groupRepository.GetGroupList(dto);
  187. if (groupData.Code != 0)
  188. {
  189. return Ok(JsonView(false, groupData.Msg));
  190. }
  191. return Ok(JsonView(groupData.Data));
  192. }
  193. /// <summary>
  194. /// 接团信息详情
  195. /// </summary>
  196. /// <param name="dto">团组info请求dto</param>
  197. /// <returns></returns>
  198. [HttpPost]
  199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  200. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  201. {
  202. var groupData = await _groupRepository.GetGroupInfo(dto);
  203. if (groupData.Code != 0)
  204. {
  205. return Ok(JsonView(false, groupData.Msg));
  206. }
  207. return Ok(JsonView(groupData.Data));
  208. }
  209. /// <summary>
  210. /// 接团信息 编辑添加
  211. /// 基础信息数据源
  212. /// </summary>
  213. /// <param name="dto"></param>
  214. /// <returns></returns>
  215. [HttpPost]
  216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  217. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  218. {
  219. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  220. if (groupData.Code != 0)
  221. {
  222. return Ok(JsonView(false, groupData.Msg));
  223. }
  224. return Ok(JsonView(groupData.Data));
  225. }
  226. /// <summary>
  227. /// 接团信息 操作(增改)
  228. /// </summary>
  229. /// <param name="dto"></param>
  230. /// <returns></returns>
  231. [HttpPost]
  232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  233. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  234. {
  235. try
  236. {
  237. var groupData = await _groupRepository.GroupOperation(dto);
  238. if (groupData.Code != 0)
  239. {
  240. return Ok(JsonView(false, groupData.Msg));
  241. }
  242. return Ok(JsonView(true));
  243. }
  244. catch (Exception ex)
  245. {
  246. Logs("[response]" + JsonConvert.SerializeObject(dto));
  247. Logs(ex.Message);
  248. return Ok(JsonView(false, ex.Message));
  249. }
  250. }
  251. /// <summary>
  252. /// 接团信息 操作(删除)
  253. /// </summary>
  254. /// <param name="dto"></param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  259. {
  260. try
  261. {
  262. var groupData = await _groupRepository.GroupDel(dto);
  263. if (groupData.Code != 0)
  264. {
  265. return Ok(JsonView(false, groupData.Msg));
  266. }
  267. return Ok(JsonView(true));
  268. }
  269. catch (Exception ex)
  270. {
  271. Logs("[response]" + JsonConvert.SerializeObject(dto));
  272. Logs(ex.Message);
  273. return Ok(JsonView(false, ex.Message));
  274. }
  275. }
  276. /// <summary>
  277. /// 获取团组销售报价号
  278. /// 团组添加时 使用
  279. /// </summary>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<IActionResult> GetGroupSalesQuoteNo()
  284. {
  285. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  286. if (groupData.Code != 0)
  287. {
  288. return Ok(JsonView(false, groupData.Msg));
  289. }
  290. object salesQuoteNo = new
  291. {
  292. SalesQuoteNo = groupData.Data
  293. };
  294. return Ok(JsonView(salesQuoteNo));
  295. }
  296. /// <summary>
  297. /// 设置确认出团
  298. /// </summary>
  299. /// <param name="dto"></param>
  300. /// <returns></returns>
  301. [HttpPost]
  302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  303. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  304. {
  305. var groupData = await _groupRepository.ConfirmationGroup(dto);
  306. if (groupData.Code != 0)
  307. {
  308. return Ok(JsonView(false, groupData.Msg));
  309. }
  310. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  311. return Ok(JsonView(groupData.Data));
  312. }
  313. /// <summary>
  314. /// 获取团组名称 List
  315. /// </summary>
  316. /// <param name="dto"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
  321. {
  322. var groupData = await _groupRepository.GetGroupNameList(dto);
  323. if (groupData.Code != 0)
  324. {
  325. return Ok(JsonView(false, groupData.Msg));
  326. }
  327. return Ok(JsonView(groupData.Data, groupData.Data.Count));
  328. }
  329. /// <summary>
  330. /// 获取团组名称data And 签证国别Data
  331. /// </summary>
  332. /// <param name="dto"></param>
  333. /// <returns></returns>
  334. [HttpPost]
  335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  336. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  337. {
  338. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  339. if (groupData.Code != 0)
  340. {
  341. return Ok(JsonView(false, groupData.Msg));
  342. }
  343. return Ok(JsonView(groupData.Data));
  344. }
  345. #endregion
  346. #region 团组&签证
  347. /// <summary>
  348. /// 根据团组Id获取签证客户信息List
  349. /// </summary>
  350. /// <param name="dto">请求dto</param>
  351. /// <returns></returns>
  352. [HttpPost]
  353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  354. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  355. {
  356. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  357. if (groupData.Code != 0)
  358. {
  359. return Ok(JsonView(false, groupData.Msg));
  360. }
  361. return Ok(JsonView(groupData.Data));
  362. }
  363. #endregion
  364. #region 团组任务分配
  365. /// <summary>
  366. /// 团组任务分配初始化
  367. /// </summary>
  368. /// <param name="dto"></param>
  369. /// <returns></returns>
  370. [HttpPost]
  371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  372. public async Task<IActionResult> GetTaskAssignmen()
  373. {
  374. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  375. if (groupData.Code != 0)
  376. {
  377. return Ok(JsonView(false, groupData.Msg));
  378. }
  379. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  380. }
  381. /// <summary>
  382. /// 团组任务分配查询
  383. /// </summary>
  384. /// <param name="dto"></param>
  385. /// <returns></returns>
  386. [HttpPost]
  387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  388. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  389. {
  390. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  391. if (groupData.Code != 0)
  392. {
  393. return Ok(JsonView(false, groupData.Msg));
  394. }
  395. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  396. }
  397. /// <summary>
  398. /// 团组任务分配操作
  399. /// </summary>
  400. /// <param name="dto"></param>
  401. /// <returns></returns>
  402. [HttpPost]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  405. {
  406. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  407. if (groupData.Code != 0)
  408. {
  409. return Ok(JsonView(false, groupData.Msg));
  410. }
  411. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  412. }
  413. #endregion
  414. #region 团组费用审核
  415. /// <summary>
  416. /// 获取团组费用审核
  417. /// </summary>
  418. /// <param name="paras">参数Json字符串</param>
  419. /// <returns></returns>
  420. [HttpPost]
  421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  422. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  423. {
  424. if (_dto.DiId < 1)
  425. {
  426. return Ok(JsonView(false, "团组Id为空"));
  427. }
  428. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  429. #region 团组基本信息
  430. Grp_DelegationInfo _delegation = _groupRepository.Query<Grp_DelegationInfo>(s => s.Id == _dto.DiId).First();
  431. if (_delegation != null)
  432. {
  433. _view.ClientName = _delegation.ClientName;
  434. _view.DiId = _dto.DiId;
  435. _view.TeamName = _delegation.TeamName;
  436. _view.VisitCountry = _delegation.VisitCountry;
  437. _view.VisitDate = _delegation.VisitStartDate.ToString("yyyy-MM-dd") + " ~ " + _delegation.VisitEndDate.ToString("yyyy-MM-dd");
  438. _view.VisitDays = _delegation.VisitDays;
  439. _view.VisitPNumber = _delegation.VisitPNumber;
  440. }
  441. else
  442. {
  443. return Ok(JsonView(false, "团组信息为空"));
  444. }
  445. #endregion
  446. #region 费用清单
  447. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  448. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  449. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  450. List<Grp_CreditCardPayment> entityList = _groupRepository
  451. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  452. .Where(exp.ToExpression())
  453. .ToList();
  454. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  455. decimal CNY = 0;
  456. decimal PayCNY = 0;
  457. decimal BalanceCNY = 0;
  458. decimal YSFYCNY = 0;
  459. decimal USD = 0;
  460. decimal PayUSD = 0;
  461. decimal BalanceUSD = 0;
  462. decimal YSFYUSD = 0;
  463. decimal EUR = 0;
  464. decimal PayEUR = 0;
  465. decimal BalanceEUR = 0;
  466. decimal YSFYEUR = 0;
  467. foreach (var entity in entityList)
  468. {
  469. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  470. _detail.Id = entity.Id;
  471. /*
  472. * Bus名称
  473. */
  474. _detail.BusName = "";
  475. /*
  476. *费用所属
  477. */
  478. switch (entity.CTable)
  479. {
  480. case 85:
  481. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  482. if (jpRes != null)
  483. {
  484. string FlightsDescription = jpRes.FlightsDescription;
  485. string PriceDescription = jpRes.PriceDescription;
  486. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  487. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  488. }
  489. break;
  490. case 79:
  491. _detail.BusName = "待增加";
  492. break;
  493. case 98:
  494. Grp_DecreasePayments gdpRes = _groupRepository.Query<Grp_DecreasePayments>(s => s.Id == entity.CId).First();
  495. if (gdpRes != null)
  496. {
  497. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  498. _detail.PriceNameContent = gdpRes.PriceName;
  499. }
  500. break;
  501. default:
  502. break;
  503. }
  504. /*
  505. * 费用模块
  506. */
  507. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.CTable).First();
  508. if (sdPriceName != null)
  509. {
  510. _detail.PriceName = sdPriceName.Name;
  511. }
  512. /*
  513. * 应付款金额
  514. */
  515. Sys_SetData sdPaymentCurrency_WaitPay = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.PaymentCurrency).First();
  516. string PaymentCurrency_WaitPay = "Unknown";
  517. if (sdPaymentCurrency_WaitPay != null)
  518. {
  519. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  520. }
  521. _detail.WaitPay = entity.PayMoney.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  522. /*
  523. * 此次付款金额
  524. */
  525. decimal CurrPayStr = 0;
  526. if (entity.PayPercentage == 0)
  527. {
  528. if (entity.PayThenMoney != 0)
  529. CurrPayStr = entity.PayThenMoney * decimal.Parse(entity.DayRate);
  530. }
  531. else
  532. {
  533. CurrPayStr = entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * decimal.Parse(entity.DayRate));
  534. }
  535. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  536. /*
  537. * 剩余尾款
  538. */
  539. decimal BalanceStr = 0;
  540. if (entity.PayMoney - (CurrPayStr / decimal.Parse(entity.DayRate)) < 0.01M)
  541. BalanceStr = 0;
  542. else
  543. BalanceStr = (entity.PayMoney - CurrPayStr / decimal.Parse(entity.DayRate));
  544. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  545. /*
  546. * 申请人
  547. */
  548. string operatorName = "无";
  549. Sys_Users _opUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.CreateUserId).First();
  550. if (_opUser != null)
  551. {
  552. operatorName = _opUser.CnName;
  553. }
  554. _detail.OperatorName = operatorName;
  555. /*
  556. * 审核人
  557. */
  558. string auditOperatorName = "Unknown";
  559. if (entity.AuditGMOperate == 0)
  560. auditOperatorName = "无";
  561. else if (entity.AuditGMOperate == 4)
  562. auditOperatorName = "自动审核";
  563. else
  564. {
  565. Sys_Users _adUser = _groupRepository.Query<Sys_Users>(s => s.Id == entity.AuditGMOperate).First();
  566. if (_adUser != null)
  567. {
  568. auditOperatorName = _adUser.CnName;
  569. }
  570. }
  571. _detail.AuditOperatorName = auditOperatorName;
  572. /*
  573. *
  574. * *超预算比例
  575. */
  576. string overBudgetStr = "";
  577. if (entity.ExceedBudget == -1)
  578. overBudgetStr = sdPriceName.Name + "尚无预算";
  579. else if (entity.ExceedBudget == 0)
  580. overBudgetStr = "未超预算";
  581. else
  582. overBudgetStr = entity.ExceedBudget.ToString("P");
  583. _detail.OverBudget = overBudgetStr;
  584. /*
  585. * 费用总计
  586. */
  587. if (entity.PaymentCurrency == 48)
  588. {
  589. CNY += entity.PayMoney;
  590. PayCNY += CurrPayStr;
  591. BalanceCNY += BalanceStr;
  592. YSFYCNY += CurrPayStr;
  593. }
  594. if (entity.PaymentCurrency == 49)
  595. {
  596. USD += entity.PayMoney;
  597. PayUSD += CurrPayStr;
  598. BalanceUSD += BalanceStr;
  599. YSFYUSD += CurrPayStr;
  600. }
  601. if (entity.PaymentCurrency == 51)
  602. {
  603. EUR += entity.PayMoney;
  604. PayEUR += CurrPayStr;
  605. BalanceEUR += BalanceStr;
  606. YSFYEUR += CurrPayStr;
  607. }
  608. _detail.IsAuditGM = entity.IsAuditGM;
  609. detailList.Add(_detail);
  610. }
  611. #endregion
  612. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  613. _view.TotalStr1 = string.Format(@"应付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", CNY, USD, EUR);
  614. _view.TotalStr2 = string.Format(@"此次付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", PayCNY, PayUSD, PayEUR);
  615. _view.TotalStr3 = string.Format(@"目前剩余尾款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", BalanceCNY, BalanceUSD, BalanceEUR);
  616. _view.TotalStr4 = string.Format(@"已审费用总额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", YSFYCNY, YSFYUSD, YSFYEUR);
  617. return Ok(JsonView(_view));
  618. }
  619. /// <summary>
  620. /// 修改团组费用审核状态
  621. /// </summary>
  622. /// <param name="paras">参数Json字符串</param>
  623. /// <returns></returns>
  624. [HttpPost]
  625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  626. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  627. {
  628. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  629. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  630. DateTime dtNow = DateTime.Now;
  631. _groupRepository.BeginTran();
  632. int rst = 0;
  633. foreach (var item in idList)
  634. {
  635. int CreditId = int.Parse(item);
  636. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  637. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  638. .SetColumns(it => it.AuditGMOperate == _dto.User)
  639. .SetColumns(it => it.AuditGMDate == dtNow)
  640. .Where(s => s.Id == CreditId)
  641. .ExecuteCommandAsync();
  642. if (result < 1)
  643. {
  644. rst = -1;
  645. }
  646. else
  647. {
  648. _groupRepository.RollbackTran();
  649. return Ok(JsonView(false, "保存失败并回滚!"));
  650. }
  651. }
  652. _groupRepository.CommitTran();
  653. if (rst == 0)
  654. {
  655. return Ok(JsonView(true, "保存成功!"));
  656. }
  657. return Ok(JsonView(false, "保存失败!"));
  658. }
  659. #endregion
  660. #region 机票费用录入
  661. /// <summary>
  662. /// 机票录入当前登录人可操作团组
  663. /// </summary>
  664. /// <param name="dto"></param>
  665. /// <returns></returns>
  666. [HttpPost]
  667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  668. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  669. {
  670. try
  671. {
  672. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  673. if (groupData.Code != 0)
  674. {
  675. return Ok(JsonView(false, groupData.Msg));
  676. }
  677. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  678. }
  679. catch (Exception ex)
  680. {
  681. return Ok(JsonView(false, "程序错误!"));
  682. throw;
  683. }
  684. }
  685. /// <summary>
  686. /// 机票费用录入列表
  687. /// </summary>
  688. /// <param name="dto"></param>
  689. /// <returns></returns>
  690. [HttpPost]
  691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  692. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  693. {
  694. try
  695. {
  696. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  697. if (groupData.Code != 0)
  698. {
  699. return Ok(JsonView(false, groupData.Msg));
  700. }
  701. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  702. }
  703. catch (Exception ex)
  704. {
  705. return Ok(JsonView(false, "程序错误!"));
  706. throw;
  707. }
  708. }
  709. /// <summary>
  710. /// 根据id查询费用录入信息
  711. /// </summary>
  712. /// <param name="dto"></param>
  713. /// <returns></returns>
  714. [HttpPost]
  715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  716. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  717. {
  718. try
  719. {
  720. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  721. if (groupData.Code != 0)
  722. {
  723. return Ok(JsonView(false, groupData.Msg));
  724. }
  725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  726. }
  727. catch (Exception ex)
  728. {
  729. return Ok(JsonView(false, "程序错误!"));
  730. throw;
  731. }
  732. }
  733. /// <summary>
  734. /// 机票费用录入操作(Status:1.新增,2.修改)
  735. /// </summary>
  736. /// <param name="dto"></param>
  737. /// <returns></returns>
  738. [HttpPost]
  739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  740. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  741. {
  742. try
  743. {
  744. Result groupData = await _airTicketResRep.OpAirTicketRes(dto);
  745. if (groupData.Code != 0)
  746. {
  747. return Ok(JsonView(false, groupData.Msg));
  748. }
  749. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  750. }
  751. catch (Exception ex)
  752. {
  753. return Ok(JsonView(false, "程序错误!"));
  754. throw;
  755. }
  756. }
  757. /// <summary>
  758. /// 机票费用录入,删除
  759. /// </summary>
  760. /// <param name="dto"></param>
  761. /// <returns></returns>
  762. [HttpPost]
  763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  764. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  765. {
  766. try
  767. {
  768. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  769. if (!res)
  770. {
  771. return Ok(JsonView(false, "删除失败"));
  772. }
  773. return Ok(JsonView(true, "删除成功!"));
  774. }
  775. catch (Exception ex)
  776. {
  777. return Ok(JsonView(false, "程序错误!"));
  778. throw;
  779. }
  780. }
  781. /// <summary>
  782. /// 导出机票录入报表
  783. /// </summary>
  784. /// <param name="dto"></param>
  785. /// <returns></returns>
  786. [HttpPost]
  787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  788. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  789. {
  790. try
  791. {
  792. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  793. if (groupData.Code != 0)
  794. {
  795. return Ok(JsonView(false, groupData.Msg));
  796. }
  797. else
  798. {
  799. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  800. if (AirTicketReservations.Count != 0)
  801. {
  802. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  803. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  804. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  805. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  806. WorkbookDesigner designer = new WorkbookDesigner();
  807. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  808. decimal countCost = 0;
  809. foreach (var item in AirTicketReservations)
  810. {
  811. if (item.BankType == "其他")
  812. {
  813. item.BankNo = "--";
  814. }
  815. else
  816. {
  817. item.BankNo = item.BankType + ":" + item.BankNo.Substring(0, 3);
  818. }
  819. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  820. item.Price = System.Decimal.Round(item.Price, 2);
  821. countCost += Convert.ToDecimal(item.Price);
  822. }
  823. designer.SetDataSource("Export", AirTicketReservations);
  824. designer.SetDataSource("ExportDiCode", diCode);
  825. designer.SetDataSource("ExportDiName", diName);
  826. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  827. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  828. designer.Process();
  829. string fileName = "AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  830. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  831. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  832. return Ok(JsonView(true, "成功", url = rst));
  833. }
  834. else
  835. {
  836. return Ok(JsonView(false, "暂无数据!"));
  837. }
  838. }
  839. }
  840. catch (Exception ex)
  841. {
  842. return Ok(JsonView(false, "程序错误!"));
  843. throw;
  844. }
  845. }
  846. Dictionary<string, string> transDic = new Dictionary<string, string>();
  847. /// <summary>
  848. /// 行程单导出
  849. /// </summary>
  850. /// <param name="dto"></param>
  851. /// <returns></returns>
  852. [HttpPost]
  853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  854. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  855. {
  856. try
  857. {
  858. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  859. if (groupData.Code != 0)
  860. {
  861. return Ok(JsonView(false, groupData.Msg));
  862. }
  863. else
  864. {
  865. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  866. if (dto.Language == "CN")
  867. {
  868. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  869. DocumentBuilder builder = new DocumentBuilder(doc);
  870. int tableIndex = 0;//表格索引
  871. //得到文档中的第一个表格
  872. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  873. foreach (var item in _AirTicketReservations)
  874. {
  875. #region 处理固定数据
  876. string[] FlightsCode = item.FlightsCode.Split('/');
  877. if (FlightsCode.Length != 0)
  878. {
  879. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  880. if (_AirCompany != null)
  881. {
  882. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  883. }
  884. else
  885. {
  886. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  887. }
  888. }
  889. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  890. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  891. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  892. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  893. string name = "";
  894. foreach (string clientName in nameArray)
  895. {
  896. if (!name.Contains(clientName))
  897. {
  898. name += clientName + ",";
  899. }
  900. }
  901. if (!string.IsNullOrWhiteSpace(name))
  902. {
  903. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  904. }
  905. else
  906. {
  907. table.Range.Bookmarks["ClientName"].Text = "--";
  908. }
  909. table.Range.Bookmarks["TicketNumber"].Text = "--";
  910. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  911. table.Range.Bookmarks["JointTicket"].Text = "--";
  912. table.Range.Bookmarks["TimeIssue"].Text = "--";
  913. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  914. table.Range.Bookmarks["NavigationCode"].Text = "--";
  915. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  916. table.Range.Bookmarks["AgentPhone"].Text = "--";
  917. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  918. #endregion
  919. #region 循环数据处理
  920. List<AirInfo> airs = new List<AirInfo>();
  921. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  922. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  923. for (int i = 0; i < FlightsCode.Length; i++)
  924. {
  925. AirInfo air = new AirInfo();
  926. string[] tempstr = DayArray[i]
  927. .Replace("\r\n", string.Empty)
  928. .Replace("\\r\\n", string.Empty)
  929. .TrimStart().TrimEnd()
  930. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  931. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  932. string starCity = "";
  933. if (star_Three != null)
  934. {
  935. starCity = star_Three.AirPort;
  936. }
  937. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  938. string EndCity = "";
  939. if (End_Three != null)
  940. {
  941. EndCity = End_Three.AirPort;
  942. }
  943. air.Destination = starCity + "/" + EndCity;
  944. air.Flight = FlightsCode[i];
  945. air.SeatingClass = item.CTypeName;
  946. string dateTime = tempstr[2];
  947. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  948. air.FlightDate = DateTemp;
  949. air.DepartureTime = tempstr[5];
  950. air.LandingTime = tempstr[6];
  951. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  952. air.TicketStatus = "--";
  953. air.Luggage = "--";
  954. air.DepartureTerminal = "--";
  955. air.LandingTerminal = "--";
  956. airs.Add(air);
  957. }
  958. int row = 13;
  959. for (int i = 0; i < airs.Count; i++)
  960. {
  961. if (airs.Count > 2)
  962. {
  963. for (int j = 0; j < airs.Count - 2; j++)
  964. {
  965. var CopyRow = table.Rows[12].Clone(true);
  966. table.Rows.Add(CopyRow);
  967. }
  968. }
  969. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  970. int index = 0;
  971. foreach (PropertyInfo property in properties)
  972. {
  973. string value = property.GetValue(airs[i]).ToString();
  974. Cell ishcel0 = table.Rows[row].Cells[index];
  975. Paragraph p = new Paragraph(doc);
  976. string s = value;
  977. p.AppendChild(new Run(doc, s));
  978. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  979. ishcel0.AppendChild(p);
  980. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  981. index++;
  982. }
  983. row++;
  984. }
  985. #endregion
  986. Paragraph lastParagraph = new Paragraph(doc);
  987. //第一个表格末尾加段落
  988. table.ParentNode.InsertAfter(lastParagraph, table);
  989. //复制第一个表格
  990. Table cloneTable = (Table)table.Clone(true);
  991. //在文档末尾段落后面加入复制的表格
  992. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  993. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  994. {
  995. int rownewsIndex = 13;
  996. for (int i = 0; i < 2; i++)
  997. {
  998. var CopyRow = table.Rows[12].Clone(true);
  999. table.Rows.RemoveAt(13);
  1000. table.Rows.Add(CopyRow);
  1001. rownewsIndex++;
  1002. }
  1003. }
  1004. else
  1005. {
  1006. table.Rows.RemoveAt(12);
  1007. }
  1008. cloneTable.Rows.RemoveAt(12);
  1009. }
  1010. if (_AirTicketReservations.Count != 0)
  1011. {
  1012. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1013. if (FlightsCode.Length != 0)
  1014. {
  1015. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1016. if (_AirCompany != null)
  1017. {
  1018. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  1019. }
  1020. else
  1021. {
  1022. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1023. }
  1024. }
  1025. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1026. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1027. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1028. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1029. string name = "";
  1030. foreach (string clientName in nameArray)
  1031. {
  1032. if (!name.Contains(clientName))
  1033. {
  1034. name += clientName + ",";
  1035. }
  1036. }
  1037. if (!string.IsNullOrWhiteSpace(name))
  1038. {
  1039. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  1040. }
  1041. else
  1042. {
  1043. table.Range.Bookmarks["ClientName"].Text = "--";
  1044. }
  1045. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1046. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1047. table.Range.Bookmarks["JointTicket"].Text = "--";
  1048. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1049. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1050. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1051. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1052. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1053. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1054. }
  1055. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1056. //保存合并后的文档
  1057. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  1058. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1059. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1060. return Ok(JsonView(true, "成功!", rst));
  1061. }
  1062. else
  1063. {
  1064. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  1065. DocumentBuilder builder = new DocumentBuilder(doc);
  1066. int tableIndex = 0;//表格索引
  1067. //得到文档中的第一个表格
  1068. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  1069. List<string> texts = new List<string>();
  1070. foreach (var item in _AirTicketReservations)
  1071. {
  1072. string[] FlightsCode = item.FlightsCode.Split('/');
  1073. if (FlightsCode.Length != 0)
  1074. {
  1075. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1076. if (_AirCompany != null)
  1077. {
  1078. if (!transDic.ContainsKey(_AirCompany.CnName))
  1079. {
  1080. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  1081. }
  1082. }
  1083. else
  1084. {
  1085. if (!transDic.ContainsKey("--"))
  1086. {
  1087. transDic.Add("--", "--");
  1088. }
  1089. }
  1090. }
  1091. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1092. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1093. string name = "";
  1094. foreach (string clientName in nameArray)
  1095. {
  1096. name += clientName + ",";
  1097. }
  1098. if (!texts.Contains(name))
  1099. {
  1100. texts.Add(name);
  1101. }
  1102. List<AirInfo> airs = new List<AirInfo>();
  1103. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1104. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1105. for (int i = 0; i < FlightsCode.Length; i++)
  1106. {
  1107. AirInfo air = new AirInfo();
  1108. string[] tempstr = DayArray[i]
  1109. .Replace("\r\n", string.Empty)
  1110. .Replace("\\r\\n", string.Empty)
  1111. .TrimStart().TrimEnd()
  1112. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1113. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1114. if (star_Three != null)
  1115. {
  1116. if (!transDic.ContainsKey(star_Three.AirPort))
  1117. {
  1118. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  1119. }
  1120. }
  1121. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1122. if (End_Three != null)
  1123. {
  1124. if (!transDic.ContainsKey(End_Three.AirPort))
  1125. {
  1126. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  1127. }
  1128. }
  1129. if (!texts.Contains(item.CTypeName))
  1130. {
  1131. texts.Add(item.CTypeName);
  1132. }
  1133. }
  1134. }
  1135. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  1136. if (transData.Count > 0)
  1137. {
  1138. foreach (TranslateResult item in transData)
  1139. {
  1140. if (!transDic.ContainsKey(item.Query))
  1141. {
  1142. transDic.Add(item.Query, item.Translation);
  1143. }
  1144. }
  1145. }
  1146. foreach (var item in _AirTicketReservations)
  1147. {
  1148. #region 处理固定数据
  1149. string[] FlightsCode = item.FlightsCode.Split('/');
  1150. if (FlightsCode.Length != 0)
  1151. {
  1152. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1153. if (_AirCompany != null)
  1154. {
  1155. string str = "--";
  1156. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1157. if (!string.IsNullOrEmpty(translateResult))
  1158. {
  1159. str = translateResult;
  1160. str = _airTicketResRep.Processing(str);
  1161. }
  1162. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1163. }
  1164. else
  1165. {
  1166. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1167. }
  1168. }
  1169. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1170. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1171. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1172. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1173. string names = "";
  1174. foreach (string clientName in nameArray)
  1175. {
  1176. names += clientName + ",";
  1177. }
  1178. if (!string.IsNullOrWhiteSpace(names))
  1179. {
  1180. string str = "--";
  1181. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1182. if (!string.IsNullOrEmpty(translateResult))
  1183. {
  1184. str = translateResult;
  1185. str = _airTicketResRep.Processing(str);
  1186. }
  1187. table.Range.Bookmarks["ClientName"].Text = str;
  1188. }
  1189. else
  1190. {
  1191. table.Range.Bookmarks["ClientName"].Text = "--";
  1192. }
  1193. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1194. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1195. table.Range.Bookmarks["JointTicket"].Text = "--";
  1196. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1197. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1198. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1199. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1200. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1201. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1202. #endregion
  1203. #region 循环数据处理
  1204. List<AirInfo> airs = new List<AirInfo>();
  1205. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  1206. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  1207. for (int i = 0; i < FlightsCode.Length; i++)
  1208. {
  1209. AirInfo air = new AirInfo();
  1210. string[] tempstr = DayArray[i]
  1211. .Replace("\r\n", string.Empty)
  1212. .Replace("\\r\\n", string.Empty)
  1213. .TrimStart().TrimEnd()
  1214. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  1215. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  1216. string starCity = "";
  1217. if (star_Three != null)
  1218. {
  1219. string str2 = "--";
  1220. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  1221. if (!string.IsNullOrEmpty(translateResult2))
  1222. {
  1223. str2 = translateResult2;
  1224. str2 = _airTicketResRep.Processing(str2);
  1225. }
  1226. starCity = str2;
  1227. }
  1228. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  1229. string EndCity = "";
  1230. if (End_Three != null)
  1231. {
  1232. string str1 = "--";
  1233. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  1234. if (!string.IsNullOrEmpty(translateResult1))
  1235. {
  1236. str1 = translateResult1;
  1237. str1 = _airTicketResRep.Processing(str1);
  1238. }
  1239. EndCity = str1;
  1240. }
  1241. air.Destination = starCity + "/" + EndCity;
  1242. air.Flight = FlightsCode[i];
  1243. string str = "--";
  1244. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  1245. if (!string.IsNullOrEmpty(translateResult))
  1246. {
  1247. str = translateResult;
  1248. str = _airTicketResRep.Processing(str);
  1249. }
  1250. air.SeatingClass = str;
  1251. string dateTime = tempstr[2];
  1252. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  1253. air.FlightDate = DateTemp;
  1254. air.DepartureTime = tempstr[5];
  1255. air.LandingTime = tempstr[6];
  1256. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  1257. air.TicketStatus = "--";
  1258. air.Luggage = "--";
  1259. air.DepartureTerminal = "--";
  1260. air.LandingTerminal = "--";
  1261. airs.Add(air);
  1262. }
  1263. int row = 13;
  1264. for (int i = 0; i < airs.Count; i++)
  1265. {
  1266. if (airs.Count > 2)
  1267. {
  1268. for (int j = 0; j < airs.Count - 2; j++)
  1269. {
  1270. var CopyRow = table.Rows[12].Clone(true);
  1271. table.Rows.Add(CopyRow);
  1272. }
  1273. }
  1274. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  1275. int index = 0;
  1276. foreach (PropertyInfo property in properties)
  1277. {
  1278. string value = property.GetValue(airs[i]).ToString();
  1279. Cell ishcel0 = table.Rows[row].Cells[index];
  1280. Paragraph p = new Paragraph(doc);
  1281. string s = value;
  1282. p.AppendChild(new Run(doc, s));
  1283. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  1284. ishcel0.AppendChild(p);
  1285. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  1286. //ishcel0.CellFormat.VerticalAlignment=
  1287. index++;
  1288. }
  1289. row++;
  1290. }
  1291. #endregion
  1292. Paragraph lastParagraph = new Paragraph(doc);
  1293. //第一个表格末尾加段落
  1294. table.ParentNode.InsertAfter(lastParagraph, table);
  1295. //复制第一个表格
  1296. Table cloneTable = (Table)table.Clone(true);
  1297. //在文档末尾段落后面加入复制的表格
  1298. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  1299. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  1300. {
  1301. int rownewsIndex = 13;
  1302. for (int i = 0; i < 2; i++)
  1303. {
  1304. var CopyRow = table.Rows[12].Clone(true);
  1305. table.Rows.RemoveAt(13);
  1306. table.Rows.Add(CopyRow);
  1307. rownewsIndex++;
  1308. }
  1309. }
  1310. else
  1311. {
  1312. table.Rows.RemoveAt(12);
  1313. }
  1314. cloneTable.Rows.RemoveAt(12);
  1315. }
  1316. if (_AirTicketReservations.Count != 0)
  1317. {
  1318. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  1319. if (FlightsCode.Length != 0)
  1320. {
  1321. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  1322. if (_AirCompany != null)
  1323. {
  1324. string str = "--";
  1325. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  1326. if (!string.IsNullOrEmpty(translateResult))
  1327. {
  1328. str = translateResult;
  1329. str = _airTicketResRep.Processing(str);
  1330. }
  1331. table.Range.Bookmarks["AirlineCompany"].Text = str;
  1332. }
  1333. else
  1334. {
  1335. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  1336. }
  1337. }
  1338. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  1339. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  1340. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  1341. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  1342. string names = "";
  1343. foreach (string clientName in nameArray)
  1344. {
  1345. names += clientName + ",";
  1346. }
  1347. if (!string.IsNullOrWhiteSpace(names))
  1348. {
  1349. string str = "--";
  1350. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  1351. if (!string.IsNullOrEmpty(translateResult))
  1352. {
  1353. str = translateResult;
  1354. str = _airTicketResRep.Processing(str);
  1355. }
  1356. table.Range.Bookmarks["ClientName"].Text = str;
  1357. }
  1358. else
  1359. {
  1360. table.Range.Bookmarks["ClientName"].Text = "--";
  1361. }
  1362. table.Range.Bookmarks["TicketNumber"].Text = "--";
  1363. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  1364. table.Range.Bookmarks["JointTicket"].Text = "--";
  1365. table.Range.Bookmarks["TimeIssue"].Text = "--";
  1366. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  1367. table.Range.Bookmarks["NavigationCode"].Text = "--";
  1368. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  1369. table.Range.Bookmarks["AgentPhone"].Text = "--";
  1370. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  1371. }
  1372. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  1373. //保存合并后的文档
  1374. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  1375. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  1376. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  1377. return Ok(JsonView(true, "成功!", rst));
  1378. }
  1379. }
  1380. }
  1381. catch (Exception ex)
  1382. {
  1383. return Ok(JsonView(false, "程序错误!"));
  1384. throw;
  1385. }
  1386. }
  1387. #endregion
  1388. #region 团组增减款项
  1389. /// <summary>
  1390. /// 团组增减款项下拉框绑定
  1391. /// </summary>
  1392. /// <param name="dto"></param>
  1393. /// <returns></returns>
  1394. [HttpPost]
  1395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1396. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  1397. {
  1398. try
  1399. {
  1400. Result groupData = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
  1401. if (groupData.Code != 0)
  1402. {
  1403. return Ok(JsonView(false, groupData.Msg));
  1404. }
  1405. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1406. }
  1407. catch (Exception ex)
  1408. {
  1409. return Ok(JsonView(false, "程序错误!"));
  1410. throw;
  1411. }
  1412. }
  1413. /// <summary>
  1414. /// 根据团组Id查询团组增减款项
  1415. /// </summary>
  1416. /// <param name="dto"></param>
  1417. /// <returns></returns>
  1418. [HttpPost]
  1419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1420. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  1421. {
  1422. try
  1423. {
  1424. Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
  1425. if (groupData.Code != 0)
  1426. {
  1427. return Ok(JsonView(false, groupData.Msg));
  1428. }
  1429. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1430. }
  1431. catch (Exception ex)
  1432. {
  1433. return Ok(JsonView(false, "程序错误!"));
  1434. throw;
  1435. }
  1436. }
  1437. /// <summary>
  1438. /// 团组增减款项操作(Status:1.新增,2.修改)
  1439. /// </summary>
  1440. /// <param name="dto"></param>
  1441. /// <returns></returns>
  1442. [HttpPost]
  1443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1444. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  1445. {
  1446. try
  1447. {
  1448. Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  1449. if (groupData.Code != 0)
  1450. {
  1451. return Ok(JsonView(false, groupData.Msg));
  1452. }
  1453. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1454. }
  1455. catch (Exception ex)
  1456. {
  1457. return Ok(JsonView(false, "程序错误!"));
  1458. throw;
  1459. }
  1460. }
  1461. /// <summary>
  1462. /// 团组增减款项操作 删除
  1463. /// </summary>
  1464. /// <param name="dto"></param>
  1465. /// <returns></returns>
  1466. [HttpPost]
  1467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1468. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  1469. {
  1470. try
  1471. {
  1472. var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
  1473. if (!res)
  1474. {
  1475. return Ok(JsonView(false, "删除失败"));
  1476. }
  1477. return Ok(JsonView(true, "删除成功!"));
  1478. }
  1479. catch (Exception ex)
  1480. {
  1481. return Ok(JsonView(false, "程序错误!"));
  1482. throw;
  1483. }
  1484. }
  1485. /// <summary>
  1486. /// 根据团组增减款项Id查询
  1487. /// </summary>
  1488. /// <param name="dto"></param>
  1489. /// <returns></returns>
  1490. [HttpPost]
  1491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1492. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  1493. {
  1494. try
  1495. {
  1496. Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
  1497. if (groupData.Code != 0)
  1498. {
  1499. return Ok(JsonView(false, groupData.Msg));
  1500. }
  1501. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1502. }
  1503. catch (Exception ex)
  1504. {
  1505. return Ok(JsonView(false, "程序错误!"));
  1506. throw;
  1507. }
  1508. }
  1509. /// <summary>
  1510. /// region 文件上传 可以带参数
  1511. /// </summary>
  1512. /// <param name="file"></param>
  1513. /// <returns></returns>
  1514. [HttpPost]
  1515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1516. public async Task<IActionResult> UploadProject(IFormFile file)
  1517. {
  1518. try
  1519. {
  1520. if (file != null)
  1521. {
  1522. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1523. if (!Directory.Exists(fileDir))
  1524. {
  1525. Directory.CreateDirectory(fileDir);
  1526. }
  1527. //文件名称
  1528. string projectFileName = file.FileName;
  1529. //上传的文件的路径
  1530. string filePath = fileDir + $@"\{projectFileName}";
  1531. using (FileStream fs = System.IO.File.Create(filePath))
  1532. {
  1533. file.CopyTo(fs);
  1534. fs.Flush();
  1535. }
  1536. return Ok(JsonView(true, "上传成功!", projectFileName));
  1537. }
  1538. else
  1539. {
  1540. return Ok(JsonView(false, "上传失败!"));
  1541. }
  1542. }
  1543. catch (Exception ex)
  1544. {
  1545. return Ok(JsonView(false, "程序错误!"));
  1546. throw;
  1547. }
  1548. }
  1549. /// <summary>
  1550. /// 删除指定文件
  1551. /// </summary>
  1552. /// <param name="dto"></param>
  1553. /// <returns></returns>
  1554. [HttpPost]
  1555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1556. public async Task<IActionResult> DelFile(DelFileDto dto)
  1557. {
  1558. try
  1559. {
  1560. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  1561. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  1562. string filePath = fileDir+ dto.fileName;
  1563. // 删除该文件
  1564. System.IO.File.Delete(filePath);
  1565. int id= await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments {FilePath="" }).ExecuteCommandAsync();
  1566. if (id!=0)
  1567. {
  1568. return Ok(JsonView(true, "成功!"));
  1569. }
  1570. else
  1571. {
  1572. return Ok(JsonView(false, "失败!"));
  1573. }
  1574. }
  1575. catch (Exception ex)
  1576. {
  1577. return Ok(JsonView(false, "程序错误!"));
  1578. throw;
  1579. }
  1580. }
  1581. #endregion
  1582. #region 商邀费用录入
  1583. /// <summary>
  1584. /// 根据团组Id查询商邀费用列表
  1585. /// </summary>
  1586. /// <param name="dto"></param>
  1587. /// <returns></returns>
  1588. [HttpPost]
  1589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1590. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  1591. {
  1592. try
  1593. {
  1594. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  1595. if (groupData.Code != 0)
  1596. {
  1597. return Ok(JsonView(false, groupData.Msg));
  1598. }
  1599. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1600. }
  1601. catch (Exception ex)
  1602. {
  1603. return Ok(JsonView(false, "程序错误!"));
  1604. throw;
  1605. }
  1606. }
  1607. /// <summary>
  1608. /// 根据商邀费用ID查询C表和商邀费用数据
  1609. /// </summary>
  1610. /// <param name="dto"></param>
  1611. /// <returns></returns>
  1612. [HttpPost]
  1613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1614. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  1615. {
  1616. try
  1617. {
  1618. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  1619. if (groupData.Code != 0)
  1620. {
  1621. return Ok(JsonView(false, groupData.Msg));
  1622. }
  1623. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1624. }
  1625. catch (Exception ex)
  1626. {
  1627. return Ok(JsonView(false, "程序错误!"));
  1628. throw;
  1629. }
  1630. }
  1631. #endregion
  1632. }
  1633. }