From e126c6c0ff0221e8b7025282d362bfdfeb52428b Mon Sep 17 00:00:00 2001 From: chfei Date: Thu, 24 Sep 2026 09:42:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E7=89=A9=E6=B5=81=E8=AE=A2=E5=8D=95=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apis/VirtualLogisticsApi.cs | 30 ++++++++++++++++++- .../Controllers/LogisticsController.cs | 22 ++++++++++++-- .../Dtos/OrderStatusRequest.cs | 14 +++++++++ .../Models/OrderStatusQuery.cs | 22 ++++++++++++++ .../Services/VirtualLogisticsService.cs | 5 ++++ test/WebServiceTest/GiftLogisticsTest.cs | 13 ++++++-- 6 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 Store.SyncLogistics/Dtos/OrderStatusRequest.cs diff --git a/Store.SyncLogistics/Apis/VirtualLogisticsApi.cs b/Store.SyncLogistics/Apis/VirtualLogisticsApi.cs index b7c8c8f..b3f95ec 100644 --- a/Store.SyncLogistics/Apis/VirtualLogisticsApi.cs +++ b/Store.SyncLogistics/Apis/VirtualLogisticsApi.cs @@ -147,6 +147,34 @@ public class VirtualLogisticsApi : ISingletonDependency }); } + /// + /// 查询快递订单信息及状态 + /// + public Result> GetOrderStatus(string[] orders) + { + var res = ServerRequest>(new HttpItem + { + URL = "/api/lipin/status", + Postdata = JsonConvert.SerializeObject(new + { + show_delivery = 1, + order_sn = orders + }), + Method = MethodType.Post + }); + + var ret = new Result>() + { + Code = res.Code, + Success = res.Success, + Msg = res.Msg, + }; + if (res.Success) + { + ret.Data = res.Data.Values.ToList(); + } + return ret; + } @@ -165,7 +193,7 @@ public class VirtualLogisticsApi : ISingletonDependency } item.Encoding = Encoding.UTF8; - item.ProxyIp = "127.0.0.1:8080"; + //item.ProxyIp = "127.0.0.1:8080"; long unix = DateHelper.GetCurrentUnixTimestampInSeconds(); diff --git a/Store.SyncLogistics/Controllers/LogisticsController.cs b/Store.SyncLogistics/Controllers/LogisticsController.cs index 3ad5178..308393f 100644 --- a/Store.SyncLogistics/Controllers/LogisticsController.cs +++ b/Store.SyncLogistics/Controllers/LogisticsController.cs @@ -131,12 +131,30 @@ public class LogisticsController : ApiControllerBase return Ok(ApiResult.Fail(ex.Message)); } } + //[HttpPost] + //public IHttpActionResult GetSyncLogistics(string orderId) + //{ + // try + // { + // var result = _logisticsService.GetSyncLogistics(orderId); + // return Ok(ApiResult.Success(result)); + // } + // catch (Exception ex) + // { + // return Ok(ApiResult.Fail(ex.Message)); + // } + //} + /// + /// 查询订单中状态 + /// + /// + /// [HttpPost] - public IHttpActionResult GetSyncLogistics(string orderId) + public IHttpActionResult GetOrderStatus(string orderId) { try { - var result = _logisticsService.GetSyncLogistics(orderId); + var result = _logisticsService.GetOrderStatus([orderId]); return Ok(ApiResult.Success(result)); } catch (Exception ex) diff --git a/Store.SyncLogistics/Dtos/OrderStatusRequest.cs b/Store.SyncLogistics/Dtos/OrderStatusRequest.cs new file mode 100644 index 0000000..f00564f --- /dev/null +++ b/Store.SyncLogistics/Dtos/OrderStatusRequest.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json; +using Store.Framework.Dtos; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Store.SyncLogistics.Dtos; + +public class OrderStatusRequest : SignRequestBase +{ + public string[] Orders { get; set; } +} diff --git a/Store.SyncLogistics/Models/OrderStatusQuery.cs b/Store.SyncLogistics/Models/OrderStatusQuery.cs index 2672367..f8da0cd 100644 --- a/Store.SyncLogistics/Models/OrderStatusQuery.cs +++ b/Store.SyncLogistics/Models/OrderStatusQuery.cs @@ -42,4 +42,26 @@ public class OrderStatusResultItem /// public string Status { get; set; } public decimal Price { get; set; } + + + /// + /// 店铺订单号 + /// + public string ShopOrder { get; set; } + + + /// + /// 提示信息 + /// + public string Msg { get; set; } + + /// + /// 发货状态:0:无需发货,1:未发货,2:已发货,3:处理中,4:发货失败 + /// + public string DeliveryStatus { get; set; } + + /// + /// 发货结果描述 + /// + public string DeliveryResult { get; set; } } \ No newline at end of file diff --git a/Store.SyncLogistics/Services/VirtualLogisticsService.cs b/Store.SyncLogistics/Services/VirtualLogisticsService.cs index 1c3196d..e61301f 100644 --- a/Store.SyncLogistics/Services/VirtualLogisticsService.cs +++ b/Store.SyncLogistics/Services/VirtualLogisticsService.cs @@ -236,4 +236,9 @@ public class VirtualLogisticsService : ITransientDependency return item; } + public List GetOrderStatus(string[] orders) + { + return _api.GetOrderStatus(orders).Data; + } + } diff --git a/test/WebServiceTest/GiftLogisticsTest.cs b/test/WebServiceTest/GiftLogisticsTest.cs index 1ea91ca..4ada594 100644 --- a/test/WebServiceTest/GiftLogisticsTest.cs +++ b/test/WebServiceTest/GiftLogisticsTest.cs @@ -4,6 +4,7 @@ using KJD_Web; using KJD_Web.Services.Users; using MAX.Core.Cryptography; using MAX.Core.Helpers; +using Org.BouncyCastle.Ocsp; using Store.Framework.DependencyInjection; using Store.VirtualLogistics.Apis; using Store.VirtualLogistics.Models; @@ -96,7 +97,7 @@ internal class GiftLogisticsTest public void BuyTest() { var logisticsService = _container.Resolve(); - var ret = logisticsService.Buy("15222220006","260923-573109716621688", "4439363558732480512"); + var ret = logisticsService.Buy("15222220006", "260923-573109716621688", "4439363558732480512"); if (ret != null) { Console.WriteLine(string.Join(" ", ret.Select(a => $"{a.OrderId}:{a.TrackingNumber}"))); @@ -117,10 +118,18 @@ internal class GiftLogisticsTest } }; var logisticsService = _container.Resolve(); - var ret = logisticsService.UploadPickup("15222220006","260923-573109716621688","1-2-3"); + var ret = logisticsService.UploadPickup("15222220006", "260923-573109716621688", "1-2-3"); if (ret) { } } + + [Test] + public void GetOrderStatus() + { + var logisticsService = _container.Resolve(); + var data = logisticsService.GetOrderStatus(["260923-573109716621688"]); + Console.WriteLine(string.Join(" ", data.Select(a => $"{a.OrderSn}:{a.ShopOrder}:{a.DeliveryStatus}"))); + } }