123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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<ITrunkLineApi> _trunkLineApis;
- private readonly ILadingTrunkLineService _ladingTrunkLineService;
- public LadingTrunkLineController(IEnumerable<ITrunkLineApi> trunkLineApis, ILadingTrunkLineService ladingTrunkLineService)
- {
- _trunkLineApis = trunkLineApis;
- _ladingTrunkLineService = ladingTrunkLineService;
- }
- [HttpPost]
- public async Task<IActionResult> EditTrunkLinePager(Logistics_TrunkLine model)
- {
- await _ladingTrunkLineService.EditTrunkLinePager(model);
- return Ok();
- }
- [HttpPost]
- public async Task<IActionResult> GetTrunkLinePager(QueryModel queryModel)
- {
- var result = await _ladingTrunkLineService.GetTrunkLinePager(queryModel);
- return Ok(result);
- }
- [HttpGet]
- public async Task<IActionResult> GetTrunkLineInfo(int id)
- {
- var result = await _ladingTrunkLineService.GetTrunkLineInfo(id);
- return Ok(result);
- }
- [HttpGet]
- public async Task<IActionResult> DeleteTrunkLineInfo(int id)
- {
- var result = await _ladingTrunkLineService.DeleteTrunkLineInfo(id);
- return Ok(result);
- }
- #region 菜鸟干线推送信息
- [HttpGet]
- public async Task<IActionResult> CNDeliveryPush(int id)
- {
- List<int> channelIds = new List<int>() { 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<IActionResult> CNArrivePush(int id)
- {
- List<int> channelIds = new List<int>() { 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
- }
- }
|