InputMoreThanOneTicketOrdersController.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Linq;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System.Threading.Tasks;
  4. using XYY.Api.Order.Model.Order;
  5. using XYY.Core.Standard.Mvc;
  6. using XYY.Service.Standard.Order;
  7. using XYY.TaskTrack.Standard;
  8. using XYY.Model.Standard.MpsOrder;
  9. using XYY.Authentication.Standard;
  10. namespace XYY.Api.Order.Controllers
  11. {
  12. [Route("api/[controller]/[action]")]
  13. [ApiController]
  14. public class InputMoreThanOneTicketOrdersController : ControllerBase
  15. {
  16. IMoreThanOneTicketService orderService;
  17. private IMQManager _MQManager;
  18. public InputMoreThanOneTicketOrdersController(IMoreThanOneTicketService orderService, IMQManager mQManager)
  19. {
  20. this.orderService = orderService;
  21. _MQManager = mQManager;
  22. }
  23. [HttpPost]
  24. public async Task<ApiJsonModel> Post([FromBody] PostInputMoreThanOneTicketOrdersRequest postInputMoreThanOneTicketOrdersRequest)
  25. {
  26. var u = User.GetUserContent();
  27. int customerId = User.GetUserContent().CustomerId;
  28. if (customerId == 0)
  29. throw new System.Exception("未传入客户编号");
  30. var list = await this.orderService.LoadData(postInputMoreThanOneTicketOrdersRequest.FileUrl, customerId);
  31. var errorList = list.Where(x => !string.IsNullOrEmpty(x.Remark));
  32. if (errorList.Count() > 0)
  33. throw new System.Exception(string.Join(",", errorList.Select(x => x.Remark)));
  34. await this.orderService.SaveMpsData(list, postInputMoreThanOneTicketOrdersRequest.FileUrl);
  35. await this.orderService.AddDraftOrderData(list);
  36. foreach (var item in list)
  37. {
  38. await _MQManager.Publish(new OrderMpsOrderSubModel { Order = item });
  39. }
  40. return ApiJsonModel.OK();
  41. }
  42. }
  43. }