Bitzsoft.Integrations.Express 1.0.0-alpha.10

This is a prerelease version of Bitzsoft.Integrations.Express.
dotnet add package Bitzsoft.Integrations.Express --version 1.0.0-alpha.10
                    
NuGet\Install-Package Bitzsoft.Integrations.Express -Version 1.0.0-alpha.10
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.Express" Version="1.0.0-alpha.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.Express" Version="1.0.0-alpha.10" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.Express" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.Express --version 1.0.0-alpha.10
                    
#r "nuget: Bitzsoft.Integrations.Express, 1.0.0-alpha.10"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.Express@1.0.0-alpha.10
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.Express&version=1.0.0-alpha.10&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.Express&version=1.0.0-alpha.10&prerelease
                    
Install as a Cake Tool

Bitzsoft.Integrations.Express

快递物流服务抽象层 -- 统一接口定义与基础模型,屏蔽各快递供应商 API 差异。

功能特性

  • 统一的 IExpressProvider 接口,封装轨迹查询、订阅推送、寄件下单、运费查询、电子面单、单号识别等核心操作
  • 独立的 ISfLegalDocumentProvider 接口,面向顺丰函证通法律函件寄递场景
  • 统一快递公司编码枚举(ExpressCarrierCode),各供应商内部维护平台编码到此枚举的映射
  • 物流状态 ExpressTrackingState、法律函件状态 LegalDocumentStatus 统一枚举
  • 不可变模型设计,所有属性使用 init 访问器
  • ExpressException 统一异常,携带供应商名称与错误码,便于上层处理

安装

.NET CLI

dotnet add package Bitzsoft.Integrations.Express

PackageReference

<PackageReference Include="Bitzsoft.Integrations.Express" Version="1.0.0" />

配置

本包为纯抽象层,不包含具体供应商配置,也不涉及 appsettings.json。请将各实现包(如 Express.Kdniao)注册到 DI 容器后,通过依赖注入消费 IExpressProvider

注册服务

本包不提供 DI 扩展方法。请使用具体实现包的 AddBitzsoft* 方法注册服务,或直接使用聚合包 Express.All 一键注册全部供应商。

// 以快递鸟为例(实现包提供注册扩展)
using Bitzsoft.Integrations.Express.Kdniao;

builder.Services.AddBitzsoftKdniaoExpress(
    builder.Configuration.GetSection("Express:Kdniao"));

使用示例

物流轨迹查询

using Bitzsoft.Integrations.Express.Interfaces;
using Bitzsoft.Integrations.Express.Models;

public class TrackingService
{
    private readonly IExpressProvider _express;

    public TrackingService(IExpressProvider express) => _express = express;

    public async Task ShowTrackingAsync(string trackingNumber)
    {
        // 查询单个运单轨迹(carrierCode 可选,部分供应商支持自动识别)
        ExpressTrackingInfo info = await _express.TrackAsync(trackingNumber);

        Console.WriteLine($"运单号: {info.TrackingNumber}");
        Console.WriteLine($"状态: {info.State}");

        // 轨迹按时间倒序排列
        foreach (var step in info.Traces)
        {
            Console.WriteLine($"[{step.Time:yyyy-MM-dd HH:mm}] {step.Location} {step.Description}");
        }
    }

    public async Task BatchTrackAsync(IEnumerable<string> numbers)
    {
        // 批量查询
        IReadOnlyList<ExpressTrackingInfo> results =
            await _express.BatchTrackAsync(numbers);
    }
}

单号识别快递公司

ExpressCarrierInfo carrier = await _express.DetectCarrierAsync("SF1234567890");
Console.WriteLine($"{carrier.CarrierName}(统一编码 {carrier.UnifiedCode},置信度 {carrier.Confidence})");

法律函件寄递(顺丰函证通)

using Bitzsoft.Integrations.Express.Interfaces;

public class LegalService
{
    private readonly ISfLegalDocumentProvider _legal;

    public LegalService(ISfLegalDocumentProvider legal) => _legal = legal;

    public async Task TrackDocumentAsync(string documentId)
    {
        LegalDocumentTrackingResult result =
            await _legal.TrackDocumentAsync(documentId);

        Console.WriteLine($"函件 {result.DocumentId} 当前状态: {result.Status}");
    }
}

核心类型一览

接口

类型 说明
IExpressProvider 通用物流操作统一契约(轨迹 / 订阅 / 寄件 / 运费 / 面单 / 识别)
ISfLegalDocumentProvider 顺丰函证通法律函件寄递契约(创建 / 追踪 / 签收 / 全流程记录)

IExpressProvider 方法

方法 说明
TrackAsync 实时查询运单物流轨迹
BatchTrackAsync 批量查询多个运单
SubscribeAsync 订阅运单号,状态变更时推送
CreateShipmentAsync 创建寄件订单
CancelShipmentAsync 取消寄件订单
GetQuoteAsync 查询预估运费和送达时效
GenerateWaybillAsync 生成电子面单
DetectCarrierAsync 根据单号自动识别快递公司

ISfLegalDocumentProvider 方法

方法 说明
CreateDocumentShipmentAsync 创建法律函件寄递任务
TrackDocumentAsync 查询法律函件寄递状态
ConfirmReceiptAsync 确认函件签收
GetFullRecordAsync 获取函件寄递全流程记录

模型

类型 说明
ExpressTrackingInfo 物流轨迹查询结果(TrackingNumber / CarrierCode / State / Traces / RawResponse)
ExpressTraceStep 单条物流轨迹(Description / Time / Location)
ExpressShipmentOrder 寄件下单请求(Sender / Receiver / CarrierCode / Weight / Extra)
ExpressShipmentResult 寄件下单结果(OrderId / TrackingNumber / EstimatedCost)
ExpressQuoteRequest 运费查询请求(Sender / Receiver / Weight / Quantity)
ExpressQuoteResult 运费查询结果(CarrierCode / EstimatedCost / EstimatedDeliveryTime)
ExpressCarrierInfo 快递公司识别结果(CarrierCode / UnifiedCode / Confidence)
ExpressWaybillResult 电子面单结果(TrackingNumber / HtmlContent / PdfBase64)
ExpressSubscriptionResult 订阅结果(Success / SubscriptionId / FailureReason)
ExpressContact 快递联系人信息(Name / Phone / Province / City / Address)
LegalDocumentShipmentRequest 法律函件寄递请求(DocumentType / Title / CaseNumber)
LegalDocumentShipmentResult 法律函件寄递结果(DocumentId / TrackingNumber / Status)
LegalDocumentTrackingResult 法律函件追踪结果(Status / Traces / SignedTime / SignedBy)
LegalDocumentFullRecord 法律函件全流程记录(DocumentType / Status / CreatedTime / SentTime)

枚举

类型 说明
ExpressTrackingState 物流状态(NoInfo / PickedUp / InTransit / Delivered / Exception)
ExpressCarrierCode 统一快递公司编码(SF / YTO / ZTO / STO / YD / HTKY / JTSD / EMS / ChinaPost / JD / DBL ...)
LegalDocumentStatus 法律函件状态(Created / Pending / Sent / InTransit / Signed / Rejected / Returned / Exception)

异常

类型 说明
ExpressException 快递服务异常(携带 ProviderName / ErrorCode / 原始响应)

请求审计

本包为抽象层,不发起 HTTP 请求。各实现包内置 Bitzsoft.Integrations.RequestLogging 出站请求记录管道,默认使用 NullRequestLogStore 不持久化。

// 宿主注册 IRequestLogStore 实现后,各实现包的出站请求自动落库
services.AddRequestLogging<MyRequestLogStore>(opts =>
{
    opts.MaxInMemoryBodyBytes = 64 * 1024; // 仅控制内存/加密临时文件切换,不截断正文
    opts.SensitiveFields.Add("AppKey");
});

依赖

说明
Bitzsoft.Integrations.Compatibility 基础工具库

无其他外部依赖。

相关包

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Bitzsoft.Integrations.Express:

Package Downloads
Bitzsoft.Integrations.Express.SfLegal

顺丰函证通法律函件寄递服务实现

Bitzsoft.Integrations.Express.ShowApi

万维易源快递物流查询服务实现

Bitzsoft.Integrations.Express.Kdniao

快递鸟物流服务实现

Bitzsoft.Integrations.Express.Zto

中通快递物流服务实现

Bitzsoft.Integrations.Express.Kuaidi100

快递100物流服务实现

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.10 46 7/26/2026
1.0.0-alpha.9 80 7/12/2026
1.0.0-alpha.8 121 7/1/2026
1.0.0-alpha.7 102 6/16/2026
1.0.0-alpha.6 97 6/16/2026
1.0.0-alpha.5 94 6/14/2026
1.0.0-alpha.3 92 6/7/2026