1371 lines
47 KiB
Markdown
1371 lines
47 KiB
Markdown
// File: sdk_tb_linkedmall/go.mod
|
||
```
|
||
module sdk_tb_linkedmall
|
||
|
||
go 1.21
|
||
|
||
require (
|
||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.10
|
||
github.com/alibabacloud-go/tea v1.2.2
|
||
)
|
||
```
|
||
|
||
// File: sdk_tb_linkedmall/types.go
|
||
```go
|
||
package sdk_tb_linkedmall
|
||
|
||
// ============================================================
|
||
// 公共响应结构体
|
||
// ============================================================
|
||
|
||
// CommonResponse 是所有API的统一外层响应结构
|
||
type CommonResponse struct {
|
||
RequestId string `json:"RequestId"`
|
||
Success bool `json:"Success"`
|
||
Code string `json:"Code"`
|
||
Message string `json:"Message"`
|
||
SubCode string `json:"SubCode"`
|
||
SubMessage string `json:"SubMessage"`
|
||
Data interface{} `json:"Data"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口1:ListPurchaserShops - 获取采购方店铺列表
|
||
// ============================================================
|
||
|
||
// ListPurchaserShopsReq 查询采购方店铺列表请求参数
|
||
type ListPurchaserShopsReq struct {
|
||
PageNum int `json:"PageNum,omitempty"`
|
||
PageSize int `json:"PageSize,omitempty"`
|
||
}
|
||
|
||
// ListPurchaserShopsRespData 查询采购方店铺列表响应数据
|
||
type ListPurchaserShopsRespData struct {
|
||
Total int64 `json:"Total"`
|
||
PageNum int `json:"PageNum"`
|
||
PageSize int `json:"PageSize"`
|
||
ShopList []PurchaserShopItem `json:"ShopList"`
|
||
}
|
||
|
||
// PurchaserShopItem 采购方店铺条目
|
||
type PurchaserShopItem struct {
|
||
ShopId string `json:"ShopId"`
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ShopName string `json:"ShopName"`
|
||
ShopStatus string `json:"ShopStatus"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口2:GetPurchaserShop - 获取单个采购店铺详情
|
||
// ============================================================
|
||
|
||
// GetPurchaserShopReq 获取采购店铺详情请求参数
|
||
type GetPurchaserShopReq struct {
|
||
ShopId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId,omitempty"` // Query参数
|
||
}
|
||
|
||
// GetPurchaserShopRespData 获取采购店铺详情响应数据
|
||
type GetPurchaserShopRespData struct {
|
||
ShopId string `json:"ShopId"`
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ShopName string `json:"ShopName"`
|
||
ShopStatus string `json:"ShopStatus"`
|
||
ContactInfo string `json:"ContactInfo"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口3:ListSelectionProducts - 查询选品池商品列表
|
||
// ============================================================
|
||
|
||
// ListSelectionProductsReq 查询选品池商品列表请求参数
|
||
type ListSelectionProductsReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
PageNum int `json:"PageNum,omitempty"`
|
||
PageSize int `json:"PageSize,omitempty"`
|
||
}
|
||
|
||
// ListSelectionProductsRespData 查询选品池商品列表响应数据
|
||
type ListSelectionProductsRespData struct {
|
||
Total int64 `json:"Total"`
|
||
PageNum int `json:"PageNum"`
|
||
PageSize int `json:"PageSize"`
|
||
ProductList []SelectionProductItem `json:"ProductList"`
|
||
}
|
||
|
||
// SelectionProductItem 选品池商品条目
|
||
type SelectionProductItem struct {
|
||
ProductId string `json:"ProductId"`
|
||
Title string `json:"Title"`
|
||
MainImage string `json:"MainImage"`
|
||
BrandName string `json:"BrandName"`
|
||
CategoryId string `json:"CategoryId"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口4:GetSelectionProduct - 查询选品池商品详情
|
||
// ============================================================
|
||
|
||
// GetSelectionProductReq 查询选品池商品详情请求参数
|
||
type GetSelectionProductReq struct {
|
||
ProductId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
DivisionCode string `json:"DivisionCode,omitempty"`
|
||
}
|
||
|
||
// GetSelectionProductRespData 查询选品池商品详情响应数据
|
||
type GetSelectionProductRespData struct {
|
||
ProductId string `json:"ProductId"`
|
||
Title string `json:"Title"`
|
||
MainImage string `json:"MainImage"`
|
||
Images []string `json:"Images"`
|
||
BrandName string `json:"BrandName"`
|
||
CategoryId string `json:"CategoryId"`
|
||
Desc string `json:"Desc"`
|
||
SkuList []SelectionSkuItem `json:"SkuList"`
|
||
CanSale bool `json:"CanSale"`
|
||
StockQuantity int64 `json:"StockQuantity"`
|
||
}
|
||
|
||
// SelectionSkuItem SKU条目
|
||
type SelectionSkuItem struct {
|
||
SkuId string `json:"SkuId"`
|
||
SkuSpec string `json:"SkuSpec"`
|
||
SalePrice int64 `json:"SalePrice"` // 单位分
|
||
MarketPrice int64 `json:"MarketPrice"` // 单位分
|
||
StockQuantity int64 `json:"StockQuantity"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口5:GetSelectionProductSaleInfo - 查询选品池商品销售信息
|
||
// ============================================================
|
||
|
||
// GetSelectionProductSaleInfoReq 查询选品池商品销售信息请求参数
|
||
type GetSelectionProductSaleInfoReq struct {
|
||
ProductId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
DivisionCode string `json:"DivisionCode,omitempty"`
|
||
}
|
||
|
||
// GetSelectionProductSaleInfoRespData 选品池商品销售信息
|
||
type GetSelectionProductSaleInfoRespData struct {
|
||
ProductId string `json:"ProductId"`
|
||
CanSale bool `json:"CanSale"`
|
||
SalePrice int64 `json:"SalePrice"`
|
||
MarketPrice int64 `json:"MarketPrice"`
|
||
StockQuantity int64 `json:"StockQuantity"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口6:ListSelectionProductSaleInfos - 批量查询商品销售信息
|
||
// ============================================================
|
||
|
||
// ListSelectionProductSaleInfosReq 批量查询商品销售信息请求参数
|
||
type ListSelectionProductSaleInfosReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ProductIdList []string `json:"ProductIdList"`
|
||
DivisionCode string `json:"DivisionCode,omitempty"`
|
||
}
|
||
|
||
// ListSelectionProductSaleInfosRespData 批量查询商品销售信息响应数据
|
||
type ListSelectionProductSaleInfosRespData struct {
|
||
ProductSaleInfoList []GetSelectionProductSaleInfoRespData `json:"ProductSaleInfoList"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口7:ListSelectionSkuSaleInfos - 批量SKU销售信息
|
||
// ============================================================
|
||
|
||
// ListSelectionSkuSaleInfosReq 批量SKU销售信息请求参数
|
||
type ListSelectionSkuSaleInfosReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
SkuIdList []string `json:"SkuIdList"`
|
||
DivisionCode string `json:"DivisionCode,omitempty"`
|
||
}
|
||
|
||
// ListSelectionSkuSaleInfosRespData 批量SKU销售信息响应数据
|
||
type ListSelectionSkuSaleInfosRespData struct {
|
||
SkuSaleInfoList []SelectionSkuItem `json:"SkuSaleInfoList"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口8:ListCategories - 查询类目列表
|
||
// ============================================================
|
||
|
||
// ListCategoriesReq 查询类目列表请求参数
|
||
type ListCategoriesReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ParentCategoryId string `json:"ParentCategoryId,omitempty"`
|
||
}
|
||
|
||
// ListCategoriesRespData 类目列表响应数据
|
||
type ListCategoriesRespData struct {
|
||
CategoryList []CategoryItem `json:"CategoryList"`
|
||
}
|
||
|
||
// CategoryItem 类目条目
|
||
type CategoryItem struct {
|
||
CategoryId string `json:"CategoryId"`
|
||
CategoryName string `json:"CategoryName"`
|
||
ParentId string `json:"ParentId"`
|
||
Level int `json:"Level"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口9:SearchProducts - 搜索选品池商品
|
||
// ============================================================
|
||
|
||
// SearchProductsReq 搜索选品池商品请求参数
|
||
type SearchProductsReq struct {
|
||
Keyword string `json:"Keyword,omitempty"`
|
||
CategoryId string `json:"CategoryId,omitempty"`
|
||
PageNum int `json:"PageNum,omitempty"`
|
||
PageSize int `json:"PageSize,omitempty"`
|
||
PurchaserId string `json:"PurchaserId"`
|
||
}
|
||
|
||
// SearchProductsRespData 搜索选品池商品响应数据
|
||
type SearchProductsRespData struct {
|
||
Total int64 `json:"Total"`
|
||
PageNum int `json:"PageNum"`
|
||
PageSize int `json:"PageSize"`
|
||
ProductList []SelectionProductItem `json:"ProductList"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口10:SelectionGroupAddProduct - 选品池商品入库
|
||
// ============================================================
|
||
|
||
// SelectionGroupAddProductReq 选品池商品入库请求参数
|
||
type SelectionGroupAddProductReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ShopId string `json:"ShopId"`
|
||
ProductIdList []string `json:"ProductIdList"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口11:SelectionGroupRemoveProduct - 选品池商品出库
|
||
// ============================================================
|
||
|
||
// SelectionGroupRemoveProductReq 选品池商品出库请求参数
|
||
type SelectionGroupRemoveProductReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ShopId string `json:"ShopId"`
|
||
ProductIdList []string `json:"ProductIdList"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口12:RenderPurchaseOrder - 采购单渲染(下单预校验)
|
||
// ============================================================
|
||
|
||
// RenderPurchaseOrderReq 采购单渲染请求参数
|
||
type RenderPurchaseOrderReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ShopId string `json:"ShopId"`
|
||
DivisionCode string `json:"DivisionCode"`
|
||
ItemList []RenderOrderItem `json:"ItemList"`
|
||
ReceiverInfo ReceiverInfo `json:"ReceiverInfo"`
|
||
}
|
||
|
||
// RenderOrderItem 渲染商品条目
|
||
type RenderOrderItem struct {
|
||
SkuId string `json:"SkuId"`
|
||
Quantity int64 `json:"Quantity"`
|
||
}
|
||
|
||
// ReceiverInfo 收货人信息
|
||
type ReceiverInfo struct {
|
||
ReceiverName string `json:"ReceiverName"`
|
||
ReceiverPhone string `json:"ReceiverPhone"`
|
||
ProvinceCode string `json:"ProvinceCode"`
|
||
CityCode string `json:"CityCode"`
|
||
DistrictCode string `json:"DistrictCode"`
|
||
TownCode string `json:"TownCode"`
|
||
DetailAddress string `json:"DetailAddress"`
|
||
}
|
||
|
||
// RenderPurchaseOrderRespData 采购单渲染响应数据
|
||
type RenderPurchaseOrderRespData struct {
|
||
TotalFee int64 `json:"TotalFee"` // 总金额,单位分
|
||
TotalFreightFee int64 `json:"TotalFreightFee"` // 总运费,单位分
|
||
ItemList []RenderResultItem `json:"ItemList"`
|
||
UnavailableList []UnavailableItem `json:"UnavailableList"` // 不可售商品列表
|
||
}
|
||
|
||
// RenderResultItem 渲染结果商品条目
|
||
type RenderResultItem struct {
|
||
SkuId string `json:"SkuId"`
|
||
ProductId string `json:"ProductId"`
|
||
Title string `json:"Title"`
|
||
Quantity int64 `json:"Quantity"`
|
||
SalePrice int64 `json:"SalePrice"` // 实时单价,单位分
|
||
TotalFee int64 `json:"TotalFee"` // 小计金额,单位分
|
||
FreightFee int64 `json:"FreightFee"` // 运费,单位分
|
||
CanSale bool `json:"CanSale"`
|
||
UnavailableReason string `json:"UnavailableReason,omitempty"`
|
||
}
|
||
|
||
// UnavailableItem 不可售商品
|
||
type UnavailableItem struct {
|
||
SkuId string `json:"SkuId"`
|
||
ProductId string `json:"ProductId"`
|
||
Reason string `json:"Reason"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口13:SplitPurchaseOrder - 采购单渲染并拆单
|
||
// ============================================================
|
||
|
||
// SplitPurchaseOrderReq 采购单渲染并拆单请求参数(与RenderPurchaseOrderReq相同)
|
||
type SplitPurchaseOrderReq = RenderPurchaseOrderReq
|
||
|
||
// SplitPurchaseOrderRespData 采购单渲染并拆单响应数据
|
||
type SplitPurchaseOrderRespData struct {
|
||
SubOrderList []SubOrderRenderResult `json:"SubOrderList"`
|
||
}
|
||
|
||
// SubOrderRenderResult 子单渲染结果
|
||
type SubOrderRenderResult struct {
|
||
ShopId string `json:"ShopId"`
|
||
ShopName string `json:"ShopName"`
|
||
TotalFee int64 `json:"TotalFee"`
|
||
FreightFee int64 `json:"FreightFee"`
|
||
ItemList []RenderResultItem `json:"ItemList"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口14:CreatePurchaseOrder - 创建采购单【异步】
|
||
// ============================================================
|
||
|
||
// CreatePurchaseOrderReq 创建采购单请求参数
|
||
type CreatePurchaseOrderReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ShopId string `json:"ShopId"`
|
||
OuterPurchaseOrderId string `json:"OuterPurchaseOrderId"` // 外部业务唯一单号,幂等
|
||
DivisionCode string `json:"DivisionCode"`
|
||
ReceiverInfo ReceiverInfo `json:"ReceiverInfo"`
|
||
SubOrderList []CreateSubOrderItem `json:"SubOrderList"`
|
||
}
|
||
|
||
// CreateSubOrderItem 创建采购单子单条目
|
||
type CreateSubOrderItem struct {
|
||
SkuId string `json:"SkuId"`
|
||
Quantity int64 `json:"Quantity"`
|
||
}
|
||
|
||
// CreatePurchaseOrderRespData 创建采购单响应数据
|
||
type CreatePurchaseOrderRespData struct {
|
||
PurchaseOrderId string `json:"PurchaseOrderId"` // 阿里云采购单号
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口15:GetPurchaseOrderStatus - 获取采购单状态
|
||
// ============================================================
|
||
|
||
// GetPurchaseOrderStatusReq 获取采购单状态请求参数
|
||
type GetPurchaseOrderStatusReq struct {
|
||
PurchaseOrderId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
}
|
||
|
||
// GetPurchaseOrderStatusRespData 获取采购单状态响应数据
|
||
type GetPurchaseOrderStatusRespData struct {
|
||
PurchaseOrderId string `json:"PurchaseOrderId"`
|
||
Status string `json:"Status"` // INIT、PROCESS、SUCCESS、FAIL、CLOSED
|
||
}
|
||
|
||
// 采购单状态常量
|
||
const (
|
||
PurchaseOrderStatusInit = "INIT"
|
||
PurchaseOrderStatusProcess = "PROCESS"
|
||
PurchaseOrderStatusSuccess = "SUCCESS"
|
||
PurchaseOrderStatusFail = "FAIL"
|
||
PurchaseOrderStatusClosed = "CLOSED"
|
||
)
|
||
|
||
// ============================================================
|
||
// 接口16:GetOrder - 获取订单详情
|
||
// ============================================================
|
||
|
||
// GetOrderReq 获取订单详情请求参数
|
||
type GetOrderReq struct {
|
||
OrderId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
}
|
||
|
||
// GetOrderRespData 获取订单详情响应数据
|
||
type GetOrderRespData struct {
|
||
OrderId string `json:"OrderId"`
|
||
PurchaseOrderId string `json:"PurchaseOrderId"`
|
||
PurchaserId string `json:"PurchaserId"`
|
||
ShopId string `json:"ShopId"`
|
||
OrderStatus string `json:"OrderStatus"`
|
||
TotalFee int64 `json:"TotalFee"` // 实付金额,单位分
|
||
FreightFee int64 `json:"FreightFee"` // 运费,单位分
|
||
ReceiverInfo ReceiverInfo `json:"ReceiverInfo"`
|
||
OrderItemList []OrderItem `json:"OrderItemList"`
|
||
CreateTime string `json:"CreateTime"`
|
||
PayTime string `json:"PayTime,omitempty"`
|
||
DeliveryTime string `json:"DeliveryTime,omitempty"`
|
||
ConfirmReceiveTime string `json:"ConfirmReceiveTime,omitempty"`
|
||
}
|
||
|
||
// OrderItem 订单商品明细
|
||
type OrderItem struct {
|
||
OrderItemId string `json:"OrderItemId"`
|
||
SkuId string `json:"SkuId"`
|
||
ProductId string `json:"ProductId"`
|
||
Title string `json:"Title"`
|
||
Quantity int64 `json:"Quantity"`
|
||
SalePrice int64 `json:"SalePrice"`
|
||
TotalFee int64 `json:"TotalFee"`
|
||
ItemStatus string `json:"ItemStatus"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口17:QueryOrders - 查询订单列表
|
||
// ============================================================
|
||
|
||
// QueryOrdersReq 查询订单列表请求参数
|
||
type QueryOrdersReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
PurchaseOrderId string `json:"PurchaseOrderId,omitempty"`
|
||
PageNum int `json:"PageNum,omitempty"`
|
||
PageSize int `json:"PageSize,omitempty"`
|
||
StartTime string `json:"StartTime,omitempty"`
|
||
EndTime string `json:"EndTime,omitempty"`
|
||
}
|
||
|
||
// QueryOrdersRespData 查询订单列表响应数据
|
||
type QueryOrdersRespData struct {
|
||
Total int64 `json:"Total"`
|
||
PageNum int `json:"PageNum"`
|
||
PageSize int `json:"PageSize"`
|
||
OrderList []GetOrderRespData `json:"OrderList"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口18:ListLogisticsOrders - 查询订单物流信息
|
||
// ============================================================
|
||
|
||
// ListLogisticsOrdersReq 查询订单物流信息请求参数
|
||
type ListLogisticsOrdersReq struct {
|
||
OrderId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
}
|
||
|
||
// ListLogisticsOrdersRespData 查询订单物流信息响应数据
|
||
type ListLogisticsOrdersRespData struct {
|
||
LogisticsList []LogisticsInfo `json:"LogisticsList"`
|
||
}
|
||
|
||
// LogisticsInfo 物流信息
|
||
type LogisticsInfo struct {
|
||
LogisticsCompany string `json:"LogisticsCompany"`
|
||
TrackingNumber string `json:"TrackingNumber"`
|
||
TrajectoryList []LogisticsTrace `json:"TrajectoryList"`
|
||
}
|
||
|
||
// LogisticsTrace 物流轨迹
|
||
type LogisticsTrace struct {
|
||
Time string `json:"Time"`
|
||
Content string `json:"Content"`
|
||
Location string `json:"Location,omitempty"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口19:ConfirmDisburse - 确认收货
|
||
// ============================================================
|
||
|
||
// ConfirmDisburseReq 确认收货请求参数
|
||
type ConfirmDisburseReq struct {
|
||
OrderId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口20:RenderRefundOrder - 售后渲染预校验
|
||
// ============================================================
|
||
|
||
// RenderRefundOrderReq 售后渲染预校验请求参数
|
||
type RenderRefundOrderReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
OrderId string `json:"OrderId"`
|
||
OrderItemId string `json:"OrderItemId"`
|
||
RefundQuantity int64 `json:"RefundQuantity"`
|
||
RefundType string `json:"RefundType"` // 仅退款/退货退款
|
||
}
|
||
|
||
// RenderRefundOrderRespData 售后渲染预校验响应数据
|
||
type RenderRefundOrderRespData struct {
|
||
CanRefund bool `json:"CanRefund"`
|
||
RefundAmount int64 `json:"RefundAmount"` // 可退金额,单位分
|
||
RefundQuantity int64 `json:"RefundQuantity"` // 可退数量
|
||
RefundType string `json:"RefundType"`
|
||
Reason string `json:"Reason,omitempty"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口21:CreateRefundOrder - 创建售后单
|
||
// ============================================================
|
||
|
||
// CreateRefundOrderReq 创建售后单请求参数
|
||
type CreateRefundOrderReq struct {
|
||
PurchaserId string `json:"PurchaserId"`
|
||
OrderId string `json:"OrderId"`
|
||
OrderItemId string `json:"OrderItemId"`
|
||
RefundQuantity int64 `json:"RefundQuantity"`
|
||
RefundAmount int64 `json:"RefundAmount"` // 单位分
|
||
RefundType string `json:"RefundType"`
|
||
RefundReason string `json:"RefundReason"`
|
||
OuterRefundNo string `json:"OuterRefundNo"` // 外部售后单号,幂等
|
||
}
|
||
|
||
// CreateRefundOrderRespData 创建售后单响应数据
|
||
type CreateRefundOrderRespData struct {
|
||
RefundOrderId string `json:"RefundOrderId"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口22:CancelRefundOrder - 取消售后单
|
||
// ============================================================
|
||
|
||
// CancelRefundOrderReq 取消售后单请求参数
|
||
type CancelRefundOrderReq struct {
|
||
RefundOrderId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口23:GetRefundOrder - 获取售后单详情
|
||
// ============================================================
|
||
|
||
// GetRefundOrderReq 获取售后单详情请求参数
|
||
type GetRefundOrderReq struct {
|
||
RefundOrderId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
}
|
||
|
||
// GetRefundOrderRespData 获取售后单详情响应数据
|
||
type GetRefundOrderRespData struct {
|
||
RefundOrderId string `json:"RefundOrderId"`
|
||
OrderId string `json:"OrderId"`
|
||
OrderItemId string `json:"OrderItemId"`
|
||
PurchaserId string `json:"PurchaserId"`
|
||
RefundAmount int64 `json:"RefundAmount"`
|
||
RefundQuantity int64 `json:"RefundQuantity"`
|
||
RefundType string `json:"RefundType"`
|
||
RefundReason string `json:"RefundReason"`
|
||
RefundStatus string `json:"RefundStatus"`
|
||
OuterRefundNo string `json:"OuterRefundNo"`
|
||
CreateTime string `json:"CreateTime"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口24:CreateGoodsShippingNotice - 回填退货物流运单
|
||
// ============================================================
|
||
|
||
// CreateGoodsShippingNoticeReq 回填退货物流运单请求参数
|
||
type CreateGoodsShippingNoticeReq struct {
|
||
RefundOrderId string `json:"-"` // Path参数
|
||
PurchaserId string `json:"PurchaserId"`
|
||
LogisticsCompany string `json:"LogisticsCompany"`
|
||
TrackingNumber string `json:"TrackingNumber"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口25:QueryChildDivisionCode - 查询子区域编码
|
||
// ============================================================
|
||
|
||
// QueryChildDivisionCodeReq 查询子区域编码请求参数
|
||
type QueryChildDivisionCodeReq struct {
|
||
ParentDivisionCode string `json:"ParentDivisionCode,omitempty"`
|
||
}
|
||
|
||
// QueryChildDivisionCodeRespData 查询子区域编码响应数据
|
||
type QueryChildDivisionCodeRespData struct {
|
||
DivisionList []DivisionInfo `json:"DivisionList"`
|
||
}
|
||
|
||
// DivisionInfo 区域信息
|
||
type DivisionInfo struct {
|
||
DivisionCode string `json:"DivisionCode"`
|
||
DivisionName string `json:"DivisionName"`
|
||
Level int `json:"Level"`
|
||
ParentCode string `json:"ParentCode,omitempty"`
|
||
}
|
||
|
||
// ============================================================
|
||
// 回调通知结构体
|
||
// ============================================================
|
||
|
||
// CallbackMessage 回调通知消息体
|
||
type CallbackMessage struct {
|
||
EventCode string `json:"EventCode"`
|
||
PurchaseOrderId string `json:"PurchaseOrderId"`
|
||
OrderIdList []string `json:"OrderIdList"`
|
||
Status string `json:"Status"`
|
||
RequestId string `json:"RequestId"`
|
||
}
|
||
|
||
// 事件码常量
|
||
const (
|
||
EventCodePurchaseOrderChange = "PURCHASE_ORDER_CHANGE"
|
||
EventCodeOrderStatusChange = "ORDER_STATUS_CHANGE"
|
||
EventCodeRefundOrderChange = "REFUND_ORDER_CHANGE"
|
||
)
|
||
|
||
// CallbackResponse 回调响应,告知阿里云消费成功
|
||
type CallbackResponse struct {
|
||
Success bool `json:"success"`
|
||
}
|
||
```
|
||
|
||
// File: sdk_tb_linkedmall/errors.go
|
||
```go
|
||
package sdk_tb_linkedmall
|
||
|
||
import "fmt"
|
||
|
||
// APIError 表示API调用返回的业务错误
|
||
type APIError struct {
|
||
Code string // 错误码
|
||
Message string // 错误信息
|
||
SubCode string // 子错误码
|
||
SubMessage string // 子错误信息
|
||
RequestId string // 请求ID
|
||
}
|
||
|
||
func (e *APIError) Error() string {
|
||
return fmt.Sprintf("linkedmall api error: code=%s, message=%s, subCode=%s, subMessage=%s, requestId=%s",
|
||
e.Code, e.Message, e.SubCode, e.SubMessage, e.RequestId)
|
||
}
|
||
|
||
// NewAPIError 创建API错误
|
||
func NewAPIError(code, message, subCode, subMessage, requestId string) *APIError {
|
||
return &APIError{
|
||
Code: code,
|
||
Message: message,
|
||
SubCode: subCode,
|
||
SubMessage: subMessage,
|
||
RequestId: requestId,
|
||
}
|
||
}
|
||
|
||
// IsBusinessSuccess 判断业务是否成功(需要HTTP 200 + Success=true)
|
||
func IsBusinessSuccess(resp *CommonResponse) bool {
|
||
return resp != nil && resp.Success
|
||
}
|
||
|
||
// CheckResponse 检查响应是否成功,失败返回error
|
||
func CheckResponse(resp *CommonResponse) error {
|
||
if resp == nil {
|
||
return fmt.Errorf("linkedmall: response is nil")
|
||
}
|
||
if !resp.Success {
|
||
return NewAPIError(resp.Code, resp.Message, resp.SubCode, resp.SubMessage, resp.RequestId)
|
||
}
|
||
return nil
|
||
}
|
||
|
||
// 预定义错误码常量
|
||
const (
|
||
ErrCodeShopTypeInvalid = "ShopTypeInvalid"
|
||
ErrCodeSkuPriceNotUnique = "SkuPriceUnique"
|
||
ErrCodePurchaseOrderNotFound = "PurchaseOrderNotFound"
|
||
ErrCodeRefundNumberMustLessThanOrder = "RefundNumberMustLessThanOrder"
|
||
ErrCodeRefundAmountMustLessThanOrder = "RefundAmountMustLessThanOrder"
|
||
ErrCodeHasNoPrivilege = "HasNoPrivilege"
|
||
ErrCodeOrderNotFound = "OrderNotFound"
|
||
ErrCodeShopNotFind = "ShopNotFind"
|
||
ErrCodeSavePurchaseOrderError = "SavePurchaseOrderError"
|
||
ErrCodeOuterPurchaseOrderIdExist = "OuterPurchaseOrderIdExist"
|
||
)
|
||
```
|
||
|
||
// File: sdk_tb_linkedmall/crypto.go
|
||
```go
|
||
package sdk_tb_linkedmall
|
||
|
||
// 本SDK使用阿里云OpenAPI客户端(darabonba-openapi/v2)进行ROA签名认证,
|
||
// 签名过程由SDK内部自动处理,业务无需自行实现签名算法。
|
||
// 因此本文件为占位文件,不包含自定义加密实现。
|
||
```
|
||
|
||
// File: sdk_tb_linkedmall/client.go
|
||
```go
|
||
package sdk_tb_linkedmall
|
||
|
||
import (
|
||
"encoding/json"
|
||
"fmt"
|
||
"strconv"
|
||
|
||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||
"github.com/alibabacloud-go/tea"
|
||
)
|
||
|
||
// Client 是LinkedMall SDK客户端,封装了所有API方法
|
||
type Client struct {
|
||
openapiClient *openapi.Client
|
||
basePath string
|
||
}
|
||
|
||
// NewClient 创建LinkedMall SDK客户端
|
||
// - accessKeyId: RAM子账号的AccessKeyId
|
||
// - accessKeySecret: RAM子账号的AccessKeySecret
|
||
func NewClient(accessKeyId, accessKeySecret string) (*Client, error) {
|
||
config := &openapi.Config{
|
||
AccessKeyId: tea.String(accessKeyId),
|
||
AccessKeySecret: tea.String(accessKeySecret),
|
||
RegionId: tea.String("cn-zhangjiakou"),
|
||
Endpoint: tea.String("linkedmall.cn-zhangjiakou.aliyuncs.com"),
|
||
ReadTimeout: tea.Int(30000),
|
||
ConnectTimeout: tea.Int(10000),
|
||
}
|
||
apiClient, err := openapi.NewClient(config)
|
||
if err != nil {
|
||
return nil, fmt.Errorf("failed to create openapi client: %w", err)
|
||
}
|
||
return &Client{
|
||
openapiClient: apiClient,
|
||
basePath: "/opensaas-s2b/opensaas-s2b-biz-trade/v2",
|
||
}, nil
|
||
}
|
||
|
||
// doRequest 执行ROA请求,并解析公共响应体
|
||
func (c *Client) doRequest(method, path string, query map[string]string, body interface{}) (*CommonResponse, error) {
|
||
// 转换query为map[string]*string
|
||
teaQuery := make(map[string]*string, len(query))
|
||
for k, v := range query {
|
||
if v != "" {
|
||
teaQuery[k] = tea.String(v)
|
||
}
|
||
}
|
||
|
||
fullPath := c.basePath + path
|
||
|
||
respBytes, err := c.openapiClient.RoaRequest(
|
||
tea.String(method),
|
||
tea.String(fullPath),
|
||
teaQuery,
|
||
body,
|
||
nil,
|
||
)
|
||
if err != nil {
|
||
return nil, fmt.Errorf("roa request failed: %w", err)
|
||
}
|
||
|
||
var commonResp CommonResponse
|
||
if err := json.Unmarshal(respBytes, &commonResp); err != nil {
|
||
return nil, fmt.Errorf("failed to parse response: %w", err)
|
||
}
|
||
|
||
return &commonResp, nil
|
||
}
|
||
|
||
// parseData 将CommonResponse的Data字段解析到目标结构体
|
||
func parseData(commonResp *CommonResponse, target interface{}) error {
|
||
dataBytes, err := json.Marshal(commonResp.Data)
|
||
if err != nil {
|
||
return fmt.Errorf("failed to marshal data: %w", err)
|
||
}
|
||
if err := json.Unmarshal(dataBytes, target); err != nil {
|
||
return fmt.Errorf("failed to unmarshal data: %w", err)
|
||
}
|
||
return nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口1:ListPurchaserShops - 分页获取采购方店铺列表
|
||
// ============================================================
|
||
|
||
// ListPurchaserShops 分页获取采购方店铺列表
|
||
func (c *Client) ListPurchaserShops(req *ListPurchaserShopsReq) (*CommonResponse, *ListPurchaserShopsRespData, error) {
|
||
query := make(map[string]string)
|
||
if req.PageNum > 0 {
|
||
query["PageNum"] = strconv.Itoa(req.PageNum)
|
||
}
|
||
if req.PageSize > 0 {
|
||
query["PageSize"] = strconv.Itoa(req.PageSize)
|
||
}
|
||
|
||
commonResp, err := c.doRequest("GET", "/purchaser-shops", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data ListPurchaserShopsRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口2:GetPurchaserShop - 获取单个采购店铺详情
|
||
// ============================================================
|
||
|
||
// GetPurchaserShop 获取单个采购店铺详情
|
||
func (c *Client) GetPurchaserShop(shopId string) (*CommonResponse, *GetPurchaserShopRespData, error) {
|
||
query := make(map[string]string)
|
||
|
||
commonResp, err := c.doRequest("GET", "/purchaser-shops/"+shopId, query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data GetPurchaserShopRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口3:ListSelectionProducts - 分页查询选品池商品列表
|
||
// ============================================================
|
||
|
||
// ListSelectionProducts 分页查询选品池商品列表
|
||
func (c *Client) ListSelectionProducts(req *ListSelectionProductsReq) (*CommonResponse, *ListSelectionProductsRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = req.PurchaserId
|
||
if req.PageNum > 0 {
|
||
query["PageNum"] = strconv.Itoa(req.PageNum)
|
||
}
|
||
if req.PageSize > 0 {
|
||
query["PageSize"] = strconv.Itoa(req.PageSize)
|
||
}
|
||
|
||
commonResp, err := c.doRequest("GET", "/selection-products", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data ListSelectionProductsRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口4:GetSelectionProduct - 查询选品池商品详情
|
||
// ============================================================
|
||
|
||
// GetSelectionProduct 查询选品池商品详情
|
||
// - divisionCode: 可选,五级乡镇区域编码,传入后返回该区域可售状态
|
||
func (c *Client) GetSelectionProduct(req *GetSelectionProductReq) (*CommonResponse, *GetSelectionProductRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = req.PurchaserId
|
||
if req.DivisionCode != "" {
|
||
query["DivisionCode"] = req.DivisionCode
|
||
}
|
||
|
||
commonResp, err := c.doRequest("GET", "/selection-products/"+req.ProductId, query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data GetSelectionProductRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口5:GetSelectionProductSaleInfo - 查询选品池商品销售信息
|
||
// ============================================================
|
||
|
||
// GetSelectionProductSaleInfo 查询选品池商品销售信息
|
||
func (c *Client) GetSelectionProductSaleInfo(req *GetSelectionProductSaleInfoReq) (*CommonResponse, *GetSelectionProductSaleInfoRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = req.PurchaserId
|
||
if req.DivisionCode != "" {
|
||
query["DivisionCode"] = req.DivisionCode
|
||
}
|
||
|
||
commonResp, err := c.doRequest("GET", "/selection-products/"+req.ProductId+"/sale-info", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data GetSelectionProductSaleInfoRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口6:ListSelectionProductSaleInfos - 批量查询商品销售信息
|
||
// ============================================================
|
||
|
||
// ListSelectionProductSaleInfos 批量查询商品销售信息
|
||
func (c *Client) ListSelectionProductSaleInfos(req *ListSelectionProductSaleInfosReq) (*CommonResponse, *ListSelectionProductSaleInfosRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/selection-products:batch-sale-info", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data ListSelectionProductSaleInfosRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口7:ListSelectionSkuSaleInfos - 批量SKU销售信息
|
||
// ============================================================
|
||
|
||
// ListSelectionSkuSaleInfos 批量查询SKU销售信息
|
||
func (c *Client) ListSelectionSkuSaleInfos(req *ListSelectionSkuSaleInfosReq) (*CommonResponse, *ListSelectionSkuSaleInfosRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/selection-skus:batch-sale-info", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data ListSelectionSkuSaleInfosRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口8:ListCategories - 查询类目列表
|
||
// ============================================================
|
||
|
||
// ListCategories 查询类目列表
|
||
// - parentCategoryId: 父类目ID,不传时查询一级类目
|
||
func (c *Client) ListCategories(req *ListCategoriesReq) (*CommonResponse, *ListCategoriesRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = req.PurchaserId
|
||
if req.ParentCategoryId != "" {
|
||
query["ParentCategoryId"] = req.ParentCategoryId
|
||
}
|
||
|
||
commonResp, err := c.doRequest("GET", "/categories", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data ListCategoriesRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口9:SearchProducts - 搜索选品池商品
|
||
// ============================================================
|
||
|
||
// SearchProducts 搜索选品池商品
|
||
func (c *Client) SearchProducts(req *SearchProductsReq) (*CommonResponse, *SearchProductsRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/selection-products:search", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data SearchProductsRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口10:SelectionGroupAddProduct - 选品池商品入库
|
||
// ============================================================
|
||
|
||
// SelectionGroupAddProduct 选品池商品入库
|
||
func (c *Client) SelectionGroupAddProduct(req *SelectionGroupAddProductReq) (*CommonResponse, error) {
|
||
commonResp, err := c.doRequest("POST", "/selection-group/products:add", nil, req)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, err
|
||
}
|
||
return commonResp, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口11:SelectionGroupRemoveProduct - 选品池商品出库
|
||
// ============================================================
|
||
|
||
// SelectionGroupRemoveProduct 选品池商品出库
|
||
func (c *Client) SelectionGroupRemoveProduct(req *SelectionGroupRemoveProductReq) (*CommonResponse, error) {
|
||
commonResp, err := c.doRequest("POST", "/selection-group/products:remove", nil, req)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, err
|
||
}
|
||
return commonResp, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口12:RenderPurchaseOrder - 采购单渲染(下单预校验)
|
||
// ============================================================
|
||
|
||
// RenderPurchaseOrder 采购单渲染(下单预校验)
|
||
// 下单前必须调用,获取实时价格、校验商品是否可售
|
||
func (c *Client) RenderPurchaseOrder(req *RenderPurchaseOrderReq) (*CommonResponse, *RenderPurchaseOrderRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/purchase-orders:render", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data RenderPurchaseOrderRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口13:SplitPurchaseOrder - 采购单渲染并拆单
|
||
// ============================================================
|
||
|
||
// SplitPurchaseOrder 采购单渲染并拆单
|
||
// 返回拆成多份子单结构,用于前端展示,拆单结果用于创建采购单入参
|
||
func (c *Client) SplitPurchaseOrder(req *SplitPurchaseOrderReq) (*CommonResponse, *SplitPurchaseOrderRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/purchase-orders:split-render", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data SplitPurchaseOrderRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口14:CreatePurchaseOrder - 创建采购单【异步】
|
||
// ============================================================
|
||
|
||
// CreatePurchaseOrder 创建采购单【异步】
|
||
// 重要:接口只返回采购单号,不代表下单成功,必须等待回调通知,再查询订单接口
|
||
func (c *Client) CreatePurchaseOrder(req *CreatePurchaseOrderReq) (*CommonResponse, *CreatePurchaseOrderRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/purchase-orders", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data CreatePurchaseOrderRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口15:GetPurchaseOrderStatus - 获取采购单状态
|
||
// ============================================================
|
||
|
||
// GetPurchaseOrderStatus 获取采购单状态
|
||
// 状态枚举:INIT、PROCESS、SUCCESS、FAIL、CLOSED
|
||
func (c *Client) GetPurchaseOrderStatus(purchaseOrderId, purchaserId string) (*CommonResponse, *GetPurchaseOrderStatusRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = purchaserId
|
||
|
||
commonResp, err := c.doRequest("GET", "/purchase-orders/"+purchaseOrderId+"/status", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data GetPurchaseOrderStatusRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口16:GetOrder - 获取订单详情
|
||
// ============================================================
|
||
|
||
// GetOrder 获取订单详情
|
||
func (c *Client) GetOrder(orderId, purchaserId string) (*CommonResponse, *GetOrderRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = purchaserId
|
||
|
||
commonResp, err := c.doRequest("GET", "/orders/"+orderId, query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data GetOrderRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口17:QueryOrders - 查询订单列表
|
||
// ============================================================
|
||
|
||
// QueryOrders 查询订单列表
|
||
func (c *Client) QueryOrders(req *QueryOrdersReq) (*CommonResponse, *QueryOrdersRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = req.PurchaserId
|
||
if req.PurchaseOrderId != "" {
|
||
query["PurchaseOrderId"] = req.PurchaseOrderId
|
||
}
|
||
if req.PageNum > 0 {
|
||
query["PageNum"] = strconv.Itoa(req.PageNum)
|
||
}
|
||
if req.PageSize > 0 {
|
||
query["PageSize"] = strconv.Itoa(req.PageSize)
|
||
}
|
||
if req.StartTime != "" {
|
||
query["StartTime"] = req.StartTime
|
||
}
|
||
if req.EndTime != "" {
|
||
query["EndTime"] = req.EndTime
|
||
}
|
||
|
||
commonResp, err := c.doRequest("GET", "/orders", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data QueryOrdersRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口18:ListLogisticsOrders - 查询订单物流信息
|
||
// ============================================================
|
||
|
||
// ListLogisticsOrders 查询订单物流信息
|
||
func (c *Client) ListLogisticsOrders(orderId, purchaserId string) (*CommonResponse, *ListLogisticsOrdersRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = purchaserId
|
||
|
||
commonResp, err := c.doRequest("GET", "/orders/"+orderId+"/logistics", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data ListLogisticsOrdersRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口19:ConfirmDisburse - 确认收货
|
||
// ============================================================
|
||
|
||
// ConfirmDisburse 确认收货
|
||
func (c *Client) ConfirmDisburse(orderId, purchaserId string) (*CommonResponse, error) {
|
||
body := map[string]string{
|
||
"PurchaserId": purchaserId,
|
||
}
|
||
|
||
commonResp, err := c.doRequest("POST", "/orders/"+orderId+":confirm-disburse", nil, body)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, err
|
||
}
|
||
return commonResp, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口20:RenderRefundOrder - 售后渲染预校验
|
||
// ============================================================
|
||
|
||
// RenderRefundOrder 售后渲染预校验
|
||
func (c *Client) RenderRefundOrder(req *RenderRefundOrderReq) (*CommonResponse, *RenderRefundOrderRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/refund-orders:render", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data RenderRefundOrderRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口21:CreateRefundOrder - 创建售后单
|
||
// ============================================================
|
||
|
||
// CreateRefundOrder 创建售后单
|
||
func (c *Client) CreateRefundOrder(req *CreateRefundOrderReq) (*CommonResponse, *CreateRefundOrderRespData, error) {
|
||
commonResp, err := c.doRequest("POST", "/refund-orders", nil, req)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data CreateRefundOrderRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口22:CancelRefundOrder - 取消售后单
|
||
// ============================================================
|
||
|
||
// CancelRefundOrder 取消售后单
|
||
func (c *Client) CancelRefundOrder(refundOrderId, purchaserId string) (*CommonResponse, error) {
|
||
body := map[string]string{
|
||
"PurchaserId": purchaserId,
|
||
}
|
||
|
||
commonResp, err := c.doRequest("POST", "/refund-orders/"+refundOrderId+":cancel", nil, body)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, err
|
||
}
|
||
return commonResp, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口23:GetRefundOrder - 获取售后单详情
|
||
// ============================================================
|
||
|
||
// GetRefundOrder 获取售后单详情
|
||
func (c *Client) GetRefundOrder(refundOrderId, purchaserId string) (*CommonResponse, *GetRefundOrderRespData, error) {
|
||
query := make(map[string]string)
|
||
query["PurchaserId"] = purchaserId
|
||
|
||
commonResp, err := c.doRequest("GET", "/refund-orders/"+refundOrderId, query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data GetRefundOrderRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口24:CreateGoodsShippingNotice - 回填退货物流运单
|
||
// ============================================================
|
||
|
||
// CreateGoodsShippingNotice 回填退货物流运单
|
||
func (c *Client) CreateGoodsShippingNotice(refundOrderId, purchaserId, logisticsCompany, trackingNumber string) (*CommonResponse, error) {
|
||
body := map[string]string{
|
||
"PurchaserId": purchaserId,
|
||
"LogisticsCompany": logisticsCompany,
|
||
"TrackingNumber": trackingNumber,
|
||
}
|
||
|
||
commonResp, err := c.doRequest("POST", "/refund-orders/"+refundOrderId+":fill-logistics", nil, body)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, err
|
||
}
|
||
return commonResp, nil
|
||
}
|
||
|
||
// ============================================================
|
||
// 接口25:QueryChildDivisionCode - 查询子区域编码
|
||
// ============================================================
|
||
|
||
// QueryChildDivisionCode 查询子区域编码
|
||
// 不传返回省级;传入省返回市,传入市返回区,传入区返回乡镇(五级)
|
||
func (c *Client) QueryChildDivisionCode(parentDivisionCode string) (*CommonResponse, *QueryChildDivisionCodeRespData, error) {
|
||
query := make(map[string]string)
|
||
if parentDivisionCode != "" {
|
||
query["ParentDivisionCode"] = parentDivisionCode
|
||
}
|
||
|
||
commonResp, err := c.doRequest("GET", "/divisions:children", query, nil)
|
||
if err != nil {
|
||
return nil, nil, err
|
||
}
|
||
if err := CheckResponse(commonResp); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
|
||
var data QueryChildDivisionCodeRespData
|
||
if err := parseData(commonResp, &data); err != nil {
|
||
return commonResp, nil, err
|
||
}
|
||
return commonResp, &data, nil
|
||
}
|
||
``` |