LadingTrunkLineController.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using Microsoft.AspNetCore.Mvc;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using XYY.Common.Standard;
  6. using XYY.Core.Standard.Mvc;
  7. using XYY.Model.Standard;
  8. using XYY.Model.Standard.Order;
  9. using XYY.Service.Standard.ChannelApi.Base;
  10. using XYY.Service.Standard.Order;
  11. namespace XYY.Api.Order.Controllers
  12. {
  13. [Route("api/[controller]/[action]")]
  14. [ApiController]
  15. public class LadingTrunkLineController : ApiControllerBase
  16. {
  17. private IEnumerable<ITrunkLineApi> _trunkLineApis;
  18. private readonly ILadingTrunkLineService _ladingTrunkLineService;
  19. public LadingTrunkLineController(IEnumerable<ITrunkLineApi> trunkLineApis, ILadingTrunkLineService ladingTrunkLineService)
  20. {
  21. _trunkLineApis = trunkLineApis;
  22. _ladingTrunkLineService = ladingTrunkLineService;
  23. }
  24. [HttpPost]
  25. public async Task<IActionResult> EditTrunkLinePager(Logistics_TrunkLine model)
  26. {
  27. await _ladingTrunkLineService.EditTrunkLinePager(model);
  28. return Ok();
  29. }
  30. [HttpPost]
  31. public async Task<IActionResult> GetTrunkLinePager(QueryModel queryModel)
  32. {
  33. var result = await _ladingTrunkLineService.GetTrunkLinePager(queryModel);
  34. return Ok(result);
  35. }
  36. [HttpGet]
  37. public async Task<IActionResult> GetTrunkLineInfo(int id)
  38. {
  39. var result = await _ladingTrunkLineService.GetTrunkLineInfo(id);
  40. return Ok(result);
  41. }
  42. [HttpGet]
  43. public async Task<IActionResult> DeleteTrunkLineInfo(int id)
  44. {
  45. var result = await _ladingTrunkLineService.DeleteTrunkLineInfo(id);
  46. return Ok(result);
  47. }
  48. #region 菜鸟干线推送信息
  49. [HttpGet]
  50. public async Task<IActionResult> CNDeliveryPush(int id)
  51. {
  52. List<int> channelIds = new List<int>() { 536,
  53. 537,
  54. 538,
  55. 539,
  56. 540,
  57. 549,
  58. 550,
  59. 565,
  60. 571,
  61. 572,
  62. 573,700,574};
  63. var data = await _ladingTrunkLineService.GetTrunkLinePushInfo(id, channelIds);
  64. var baseApi = _trunkLineApis.Where(x => x.ServiceName == data.Channel.ServiceCode).FirstOrDefault();
  65. try
  66. {
  67. var resultData = await baseApi.DeliveryPush(data);
  68. if (resultData.IsSuccess)
  69. {
  70. data.TrunkLine.DeliveryPushStatus = PushStatusEnum.Success;
  71. data.TrunkLine.ErrorMessage = "";
  72. }
  73. else
  74. {
  75. data.TrunkLine.DeliveryPushStatus = PushStatusEnum.Fail;
  76. data.TrunkLine.ErrorMessage = resultData.ErrorMsg;
  77. }
  78. }
  79. catch (System.Exception ex)
  80. {
  81. data.TrunkLine.DeliveryPushStatus = PushStatusEnum.Fail;
  82. data.TrunkLine.ErrorMessage = ex.Message;
  83. }
  84. await _ladingTrunkLineService.EditTrunkLinePager(data.TrunkLine);
  85. return Ok();
  86. }
  87. [HttpGet]
  88. public async Task<IActionResult> CNArrivePush(int id)
  89. {
  90. List<int> channelIds = new List<int>() { 536,
  91. 537,
  92. 538,
  93. 539,
  94. 540,
  95. 549,
  96. 550,
  97. 565,
  98. 571,
  99. 572,
  100. 573,700,574 };
  101. var data = await _ladingTrunkLineService.GetTrunkLinePushInfo(id, channelIds);
  102. var baseApi = _trunkLineApis.Where(x => x.ServiceName == data.Channel.ServiceCode).FirstOrDefault();
  103. try
  104. {
  105. var resultData = await baseApi.ArrivePush(data);
  106. if (resultData.IsSuccess)
  107. {
  108. data.TrunkLine.ArrivePushStatus = PushStatusEnum.Success;
  109. data.TrunkLine.ErrorMessage = "";
  110. }
  111. else
  112. {
  113. data.TrunkLine.ArrivePushStatus = PushStatusEnum.Fail;
  114. data.TrunkLine.ErrorMessage = resultData.ErrorMsg;
  115. }
  116. }
  117. catch (System.Exception ex)
  118. {
  119. data.TrunkLine.ArrivePushStatus = PushStatusEnum.Fail;
  120. data.TrunkLine.ErrorMessage = ex.Message;
  121. }
  122. await _ladingTrunkLineService.EditTrunkLinePager(data.TrunkLine);
  123. return Ok();
  124. }
  125. #endregion
  126. }
  127. }