Files
KJD/Work/Api/Wx/WxWaybillApi.cs
2026-10-30 11:30:02 +08:00

85 lines
6.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AllBase;
using AllBase.Model.Result;
using AllBase.Model.Param.WXParam;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Work.Api.Wx
{
/// <summary>微信小店在线电子面单接口;独立于原窗体,使用 HttpHelper 发送请求。</summary>
/// <remarks>传入原 ShopLoginInfo 登录信息;方法同步执行,界面调用请置于后台任务。返回原始正文,不自动登录、重试或解释业务状态。</remarks>
public static class WxWaybillApi
{
/// <summary>在线电子面单预下单,校验寄收件资料并获取下单准备信息。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="preWaybillOnlineparam">电子面单预下单参数,沿用 AllBase 中的请求模型。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\OrderForms\WXOrderListForm.cs,WXOrderList.preCreateOrderWaybillOnline。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string PreCreateOrderWaybillOnline(ShopLoginInfo shop, WXPreCreateOrderWaybillOnlineParam preWaybillOnlineparam)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodewaybill/alltoall/platPreCreateOrder?token=&lang=zh_CN";
string body = JsonHelper.SerializeObject(preWaybillOnlineparam);
string refere = "https://store.weixin.qq.com/shop/waybill/allToAll";
var result = WxHttpClient.Post(shop, url, body, refere);
return result;
}
/// <summary>创建在线电子面单订单,实际向平台提交面单申请。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="waybillOnlineparam">电子面单创建参数,沿用 AllBase 中的请求模型。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\OrderForms\WXOrderListForm.cs,WXOrderList.createOrderWaybillOnline。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string CreateOrderWaybillOnline(ShopLoginInfo shop, WXCreateOrderWaybillOnlineParam waybillOnlineparam)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodewaybill/alltoall/platCreateOrder?token=&lang=zh_CN";
string body = JsonHelper.SerializeObject(waybillOnlineparam);
string refere = "https://store.weixin.qq.com/shop/waybill/allToAll";
var result = WxHttpClient.Post(shop, url, body, refere);
return result;
}
/// <summary>按微信订单号查询已创建的在线电子面单。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="orderId">微信订单 ID。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\OrderForms\WXOrderListForm.cs,WXOrderList.searchOnlineWaybill。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string SearchOnlineWaybill(ShopLoginInfo shop, string orderId)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodewaybill/alltoall/searchBill?token=&lang=zh_CN";
string body = @"{""createMode"":1,""orderId"":""" + orderId + @""",""cosignmentOrderId"":"""",""goodsTitle"":"""",""receiverPhone"":"""",""receiverName"":"""",""billStatus"":null,""orderStatus"":null,""offset"":0,""limit"":20,""waybillId"":"""",""payMethodList"":[],""platDisplayOrderStatusList"":[],""cosignmentOrderTime"":[],""cosignmentAssignTime"":[],""storeName"":"""",""orderNote"":"""",""deliveryOrderStatusList"":[10,20,40]}";
string refere = "https://store.weixin.qq.com/shop/waybill/allToAll";
var result = WxHttpClient.Post(shop, url, body, refere);
return result;
}
/// <summary>取消指定在线电子面单订单。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="ewaybillOrderId">平台返回的电子面单订单 ID。</param>
/// <param name="waybillId">物流运单号。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\OrderForms\WXOrderListForm.cs,WXOrderList.cancelOnlineWaybill。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string CancelOnlineWaybill(ShopLoginInfo shop, string ewaybillOrderId, string waybillId)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodewaybill/alltoall/platCancelOrder?token=&lang=zh_CN";
string body = @"{""requestContent"":[{""ewaybillOrderId"":""" + ewaybillOrderId + @""",""waybillId"":""" + waybillId + @""",""source"":1,""merchCancelReason"":""临时缺货,库存不足""}]}";
string refere = "https://store.weixin.qq.com/shop/waybill/allToAll";
var result = WxHttpClient.Post(shop, url, body, refere);
return result;
}
}
}