GetMoreThanOneTicketMpsController.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using XYY.Authentication.Standard;
  8. using XYY.Common.Standard;
  9. using XYY.Core.Standard.Mvc;
  10. using XYY.Model.Standard.Dto.MpsOrder;
  11. using XYY.Model.Standard.MpsOrder;
  12. using XYY.Service.Standard.Order;
  13. namespace XYY.Api.Order.Controllers
  14. {
  15. [Route("api/[controller]/[action]")]
  16. [ApiController]
  17. public class GetMoreThanOneTicketMpsController : ApiControllerBase
  18. {
  19. IMoreThanOneTicketService orderService;
  20. public GetMoreThanOneTicketMpsController(IMoreThanOneTicketService orderService)
  21. {
  22. this.orderService = orderService;
  23. }
  24. [HttpGet]
  25. public async Task<ApiJsonModel<Order_MpsOrder>> Get([FromQuery] int orderId, [FromQuery] int draftOrderId)
  26. {
  27. var result = await this.orderService.Get(orderId, draftOrderId);
  28. return ApiJsonModel<Order_MpsOrder>.OK(result);
  29. }
  30. [HttpPost]
  31. public async Task<IActionResult> ConfirmCustomerOrderReceipt(ConfirmCustomerOrderReceiptInput data)
  32. {
  33. var result = await orderService.ConfirmCustomerOrderReceipt(data);
  34. return Ok(result);
  35. }
  36. [HttpPost]
  37. public async Task<IActionResult> ModifyCreateOrderChannelId(MpsModifyCreateOrderChannelId mpsModify)
  38. {
  39. var u = User.GetUserContent();
  40. await orderService.ModifyCreateOrderChannelId(mpsModify, u);
  41. return Ok();
  42. }
  43. public async Task<IActionResult> CustomerOrderOut(string InputNumber, int opStatus)
  44. {
  45. var result = await orderService.CustomerOrderOut(InputNumber, opStatus);
  46. return Ok(result);
  47. }
  48. public async Task<IActionResult> BoxStatusOp(int boxId, BoxStatus boxStatus)
  49. {
  50. await orderService.BoxStatusOp(boxId, boxStatus);
  51. return Ok();
  52. }
  53. public class OutBoxDataInfo
  54. {
  55. public string orderIds
  56. {
  57. get; set;
  58. }
  59. }
  60. [AllowAnonymous]
  61. public async Task<IActionResult> OutBoxData(OutBoxDataInfo dataInfo)
  62. {
  63. if (string.IsNullOrEmpty(dataInfo.orderIds))
  64. throw new Exception("请传入需要下单的订单ID");
  65. var u = User.GetUserContent();
  66. byte[] data = await orderService.OutBoxInfo(dataInfo.orderIds.SplitToArray<int>(), u.Roles.Contains("FBA末端重量查看"));
  67. return File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
  68. }
  69. [HttpPost]
  70. public async Task<IActionResult> UpdateMpsOrder(UpdateMpsOrderInfo updateMpsOrderInfo)
  71. {
  72. await orderService.UpdateMpsOrder(updateMpsOrderInfo);
  73. return Ok();
  74. }
  75. [AllowAnonymous]
  76. [HttpPost]
  77. public async Task<IActionResult> OutMpsOrderData(OutBoxDataInfo dataInfo)
  78. {
  79. if (string.IsNullOrEmpty(dataInfo.orderIds))
  80. throw new Exception("请传入需要下单的订单ID");
  81. byte[] data = await orderService.OutMpsOrderData(dataInfo.orderIds.SplitToArray<int>());
  82. return File(data, "application/x-zip-compressed");
  83. }
  84. /// <summary>
  85. /// 导入箱子信息
  86. /// </summary>
  87. /// <returns></returns>
  88. [HttpPost]
  89. public async Task<IActionResult> ImportMpsBoxInfo()
  90. {
  91. var filelist = (await Request.ReadFormAsync()).Files;
  92. if (filelist != null && filelist.Count > 0)
  93. {
  94. var u = User.GetUserContent();
  95. string userName = u.NiceName;
  96. if (!u.Roles.Contains("FBA末端重量修改")) { throw new Exception("抱歉,您无权限进行此操作!"); }
  97. var file = filelist[0];
  98. var result = await orderService.ImportMpsBoxInfo(file.OpenReadStream(), userName);
  99. return Ok(result);
  100. }
  101. else
  102. {
  103. return Error("请上传一个文件");
  104. }
  105. }
  106. /// <summary>
  107. /// 导入末端订单信息
  108. /// </summary>
  109. /// <returns></returns>
  110. [HttpPost]
  111. public async Task<IActionResult> ImportFBAChannelOrder()
  112. {
  113. var filelist = (await Request.ReadFormAsync()).Files;
  114. if (filelist != null && filelist.Count > 0)
  115. {
  116. var u = User.GetUserContent();
  117. string userName = u.NiceName;
  118. if (!u.Roles.Contains("FBA末端重量修改")) { throw new Exception("抱歉,您无权限进行此操作!"); }
  119. var file = filelist[0];
  120. var result = await orderService.ImportFBAChannelOrder(file.OpenReadStream());
  121. return Ok(result);
  122. }
  123. else
  124. {
  125. return Error("请上传一个文件");
  126. }
  127. }
  128. [AllowAnonymous]
  129. [HttpPost]
  130. public async Task<IActionResult> Recalculate663Billing()
  131. {
  132. await orderService.RecalculateBilling();
  133. return Ok();
  134. }
  135. [AllowAnonymous]
  136. [HttpPost]
  137. public async Task<IActionResult> RecalculateCustomerFee()
  138. {
  139. await orderService.RecalculateCustomerFee();
  140. return Ok();
  141. }
  142. }
  143. }