FrayunController.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using iTextSharp.text;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System;
  4. using System.Threading.Tasks;
  5. using XYY.Core.Standard.Mvc;
  6. using XYY.Data.Standard.Channel;
  7. using XYY.Data.Standard.Order;
  8. using XYY.Model.Standard.Channel;
  9. namespace XYY.Api.Order.Controllers
  10. {
  11. [Route("api/[controller]/[action]")]
  12. [ApiController]
  13. public class FrayunController : ApiControllerBase
  14. {
  15. IFrayunRepository frayunRepository;
  16. IOrderRepository orderRepository;
  17. ILogistics_ChannelRepository logistics_ChannelRepository;
  18. public FrayunController(IFrayunRepository frayunRepository, IOrderRepository orderRepository, ILogistics_ChannelRepository logistics_ChannelRepository)
  19. {
  20. this.frayunRepository = frayunRepository;
  21. this.orderRepository = orderRepository;
  22. this.logistics_ChannelRepository = logistics_ChannelRepository;
  23. }
  24. public async Task<IActionResult> GetCancelOrders(DateTime dateTime)
  25. {
  26. var list = await this.frayunRepository.GetOrders(dateTime.ToString_yyyyMMdd());
  27. return Ok(list);
  28. }
  29. public async Task<IActionResult> CancelOrder(string orderId)
  30. {
  31. var channel = await logistics_ChannelRepository.GetAsync(237);
  32. XYY.Service.Standard.ChannelApi.Frayun.Api api = new Service.Standard.ChannelApi.Frayun.Api(orderRepository);
  33. var model = new XYY.Model.Standard.Channel.logistics_ChannelCancel
  34. {
  35. ApiHost = channel.ApiHost,
  36. ApiSecret = channel.ApiSecret,
  37. ApiKey = channel.ApiKey,
  38. ServiceCode = channel.ServiceCode,
  39. SystemNo = orderId
  40. };
  41. api.CannelOrdersByModel(model);
  42. if (model.ResultState == ResultStateEnum.成功.GetValue())
  43. {
  44. return Ok();
  45. }
  46. else
  47. {
  48. return Error(model.ResultMessage);
  49. }
  50. }
  51. }
  52. }