GroupsController.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. using Microsoft.AspNetCore.Mvc;
  2. using Newtonsoft.Json.Serialization;
  3. using OASystem.API.OAMethodLib;
  4. using OASystem.Domain.Dtos.Groups;
  5. using OASystem.Domain.Entities.Business;
  6. using OASystem.Domain.Entities.Groups;
  7. using OASystem.Domain.ViewModels.Groups;
  8. using OASystem.Infrastructure.Repositories.Groups;
  9. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  10. namespace OASystem.API.Controllers
  11. {
  12. /// <summary>
  13. /// 团组相关
  14. /// </summary>
  15. //[Authorize]
  16. [Route("api/[controller]/[action]")]
  17. public class GroupsController : ControllerBase
  18. {
  19. private readonly GrpScheduleRepository _grpScheduleRep;
  20. private readonly IMapper _mapper;
  21. private readonly DelegationInfoRepository _groupRepository;
  22. private readonly TaskAssignmentRepository _taskAssignmentRep;
  23. private readonly AirTicketResRepository _airTicketResRep;
  24. public GroupsController(IMapper mapper, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository, TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep)
  25. {
  26. _mapper = mapper;
  27. _grpScheduleRep = grpScheduleRep;
  28. _groupRepository = groupRepository;
  29. _taskAssignmentRep = taskAssignmentRep;
  30. _airTicketResRep = airTicketResRep;
  31. }
  32. #region 流程管控
  33. /// <summary>
  34. /// 获取团组流程管控信息
  35. /// </summary>
  36. /// <param name="paras">参数Json字符串</param>
  37. /// <returns></returns>
  38. [HttpPost]
  39. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  40. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  41. {
  42. if (string.IsNullOrEmpty(_jsonDto.Paras))
  43. {
  44. return Ok(JsonView(false, "参数为空"));
  45. }
  46. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  47. if (_ScheduleDto != null)
  48. {
  49. if (_ScheduleDto.SearchType == 2)//获取列表
  50. {
  51. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  52. return Ok(JsonView(_grpScheduleViewList));
  53. }
  54. else//获取对象
  55. {
  56. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  57. if (_grpScheduleView != null)
  58. {
  59. return Ok(JsonView(_grpScheduleView));
  60. }
  61. }
  62. }
  63. else
  64. {
  65. return Ok(JsonView(false, "参数反序列化失败"));
  66. }
  67. return Ok(JsonView(false, "暂无数据!"));
  68. }
  69. /// <summary>
  70. /// 修改团组流程管控详细表数据
  71. /// </summary>
  72. /// <param name="paras"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  76. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  77. {
  78. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  79. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  80. .SetColumns(it => it.Duty == _detail.Duty)
  81. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  82. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  83. .SetColumns(it => it.JobContent == _detail.JobContent)
  84. .SetColumns(it => it.Remark == _detail.Remark)
  85. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  86. .Where(s => s.Id == dto.Id)
  87. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  88. .ExecuteCommandAsync();
  89. if (result > 0)
  90. {
  91. return Ok(JsonView(true, "保存成功!"));
  92. }
  93. return Ok(JsonView(false, "保存失败!"));
  94. }
  95. /// <summary>
  96. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  97. /// </summary>
  98. /// <param name="dto"></param>
  99. /// <returns></returns>
  100. [HttpPost]
  101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  102. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  103. {
  104. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  105. _detail.IsDel = 1;
  106. _detail.DeleteUserId = dto.Duty;
  107. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  108. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  109. .SetColumns(it => it.IsDel == _detail.IsDel)
  110. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  111. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  112. .Where(it => it.Id == dto.Id)
  113. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  114. //.WhereColumns(s => s.Id == dto.Id)
  115. .ExecuteCommandAsync();
  116. if (result > 0)
  117. {
  118. return Ok(JsonView(true, "删除成功!"));
  119. }
  120. return Ok(JsonView(false, "删除失败!"));
  121. }
  122. /// <summary>
  123. /// 增加团组流程管控详细表数据
  124. /// </summary>
  125. /// <param name="dto"></param>
  126. /// <returns></returns>
  127. [HttpPost]
  128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  129. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  130. {
  131. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  132. if (DateTime.Now < _detail.ExpectBeginDt)
  133. {
  134. _detail.StepStatus = 0;
  135. }
  136. else
  137. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  138. _detail.StepStatus = 1;
  139. }
  140. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  141. if (result > 0)
  142. {
  143. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  144. return Ok(JsonView(true, "添加成功!", _result));
  145. }
  146. return Ok(JsonView(false, "添加失败!"));
  147. }
  148. #endregion
  149. #region 团组基本信息
  150. /// <summary>
  151. /// 接团信息列表
  152. /// </summary>
  153. /// <param name="dto">团组列表请求dto</param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  157. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  158. {
  159. var groupData = await _groupRepository.GetGroupList(dto);
  160. if (groupData.Code != 0)
  161. {
  162. return Ok(JsonView(false, groupData.Msg));
  163. }
  164. return Ok(JsonView(groupData.Data));
  165. }
  166. /// <summary>
  167. /// 接团信息详情
  168. /// </summary>
  169. /// <param name="dto">团组info请求dto</param>
  170. /// <returns></returns>
  171. [HttpPost]
  172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  173. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  174. {
  175. var groupData = await _groupRepository.GetGroupInfo(dto);
  176. if (groupData.Code != 0)
  177. {
  178. return Ok(JsonView(false, groupData.Msg));
  179. }
  180. return Ok(JsonView(groupData.Data));
  181. }
  182. /// <summary>
  183. /// 接团信息 编辑添加
  184. /// 基础信息数据源
  185. /// </summary>
  186. /// <param name="dto"></param>
  187. /// <returns></returns>
  188. [HttpPost]
  189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  190. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  191. {
  192. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  193. if (groupData.Code != 0)
  194. {
  195. return Ok(JsonView(false, groupData.Msg));
  196. }
  197. return Ok(JsonView(groupData.Data));
  198. }
  199. /// <summary>
  200. /// 接团信息 操作(增改)
  201. /// </summary>
  202. /// <param name="dto"></param>
  203. /// <returns></returns>
  204. [HttpPost]
  205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  206. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  207. {
  208. try
  209. {
  210. var groupData = await _groupRepository.GroupOperation(dto);
  211. if (groupData.Code != 0)
  212. {
  213. return Ok(JsonView(false, groupData.Msg));
  214. }
  215. return Ok(JsonView(true));
  216. }
  217. catch (Exception ex)
  218. {
  219. Logs("[response]" + JsonConvert.SerializeObject(dto));
  220. Logs(ex.Message);
  221. return Ok(JsonView(false, ex.Message));
  222. }
  223. }
  224. /// <summary>
  225. /// 接团信息 操作(删除)
  226. /// </summary>
  227. /// <param name="dto"></param>
  228. /// <returns></returns>
  229. [HttpPost]
  230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  231. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  232. {
  233. try
  234. {
  235. var groupData = await _groupRepository.GroupDel(dto);
  236. if (groupData.Code != 0)
  237. {
  238. return Ok(JsonView(false, groupData.Msg));
  239. }
  240. return Ok(JsonView(true));
  241. }
  242. catch (Exception ex)
  243. {
  244. Logs("[response]" + JsonConvert.SerializeObject(dto));
  245. Logs(ex.Message);
  246. return Ok(JsonView(false, ex.Message));
  247. }
  248. }
  249. /// <summary>
  250. /// 获取团组销售报价号
  251. /// 团组添加时 使用
  252. /// </summary>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<IActionResult> GetGroupSalesQuoteNo()
  257. {
  258. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  259. if (groupData.Code != 0)
  260. {
  261. return Ok(JsonView(false, groupData.Msg));
  262. }
  263. object salesQuoteNo = new
  264. {
  265. SalesQuoteNo = groupData.Data
  266. };
  267. return Ok(JsonView(salesQuoteNo));
  268. }
  269. /// <summary>
  270. /// 设置确认出团
  271. /// </summary>
  272. /// <param name="dto"></param>
  273. /// <returns></returns>
  274. [HttpPost]
  275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  276. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  277. {
  278. var groupData = await _groupRepository.ConfirmationGroup(dto);
  279. if (groupData.Code != 0)
  280. {
  281. return Ok(JsonView(false, groupData.Msg));
  282. }
  283. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  284. return Ok(JsonView(groupData.Data));
  285. }
  286. /// <summary>
  287. /// 获取团组名称 List
  288. /// </summary>
  289. /// <param name="dto"></param>
  290. /// <returns></returns>
  291. [HttpPost]
  292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  293. public async Task<IActionResult> GetGroupNameList(GroupNameDto dto)
  294. {
  295. var groupData = await _groupRepository.GetGroupNameList(dto);
  296. if (groupData.Code != 0)
  297. {
  298. return Ok(JsonView(false, groupData.Msg));
  299. }
  300. return Ok(JsonView(groupData.Data, groupData.Data.Count));
  301. }
  302. /// <summary>
  303. /// 获取团组名称data And 签证国别Data
  304. /// </summary>
  305. /// <param name="dto"></param>
  306. /// <returns></returns>
  307. [HttpPost]
  308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  309. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  310. {
  311. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  312. if (groupData.Code != 0)
  313. {
  314. return Ok(JsonView(false, groupData.Msg));
  315. }
  316. return Ok(JsonView(groupData.Data));
  317. }
  318. #endregion
  319. #region 团组&签证
  320. /// <summary>
  321. /// 根据团组Id获取签证客户信息List
  322. /// </summary>
  323. /// <param name="dto">请求dto</param>
  324. /// <returns></returns>
  325. [HttpPost]
  326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  327. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  328. {
  329. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  330. if (groupData.Code != 0)
  331. {
  332. return Ok(JsonView(false, groupData.Msg));
  333. }
  334. return Ok(JsonView(groupData.Data));
  335. }
  336. #endregion
  337. #region 团组任务分配
  338. /// <summary>
  339. /// 团组任务分配初始化
  340. /// </summary>
  341. /// <param name="dto"></param>
  342. /// <returns></returns>
  343. [HttpPost]
  344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  345. public async Task<IActionResult> GetTaskAssignmen()
  346. {
  347. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  348. if (groupData.Code != 0)
  349. {
  350. return Ok(JsonView(false, groupData.Msg));
  351. }
  352. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  353. }
  354. /// <summary>
  355. /// 团组任务分配查询
  356. /// </summary>
  357. /// <param name="dto"></param>
  358. /// <returns></returns>
  359. [HttpPost]
  360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  361. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  362. {
  363. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  364. if (groupData.Code != 0)
  365. {
  366. return Ok(JsonView(false, groupData.Msg));
  367. }
  368. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  369. }
  370. /// <summary>
  371. /// 团组任务分配操作
  372. /// </summary>
  373. /// <param name="dto"></param>
  374. /// <returns></returns>
  375. [HttpPost]
  376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  377. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  378. {
  379. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  380. if (groupData.Code != 0)
  381. {
  382. return Ok(JsonView(false, groupData.Msg));
  383. }
  384. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  385. }
  386. #endregion
  387. #region 团组费用审核
  388. /// <summary>
  389. /// 获取团组费用审核
  390. /// </summary>
  391. /// <param name="paras">参数Json字符串</param>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  395. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  396. {
  397. if (_dto.DiId < 1)
  398. {
  399. return Ok(JsonView(false, "团组Id为空"));
  400. }
  401. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  402. #region 团组基本信息
  403. Grp_DelegationInfo _delegation = _groupRepository.Query<Grp_DelegationInfo>(s => s.Id == _dto.DiId).First();
  404. if (_delegation != null)
  405. {
  406. _view.ClientName = _delegation.ClientName;
  407. _view.DiId = _dto.DiId;
  408. _view.TeamName = _delegation.TeamName;
  409. _view.VisitCountry = _delegation.VisitCountry;
  410. _view.VisitDate = _delegation.VisitStartDate.ToString("yyyy-MM-dd") + " ~ " + _delegation.VisitEndDate.ToString("yyyy-MM-dd");
  411. _view.VisitDays = _delegation.VisitDays;
  412. _view.VisitPNumber = _delegation.VisitPNumber;
  413. }
  414. else
  415. {
  416. return Ok(JsonView(false, "团组信息为空"));
  417. }
  418. #endregion
  419. #region 费用清单
  420. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  421. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  422. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  423. //缺少IF的语法糖 CTable
  424. List<Grp_CreditCardPayment> entityList = _groupRepository
  425. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  426. .Where(exp.ToExpression())
  427. .ToList();
  428. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  429. decimal CNY = 0;
  430. decimal PayCNY = 0;
  431. decimal BalanceCNY = 0;
  432. decimal YSFYCNY = 0;
  433. decimal USD = 0;
  434. decimal PayUSD = 0;
  435. decimal BalanceUSD = 0;
  436. decimal YSFYUSD = 0;
  437. decimal EUR = 0;
  438. decimal PayEUR = 0;
  439. decimal BalanceEUR = 0;
  440. decimal YSFYEUR = 0;
  441. foreach (var entity in entityList)
  442. {
  443. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  444. if (entity.CTable != 85) continue;
  445. /*
  446. * Bus名称
  447. */
  448. _detail.BusName = "";
  449. /*
  450. *费用所属
  451. */
  452. switch (entity.CTable)
  453. {
  454. case 85:
  455. Grp_AirTicketReservations jpRes = _groupRepository.Query<Grp_AirTicketReservations>(s => s.Id == entity.CId).First();
  456. if (jpRes != null)
  457. {
  458. string FlightsDescription = jpRes.FlightsDescription;
  459. string PriceDescription = jpRes.PriceDescription;
  460. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  461. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  462. }
  463. break;
  464. case 79:
  465. _detail.BusName = "待增加";
  466. break;
  467. default:
  468. break;
  469. }
  470. /*
  471. * 费用模块
  472. */
  473. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.CTable).First();
  474. if (sdPriceName != null)
  475. {
  476. _detail.PriceName = sdPriceName.Name;
  477. }
  478. /*
  479. * 应付款金额
  480. */
  481. Sys_SetData sdPaymentCurrency_WaitPay = _groupRepository.Query<Sys_SetData>(s => s.Id == entity.PaymentCurrency).First();
  482. string PaymentCurrency_WaitPay = "Unknown";
  483. if (sdPaymentCurrency_WaitPay != null)
  484. {
  485. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  486. }
  487. _detail.WaitPay = entity.PayMoney.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  488. /*
  489. * 此次付款金额
  490. */
  491. decimal CurrPayStr = 0;
  492. if (entity.PayPercentage == 0)
  493. {
  494. if (entity.PayThenMoney != 0)
  495. CurrPayStr = entity.PayThenMoney * decimal.Parse(entity.DayRate);
  496. }
  497. else
  498. {
  499. CurrPayStr = entity.PayMoney * (decimal.Parse(entity.PayPercentage.ToString("#0.00")) / 100 * decimal.Parse(entity.DayRate));
  500. }
  501. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  502. /*
  503. * 剩余尾款
  504. */
  505. decimal BalanceStr = 0;
  506. if (entity.PayMoney - (CurrPayStr / decimal.Parse(entity.DayRate)) < 0.01M)
  507. BalanceStr = 0;
  508. else
  509. BalanceStr = (entity.PayMoney - CurrPayStr / decimal.Parse(entity.DayRate));
  510. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  511. /*
  512. * 申请人
  513. */
  514. string operatorName = "无";
  515. Sys_Users _opUser = _groupRepository.Query<Sys_Users>(s => s.CreateUserId == entity.CreateUserId).First();
  516. if (_opUser != null)
  517. {
  518. operatorName = _opUser.CnName;
  519. }
  520. _detail.OperatorName = operatorName;
  521. /*
  522. * 审核人
  523. */
  524. string auditOperatorName = "Unknown";
  525. if (entity.AuditGMOperate == 0)
  526. auditOperatorName = "无";
  527. else if (entity.AuditGMOperate == 4)
  528. auditOperatorName = "自动审核";
  529. else
  530. {
  531. Sys_Users _adUser = _groupRepository.Query<Sys_Users>(s => s.CreateUserId == entity.AuditGMOperate).First();
  532. if (_adUser != null)
  533. {
  534. auditOperatorName = _adUser.CnName;
  535. }
  536. }
  537. _detail.AuditOperatorName = auditOperatorName;
  538. /*
  539. *
  540. * *超预算比例
  541. */
  542. string overBudgetStr = "";
  543. if (entity.ExceedBudget == -1)
  544. overBudgetStr = sdPriceName.Name + "尚无预算";
  545. else if (entity.ExceedBudget == 0)
  546. overBudgetStr = "未超预算";
  547. else
  548. overBudgetStr = entity.ExceedBudget.ToString("P");
  549. _detail.OverBudget = overBudgetStr;
  550. /*
  551. * 费用总计
  552. */
  553. if (entity.PaymentCurrency == 48)
  554. {
  555. CNY += entity.PayMoney;
  556. PayCNY += CurrPayStr;
  557. BalanceCNY += BalanceStr;
  558. YSFYCNY += CurrPayStr;
  559. }
  560. if (entity.PaymentCurrency == 49)
  561. {
  562. USD += entity.PayMoney;
  563. PayUSD += CurrPayStr;
  564. BalanceUSD += BalanceStr;
  565. YSFYUSD += CurrPayStr;
  566. }
  567. if (entity.PaymentCurrency == 51)
  568. {
  569. EUR += entity.PayMoney;
  570. PayEUR += CurrPayStr;
  571. BalanceEUR += BalanceStr;
  572. YSFYEUR += CurrPayStr;
  573. }
  574. _detail.TotalStr1 = string.Format(@"应付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", CNY, USD, EUR);
  575. _detail.TotalStr2 = string.Format(@"此次付款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", PayCNY, PayUSD, PayEUR);
  576. _detail.TotalStr3 = string.Format(@"目前剩余尾款总金额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", BalanceCNY, BalanceUSD, BalanceEUR);
  577. _detail.TotalStr4 = string.Format(@"已审费用总额:{0}CNY&nbsp;|&nbsp;{1}USD&nbsp;|&nbsp;{2}EUR", YSFYCNY, YSFYUSD, YSFYEUR);
  578. detailList.Add(_detail);
  579. }
  580. #endregion
  581. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  582. return Ok(JsonView(_view));
  583. }
  584. /// <summary>
  585. /// 修改团组费用审核状态
  586. /// </summary>
  587. /// <param name="paras">参数Json字符串</param>
  588. /// <returns></returns>
  589. [HttpPost]
  590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  591. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  592. {
  593. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  594. DateTime dtNow = DateTime.Now;
  595. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  596. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  597. .SetColumns(it => it.AuditGMOperate == _dto.User)
  598. .SetColumns(it => it.AuditGMDate == dtNow)
  599. .Where(s => s.Id == _dto.CreditId)
  600. .ExecuteCommandAsync();
  601. if (result > 0)
  602. {
  603. return Ok(JsonView(true, "保存成功!"));
  604. }
  605. return Ok(JsonView(false, "保存失败!"));
  606. }
  607. #endregion
  608. #region 机票费用录入
  609. /// <summary>
  610. /// 机票录入当前登录人可操作团组
  611. /// </summary>
  612. /// <param name="dto"></param>
  613. /// <returns></returns>
  614. [HttpPost]
  615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  616. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  617. {
  618. try
  619. {
  620. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  621. if (groupData.Code != 0)
  622. {
  623. return Ok(JsonView(false, groupData.Msg));
  624. }
  625. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  626. }
  627. catch (Exception ex)
  628. {
  629. return Ok(JsonView(false, "程序错误!"));
  630. throw;
  631. }
  632. }
  633. /// <summary>
  634. /// 机票费用录入列表
  635. /// </summary>
  636. /// <param name="dto"></param>
  637. /// <returns></returns>
  638. [HttpPost]
  639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  640. public async Task<IActionResult> AirTicketResList(AirTicketResListDto dto)
  641. {
  642. try
  643. {
  644. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  645. if (groupData.Code != 0)
  646. {
  647. return Ok(JsonView(false, groupData.Msg));
  648. }
  649. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  650. }
  651. catch (Exception ex)
  652. {
  653. return Ok(JsonView(false, "程序错误!"));
  654. throw;
  655. }
  656. }
  657. #endregion
  658. }
  659. }