using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using XYY.Authentication.Standard; using XYY.Common.Standard; using XYY.Core.Standard.Mvc; using XYY.Model.Standard.Dto.MpsOrder; using XYY.Model.Standard.MpsOrder; using XYY.Service.Standard.Order; namespace XYY.Api.Order.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class GetMoreThanOneTicketMpsController : ApiControllerBase { IMoreThanOneTicketService orderService; public GetMoreThanOneTicketMpsController(IMoreThanOneTicketService orderService) { this.orderService = orderService; } [HttpGet] public async Task> Get([FromQuery] int orderId, [FromQuery] int draftOrderId) { var result = await this.orderService.Get(orderId, draftOrderId); return ApiJsonModel.OK(result); } [HttpPost] public async Task ConfirmCustomerOrderReceipt(ConfirmCustomerOrderReceiptInput data) { var result = await orderService.ConfirmCustomerOrderReceipt(data); return Ok(result); } [HttpPost] public async Task ModifyCreateOrderChannelId(MpsModifyCreateOrderChannelId mpsModify) { var u = User.GetUserContent(); await orderService.ModifyCreateOrderChannelId(mpsModify, u); return Ok(); } public async Task CustomerOrderOut(string InputNumber, int opStatus) { var result = await orderService.CustomerOrderOut(InputNumber, opStatus); return Ok(result); } public async Task BoxStatusOp(int boxId, BoxStatus boxStatus) { await orderService.BoxStatusOp(boxId, boxStatus); return Ok(); } public class OutBoxDataInfo { public string orderIds { get; set; } } [AllowAnonymous] public async Task OutBoxData(OutBoxDataInfo dataInfo) { if (string.IsNullOrEmpty(dataInfo.orderIds)) throw new Exception("请传入需要下单的订单ID"); var u = User.GetUserContent(); byte[] data = await orderService.OutBoxInfo(dataInfo.orderIds.SplitToArray(), u.Roles.Contains("FBA末端重量查看")); return File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); } [HttpPost] public async Task UpdateMpsOrder(UpdateMpsOrderInfo updateMpsOrderInfo) { await orderService.UpdateMpsOrder(updateMpsOrderInfo); return Ok(); } [AllowAnonymous] [HttpPost] public async Task OutMpsOrderData(OutBoxDataInfo dataInfo) { if (string.IsNullOrEmpty(dataInfo.orderIds)) throw new Exception("请传入需要下单的订单ID"); byte[] data = await orderService.OutMpsOrderData(dataInfo.orderIds.SplitToArray()); return File(data, "application/x-zip-compressed"); } /// /// 导入箱子信息 /// /// [HttpPost] public async Task ImportMpsBoxInfo() { var filelist = (await Request.ReadFormAsync()).Files; if (filelist != null && filelist.Count > 0) { var u = User.GetUserContent(); string userName = u.NiceName; if (!u.Roles.Contains("FBA末端重量修改")) { throw new Exception("抱歉,您无权限进行此操作!"); } var file = filelist[0]; var result = await orderService.ImportMpsBoxInfo(file.OpenReadStream(), userName); return Ok(result); } else { return Error("请上传一个文件"); } } /// /// 导入末端订单信息 /// /// [HttpPost] public async Task ImportFBAChannelOrder() { var filelist = (await Request.ReadFormAsync()).Files; if (filelist != null && filelist.Count > 0) { var u = User.GetUserContent(); string userName = u.NiceName; if (!u.Roles.Contains("FBA末端重量修改")) { throw new Exception("抱歉,您无权限进行此操作!"); } var file = filelist[0]; var result = await orderService.ImportFBAChannelOrder(file.OpenReadStream()); return Ok(result); } else { return Error("请上传一个文件"); } } [AllowAnonymous] [HttpPost] public async Task Recalculate663Billing() { await orderService.RecalculateBilling(); return Ok(); } [AllowAnonymous] [HttpPost] public async Task RecalculateCustomerFee() { await orderService.RecalculateCustomerFee(); return Ok(); } } }