197 lines
7.7 KiB
Go
197 lines
7.7 KiB
Go
package weimobapi
|
|
|
|
import "git.rosy.net.cn/baseapi/utils"
|
|
|
|
const (
|
|
OrderStatusWait4Pay = 0 // 待支付
|
|
OrderStatusPayed = 1 // 已付款,待发货
|
|
OrderStatusDelivering = 2 // 已发货
|
|
OrderStatusFinished = 3 // 已完成
|
|
OrderStatusCanceled = 4 // 已取消
|
|
)
|
|
|
|
type DeliveryOrderItem struct {
|
|
ItemID int64 `json:"itemId"`
|
|
SkuID int64 `json:"skuId"`
|
|
SkuNum int `json:"skuNum"`
|
|
}
|
|
|
|
type DeliveryOrder struct {
|
|
OrderNo int64 `json:"orderNo"`
|
|
DeliveryNo string `json:"deliveryNo"`
|
|
DeliveryCompanyCode string `json:"deliveryCompanyCode"`
|
|
DeliveryCompanyName string `json:"deliveryCompanyName"`
|
|
IsNeedLogistics bool `json:"isNeedLogistics"`
|
|
IsSplitPackage bool `json:"isSplitPackage"`
|
|
DeliveryRemark string `json:"deliveryRemark"`
|
|
DeliveryOrderItemList []*DeliveryOrderItem `json:"deliveryOrderItemList"`
|
|
}
|
|
|
|
type OrderDetail struct {
|
|
AutoCancelTime int `json:"autoCancelTime"`
|
|
BizInfo struct {
|
|
BizType int `json:"bizType"`
|
|
BizTypeName string `json:"bizTypeName"`
|
|
} `json:"bizInfo"`
|
|
BizSourceType int `json:"bizSourceType"`
|
|
BuyerInfo struct {
|
|
UserNickname string `json:"userNickname"`
|
|
Wid int `json:"wid"`
|
|
} `json:"buyerInfo"`
|
|
BuyerRemark string `json:"buyerRemark"`
|
|
ChannelTypeName string `json:"channelTypeName"`
|
|
CreateTime int64 `json:"createTime"`
|
|
DeliveryAmount float64 `json:"deliveryAmount"`
|
|
DeliveryDetail struct {
|
|
DeliveryType int `json:"deliveryType"`
|
|
DeliveryTypeName string `json:"deliveryTypeName"`
|
|
LogisticsDeliveryDetail struct {
|
|
ExpectDeliveryTime string `json:"expectDeliveryTime"`
|
|
ExpectDeliveryType int `json:"expectDeliveryType"`
|
|
LogisticsOrderList []interface{} `json:"logisticsOrderList"`
|
|
ReceiverAddress string `json:"receiverAddress"`
|
|
ReceiverArea string `json:"receiverArea"`
|
|
ReceiverCity string `json:"receiverCity"`
|
|
ReceiverCounty string `json:"receiverCounty"`
|
|
ReceiverLatitude string `json:"receiverLatitude"`
|
|
ReceiverLongitude string `json:"receiverLongitude"`
|
|
ReceiverMobile string `json:"receiverMobile"`
|
|
ReceiverName string `json:"receiverName"`
|
|
ReceiverProvince string `json:"receiverProvince"`
|
|
ReceiverZip string `json:"receiverZip"`
|
|
} `json:"logisticsDeliveryDetail"`
|
|
} `json:"deliveryDetail"`
|
|
DeliveryPaymentAmount float64 `json:"deliveryPaymentAmount"`
|
|
DiscountInfo struct {
|
|
MerchantDiscountAmount int `json:"merchantDiscountAmount"`
|
|
} `json:"discountInfo"`
|
|
EnableDelivery int `json:"enableDelivery"`
|
|
ExistingInvoice bool `json:"existingInvoice"`
|
|
ExpandLabelInfo struct {
|
|
VirtualWid bool `json:"virtualWid"`
|
|
} `json:"expandLabelInfo"`
|
|
GoodsAmount float64 `json:"goodsAmount"`
|
|
GoodsPromotionInfo struct {
|
|
CycleOrderInfo struct {
|
|
CyclePackageList []interface{} `json:"cyclePackageList"`
|
|
} `json:"cycleOrderInfo"`
|
|
GoodsDistributionType int `json:"goodsDistributionType"`
|
|
PromotionType int `json:"promotionType"`
|
|
} `json:"goodsPromotionInfo"`
|
|
GoodsSellMode int `json:"goodsSellMode"`
|
|
GoodsSourceType int `json:"goodsSourceType"`
|
|
GuideInfo struct {
|
|
GoodsGuideType int `json:"goodsGuideType"`
|
|
} `json:"guideInfo"`
|
|
InvoiceTexAmount int `json:"invoiceTexAmount"`
|
|
InvoiceTexDiscountAmount int `json:"invoiceTexDiscountAmount"`
|
|
InvoiceTexPaymentAmount int `json:"invoiceTexPaymentAmount"`
|
|
ItemList []struct {
|
|
BaseDiscountInfo struct {
|
|
} `json:"baseDiscountInfo"`
|
|
BizInfo struct {
|
|
} `json:"bizInfo"`
|
|
CostPrice float64 `json:"costPrice"`
|
|
GoodsDiscountInfo struct {
|
|
} `json:"goodsDiscountInfo"`
|
|
GoodsID int64 `json:"goodsId"`
|
|
GoodsSellMode int `json:"goodsSellMode"`
|
|
GoodsSourceType int `json:"goodsSourceType"`
|
|
GoodsTitle string `json:"goodsTitle"`
|
|
GoodsType int `json:"goodsType"`
|
|
HadDeliveryItemNum int `json:"hadDeliveryItemNum"`
|
|
ID int `json:"id"`
|
|
ImageURL string `json:"imageUrl"`
|
|
OriginalPrice float64 `json:"originalPrice"`
|
|
PaymentAmount float64 `json:"paymentAmount"`
|
|
PointDeductRatio int `json:"pointDeductRatio"`
|
|
Price float64 `json:"price"`
|
|
PrimaryCategory string `json:"primaryCategory"`
|
|
SecondaryCategory string `json:"secondaryCategory"`
|
|
ShouldPaymentAmount float64 `json:"shouldPaymentAmount"`
|
|
SkuAmount float64 `json:"skuAmount"`
|
|
SkuCode string `json:"skuCode"`
|
|
SkuID int64 `json:"skuId"`
|
|
SkuNum int `json:"skuNum"`
|
|
TagInfo struct {
|
|
ActivityTag []interface{} `json:"activityTag"`
|
|
GoodsBizTag []interface{} `json:"goodsBizTag"`
|
|
} `json:"tagInfo"`
|
|
TotalAmount float64 `json:"totalAmount"`
|
|
WarehouseID int `json:"warehouseId"`
|
|
WarehouseName string `json:"warehouseName"`
|
|
WarehouseType int `json:"warehouseType"`
|
|
} `json:"itemList"`
|
|
MerchantInfo struct {
|
|
MerchantTitle string `json:"merchantTitle"`
|
|
Pid int64 `json:"pid"`
|
|
ProcessStoreID int `json:"processStoreId"`
|
|
ProcessStoreTitle string `json:"processStoreTitle"`
|
|
StoreID int `json:"storeId"`
|
|
StoreTitle string `json:"storeTitle"`
|
|
} `json:"merchantInfo"`
|
|
OperationList []struct {
|
|
Name string `json:"name"`
|
|
OperationType int `json:"operationType"`
|
|
PermissionCode string `json:"permissionCode"`
|
|
} `json:"operationList"`
|
|
OrderNo int64 `json:"orderNo"`
|
|
OrderStatus int `json:"orderStatus"`
|
|
OrderStatusName string `json:"orderStatusName"`
|
|
OrderType int `json:"orderType"`
|
|
PaymentAmount float64 `json:"paymentAmount"`
|
|
PaymentInfo struct {
|
|
PaymentStatus int `json:"paymentStatus"`
|
|
PaymentType int `json:"paymentType"`
|
|
PaymentTypeName string `json:"paymentTypeName"`
|
|
} `json:"paymentInfo"`
|
|
ProcessStoreID int `json:"processStoreId"`
|
|
ProcessStoreTitle string `json:"processStoreTitle"`
|
|
ShouldPaymentAmount float64 `json:"shouldPaymentAmount"`
|
|
StoreTitle string `json:"storeTitle"`
|
|
TotalAmount float64 `json:"totalAmount"`
|
|
TransferStatus int `json:"transferStatus"`
|
|
TransferType int `json:"transferType"`
|
|
UpdateTime int64 `json:"updateTime"`
|
|
}
|
|
|
|
func (a *API) QueryOrderDetail(orderNo int64, needInvoiceInfo bool) (retVal map[string]interface{}, err error) {
|
|
result, err := a.AccessAPI("order/queryOrderDetail", map[string]interface{}{
|
|
"orderNo": orderNo,
|
|
"needInvoiceInfo": needInvoiceInfo,
|
|
})
|
|
if err == nil {
|
|
return result.(map[string]interface{}), nil
|
|
}
|
|
return nil, err
|
|
}
|
|
|
|
func (a *API) QueryOrderDetail2(orderNo int64, needInvoiceInfo bool) (order *OrderDetail, err error) {
|
|
result, err := a.AccessAPI("order/queryOrderDetail", map[string]interface{}{
|
|
"orderNo": orderNo,
|
|
"needInvoiceInfo": needInvoiceInfo,
|
|
})
|
|
if err == nil {
|
|
err = utils.Map2StructByJson(result, &order, false)
|
|
}
|
|
return order, err
|
|
}
|
|
|
|
func (a *API) CancelOrder(orderNo int64, specificCancelReason string) (err error) {
|
|
apiParams := map[string]interface{}{
|
|
"orderNo": orderNo,
|
|
}
|
|
if specificCancelReason != "" {
|
|
apiParams["specificCancelReason"] = specificCancelReason
|
|
}
|
|
_, err = a.AccessAPI("order/cancelOrder", apiParams)
|
|
return err
|
|
}
|
|
|
|
func (a *API) DeliveryOrder(orderDeliveryInfo *DeliveryOrder) (err error) {
|
|
apiParams := utils.Struct2MapByJson(orderDeliveryInfo)
|
|
// baseapi.SugarLogger.Debug(utils.Format4Output(apiParams, false))
|
|
_, err = a.AccessAPI("order/deliveryOrder", apiParams)
|
|
return err
|
|
}
|