using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using XYY.Common.Standard; using XYY.Core.Standard.Mvc; using XYY.Model.Standard; using XYY.Model.Standard.Order; using XYY.Service.Standard.ChannelApi.Base; using XYY.Service.Standard.Order; namespace XYY.Api.Order.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class LadingTrunkLineController : ApiControllerBase { private IEnumerable _trunkLineApis; private readonly ILadingTrunkLineService _ladingTrunkLineService; public LadingTrunkLineController(IEnumerable trunkLineApis, ILadingTrunkLineService ladingTrunkLineService) { _trunkLineApis = trunkLineApis; _ladingTrunkLineService = ladingTrunkLineService; } [HttpPost] public async Task EditTrunkLinePager(Logistics_TrunkLine model) { await _ladingTrunkLineService.EditTrunkLinePager(model); return Ok(); } [HttpPost] public async Task GetTrunkLinePager(QueryModel queryModel) { var result = await _ladingTrunkLineService.GetTrunkLinePager(queryModel); return Ok(result); } [HttpGet] public async Task GetTrunkLineInfo(int id) { var result = await _ladingTrunkLineService.GetTrunkLineInfo(id); return Ok(result); } [HttpGet] public async Task DeleteTrunkLineInfo(int id) { var result = await _ladingTrunkLineService.DeleteTrunkLineInfo(id); return Ok(result); } #region 菜鸟干线推送信息 [HttpGet] public async Task CNDeliveryPush(int id) { List channelIds = new List() { 536, 537, 538, 539, 540, 549, 550, 565, 571, 572, 573,700,574}; var data = await _ladingTrunkLineService.GetTrunkLinePushInfo(id, channelIds); var baseApi = _trunkLineApis.Where(x => x.ServiceName == data.Channel.ServiceCode).FirstOrDefault(); try { var resultData = await baseApi.DeliveryPush(data); if (resultData.IsSuccess) { data.TrunkLine.DeliveryPushStatus = PushStatusEnum.Success; data.TrunkLine.ErrorMessage = ""; } else { data.TrunkLine.DeliveryPushStatus = PushStatusEnum.Fail; data.TrunkLine.ErrorMessage = resultData.ErrorMsg; } } catch (System.Exception ex) { data.TrunkLine.DeliveryPushStatus = PushStatusEnum.Fail; data.TrunkLine.ErrorMessage = ex.Message; } await _ladingTrunkLineService.EditTrunkLinePager(data.TrunkLine); return Ok(); } [HttpGet] public async Task CNArrivePush(int id) { List channelIds = new List() { 536, 537, 538, 539, 540, 549, 550, 565, 571, 572, 573,700,574 }; var data = await _ladingTrunkLineService.GetTrunkLinePushInfo(id, channelIds); var baseApi = _trunkLineApis.Where(x => x.ServiceName == data.Channel.ServiceCode).FirstOrDefault(); try { var resultData = await baseApi.ArrivePush(data); if (resultData.IsSuccess) { data.TrunkLine.ArrivePushStatus = PushStatusEnum.Success; data.TrunkLine.ErrorMessage = ""; } else { data.TrunkLine.ArrivePushStatus = PushStatusEnum.Fail; data.TrunkLine.ErrorMessage = resultData.ErrorMsg; } } catch (System.Exception ex) { data.TrunkLine.ArrivePushStatus = PushStatusEnum.Fail; data.TrunkLine.ErrorMessage = ex.Message; } await _ladingTrunkLineService.EditTrunkLinePager(data.TrunkLine); return Ok(); } #endregion } }