647 lines
22 KiB
Go
647 lines
22 KiB
Go
package ebaiapi
|
||
|
||
import (
|
||
"fmt"
|
||
"time"
|
||
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
)
|
||
|
||
const (
|
||
CancelTypeNotInServiceArea = "1"
|
||
CancelTypeShopClosed = "2"
|
||
CancelTypeSoldOut = "3"
|
||
CancelTypePriceChanged = "4"
|
||
CancelTypeClientCanceled = "5"
|
||
CancelTypeDuplicatedOrder = "6"
|
||
CancelTypeTooBusy = "7"
|
||
CancelTypeCanNotContactClient = "8"
|
||
CancelTypeFakeOrder = "9"
|
||
CancelTypePushOrderFailed = "53"
|
||
CancelTypeCustom = "-1"
|
||
)
|
||
|
||
const (
|
||
OrderStatusNew = "1"
|
||
OrderStatusAccepted = "5" // 订单确认
|
||
OrderStatusCourierAccepted = "7" // 骑士已接单开始取餐(此时可通过订单详情接口获取骑士手机号)
|
||
OrderStatusCourierPickedup = "8" // 骑士已取餐正在配送
|
||
OrderStatusFinished = "9" // 订单完成
|
||
OrderStatusCanceled = "10" // 订单取消
|
||
OrderStatusRefund = "15" // 订单退款,这个是售后之后的事件,不应该当成正常订单事件处理
|
||
)
|
||
|
||
const (
|
||
WaybillStatusNew = "2" // 生成运单
|
||
WaybillStatusRequestDelivery = "3" // 请求配送
|
||
WaybillStatusWait4Courier = "4" // 等待分配骑士
|
||
WaybillStatusCourierAccepted = "7" // 骑士接单
|
||
WaybillStatusCourierPickedup = "8" // 骑士取餐
|
||
// 饿百在发送运单取消事件后,如果订单没有及时(具体时间未知)转出自送,则订单会被取消,且不会发送订单取消事件
|
||
// https://open-be.ele.me/dev/answer/reedit?list_id=23667&question=my
|
||
WaybillStatusDeliveryCancled = "15" // 配送取消
|
||
WaybillStatusFinished = "16" // 配送完成
|
||
WaybillStatusExceptional = "17" // 配送异常
|
||
WaybillStatusSelfDelivery = "18" // 自行配送
|
||
WaybillStatusDontDeliver = "19" // 不再配送
|
||
WaybillStatusDeliveryRejected = "20" // 配送拒单
|
||
WaybillStatusCourierArrived = "21" // 骑士到店
|
||
)
|
||
|
||
const (
|
||
// 订单下行 - order.partrefund.push-部分退款订单信息推送
|
||
OrderPartRefuncTypeMerchant = 1 // 表示商户发起的部分退款
|
||
OrderPartRefuncTypeCustomer = 2 // 表示用户发起的部分退款
|
||
OrderPartRefuncTypeCS = 3 // 表示客服直接发起的部分退款
|
||
|
||
OrderPartRefundApply = 10 // 表示商家/用户发起部分退款申请
|
||
OrderPartRefundSuccess = 20 // 表示部分退款成功
|
||
OrderPartRefundUserApplyArbitration = 30 // 用户申请仲裁,客服介入
|
||
OrderPartRefundFailed = 40 // 表示部分退款失败
|
||
OrderPartRefundMerchantRefused = 50 // 表示商家拒绝用户发起的部分退款申请
|
||
|
||
// 订单下行 - order.user.cancel-用户申请订单取消/退款
|
||
OrderUserCancelApply = 10 // 发起申请
|
||
OrderUserCancelCSIntervene = 20 // 客服介入
|
||
OrderUserCancelCSRefused = 30 // 客服拒绝
|
||
OrderUserCancelCSAgreed = 40 // 客服同意
|
||
OrderUserCancelMerchantRefused = 50 // 商户拒绝
|
||
OrderUserCancelMerchantAgreed = 60 // 商家同意
|
||
OrderUserCancelInvalid = 70 // 申请失效
|
||
|
||
OrderUserCancelTypeBeforeSale = 1 // 表示订单完成前用户全单取消申请流程
|
||
OrderUserCancelTypeAfterSale = 2 // 表示订单完成后用户全单退款申请流程
|
||
)
|
||
|
||
const (
|
||
OrderFromBaidu = "1"
|
||
OrderFromElm = "2"
|
||
|
||
OrderSkuDiscountTypeZhe = "g_zhe"
|
||
OrderSkuDiscountTypeReduce = "g_reduce"
|
||
OrderSkuDiscountTypeTe = "g_te"
|
||
OrderSkuDiscountTypeZeng = "zeng"
|
||
)
|
||
|
||
const (
|
||
UserApplyCancelWaitMinute = 15 // 用户申请取消订单后待处理的最大等待时间(分钟),超时自动同意
|
||
)
|
||
|
||
const (
|
||
ListOrderPageSize = 100 // order.list的每页条数
|
||
)
|
||
|
||
type ExpressInfo struct {
|
||
OrderID string `json:"order_id"`
|
||
ExpressID string `json:"express_id"`
|
||
ExpressCompany string `json:"express_company"`
|
||
}
|
||
|
||
type PrivateMobileInfo struct {
|
||
ShortNumber string `json:"short_number"`
|
||
ExpireDate *time.Time `json:"expire_date"`
|
||
}
|
||
|
||
type RefundSku struct {
|
||
SkuID string `json:"sku_id,omitempty"`
|
||
Upc string `json:"upc,omitempty"`
|
||
CustomeSkuID string `json:"custom_sku_id,omitempty"`
|
||
Number string `json:"number"`
|
||
}
|
||
|
||
type ProductSubsidyInfo struct {
|
||
AgentRate int `json:"agent_rate"`
|
||
BaiduRate int `json:"baidu_rate"`
|
||
Discount int `json:"discount"`
|
||
DiscountDetail []*struct {
|
||
ActivityID string `json:"activity_id"`
|
||
BaiduRate int `json:"baidu_rate"`
|
||
ShopRate int `json:"shop_rate"`
|
||
Type string `json:"type"`
|
||
} `json:"discount_detail"`
|
||
LogisticsRate int `json:"logistics_rate"`
|
||
ShopRate int `json:"shop_rate"`
|
||
UserRate int `json:"user_rate"`
|
||
}
|
||
|
||
type OrderProductInfo struct {
|
||
BaiduProductID string `json:"baidu_product_id"`
|
||
SkuID string `json:"sku_id"` // 部分退款信息中是这个而不是BaiduProductID
|
||
|
||
CustomSkuID string `json:"custom_sku_id"`
|
||
|
||
PackageAmount int `json:"package_amount"`
|
||
PackageFee int `json:"package_fee"`
|
||
PackagePrice int `json:"package_price"`
|
||
PrescriptionID string `json:"prescription_id"`
|
||
|
||
ProductAmount int `json:"product_amount"`
|
||
Number int `json:"number"` // 部分退款信息中是这个而不是ProductAmount
|
||
|
||
ProductAttr []interface{} `json:"product_attr"`
|
||
ProductCustomIndex string `json:"product_custom_index"`
|
||
ProductFeatures []interface{} `json:"product_features"`
|
||
ProductFee int `json:"product_fee"`
|
||
ProductName string `json:"product_name"`
|
||
ProductPrice int `json:"product_price"`
|
||
ProductSubsidy *ProductSubsidyInfo `json:"product_subsidy"`
|
||
ProductType int `json:"product_type"`
|
||
SupplyType int `json:"supply_type"`
|
||
TotalFee int `json:"total_fee"`
|
||
TotalWeight int `json:"total_weight"`
|
||
Upc string `json:"upc"`
|
||
WeightType int `json:"weight_type"`
|
||
}
|
||
|
||
type OrderDiscountInfo struct {
|
||
ActivityID string `json:"activity_id"`
|
||
AgentRate int `json:"agent_rate"`
|
||
BaiduRate int `json:"baidu_rate"`
|
||
Desc string `json:"desc"`
|
||
Fee int `json:"fee"`
|
||
LogisticsRate int `json:"logistics_rate"`
|
||
Products []*struct {
|
||
ActivityID string `json:"activity_id"`
|
||
ActivityProductNum int `json:"activity_product_num"`
|
||
BaiduProductID int64 `json:"baidu_product_id"`
|
||
NowPrice int `json:"now_price"`
|
||
OrigPrice int `json:"orig_price"`
|
||
SavePrice int `json:"save_price"`
|
||
} `json:"products,omitempty"`
|
||
RuleID string `json:"rule_id"`
|
||
ShopRate int `json:"shop_rate"`
|
||
Type string `json:"type"`
|
||
}
|
||
|
||
type OrderDetailInfo struct {
|
||
Discount []*OrderDiscountInfo `json:"discount"`
|
||
Order *struct {
|
||
AtshopTime int `json:"atshop_time"`
|
||
CancelTime string `json:"cancel_time"`
|
||
ColdBoxFee string `json:"cold_box_fee"`
|
||
Commission int `json:"commission"`
|
||
ConfirmTime string `json:"confirm_time"`
|
||
CreateTime string `json:"create_time"`
|
||
DeliveryParty int `json:"delivery_party"` // 此字段会在配送变化后变化
|
||
DeliveryPhone string `json:"delivery_phone"`
|
||
DeliveryTime int `json:"delivery_time"`
|
||
DiscountFee int `json:"discount_fee"`
|
||
DownFlag int `json:"down_flag"`
|
||
ElemeOrderID string `json:"eleme_order_id"`
|
||
ExpectTimeMode int `json:"expect_time_mode"`
|
||
Ext struct {
|
||
TaoxiFlag int `json:"taoxi_flag"`
|
||
} `json:"ext"`
|
||
FinishedTime string `json:"finished_time"`
|
||
InvoiceTitle string `json:"invoice_title"`
|
||
IsColdBoxOrder int `json:"is_cold_box_order"`
|
||
IsPrivate int `json:"is_private"`
|
||
LatestSendTime int `json:"latest_send_time"`
|
||
MealNum string `json:"meal_num"`
|
||
NeedInvoice int `json:"need_invoice"`
|
||
OrderFlag int `json:"order_flag"`
|
||
OrderFrom string `json:"order_from"`
|
||
OrderID string `json:"order_id"`
|
||
OrderIndex string `json:"order_index"`
|
||
PackageFee int `json:"package_fee"`
|
||
PayStatus int `json:"pay_status"`
|
||
PayType int `json:"pay_type"`
|
||
PickupTime int `json:"pickup_time"`
|
||
Remark string `json:"remark"`
|
||
// ResponsibleParty string `json:"responsible_party"`
|
||
SendFee int `json:"send_fee"`
|
||
SendImmediately int `json:"send_immediately"`
|
||
SendTime int `json:"send_time"`
|
||
ShopFee int `json:"shop_fee"`
|
||
Status int `json:"status"`
|
||
TaxerID string `json:"taxer_id"`
|
||
TotalFee int `json:"total_fee"`
|
||
UserFee int `json:"user_fee"`
|
||
} `json:"order"`
|
||
Products [][]*OrderProductInfo `json:"products"`
|
||
Shop *struct {
|
||
BaiduShopID string `json:"baidu_shop_id"`
|
||
ID string `json:"id"`
|
||
Name string `json:"name"`
|
||
} `json:"shop"`
|
||
Source string `json:"source"`
|
||
User *struct {
|
||
Address string `json:"address"`
|
||
// City string `json:"city"`
|
||
Coord *struct {
|
||
Latitude string `json:"latitude"`
|
||
Longitude string `json:"longitude"`
|
||
} `json:"coord"`
|
||
CoordAmap *struct {
|
||
Latitude string `json:"latitude"`
|
||
Longitude string `json:"longitude"`
|
||
} `json:"coord_amap"`
|
||
// District string `json:"district"`
|
||
Gender string `json:"gender"`
|
||
Name string `json:"name"`
|
||
Phone string `json:"phone"`
|
||
PrivacyPhone string `json:"privacy_phone"`
|
||
// Province string `json:"province"`
|
||
UserID string `json:"user_id"`
|
||
} `json:"user"`
|
||
}
|
||
|
||
type RefundOrderDetailInfo struct {
|
||
CustomSkuID string `json:"custom_sku_id"`
|
||
Name string `json:"name"`
|
||
Number int `json:"number"`
|
||
ProductFeatures []interface{} `json:"product_features"`
|
||
ProductFee int `json:"product_fee"`
|
||
ProductPrice int `json:"product_price"`
|
||
ProductSubsidy *ProductSubsidyInfo `json:"product_subsidy"`
|
||
SkuID string `json:"sku_id"`
|
||
TotalWeight int `json:"total_weight"`
|
||
Upc string `json:"upc"`
|
||
}
|
||
|
||
type RefundDetailInfo struct {
|
||
ApplyTime string `json:"apply_time"`
|
||
CustomSkuID string `json:"custom_sku_id"`
|
||
Desc string `json:"desc"`
|
||
Name string `json:"name"`
|
||
Number int `json:"number"`
|
||
RefundID string `json:"refund_id"`
|
||
ShopEleRefund int `json:"shop_ele_refund"`
|
||
SkuID string `json:"sku_id"`
|
||
Status int `json:"status"`
|
||
TotalRefund int `json:"total_refund"`
|
||
Type int `json:"type"`
|
||
Upc string `json:"upc"`
|
||
}
|
||
|
||
type PartRefundInfo struct {
|
||
Commission int `json:"commission"`
|
||
Fee int `json:"fee"`
|
||
OrderDetail []*RefundOrderDetailInfo `json:"order_detail"`
|
||
OrderID string `json:"order_id"`
|
||
PackageFee int `json:"package_fee"`
|
||
RefundDetail []*RefundDetailInfo `json:"refund_detail"`
|
||
RefundPrice int `json:"refund_price"`
|
||
SendFee int `json:"send_fee"`
|
||
ShopFee int `json:"shop_fee"`
|
||
TotalPrice int `json:"total_price"`
|
||
Type int `json:"type"`
|
||
UserFee int `json:"user_fee"`
|
||
}
|
||
|
||
type ListOrderItemInfo struct {
|
||
BaiduShopID int64 `json:"baidu_shop_id"`
|
||
CreateTime int64 `json:"create_time"`
|
||
OrderFrom int `json:"order_from"`
|
||
OrderID string `json:"order_id"`
|
||
OrderStatus int `json:"order_status"`
|
||
PayStatus int `json:"pay_status"`
|
||
PayType int `json:"pay_type"`
|
||
ShopID string `json:"shop_id"`
|
||
Status int `json:"status"`
|
||
UserPhone string `json:"user_phone"`
|
||
}
|
||
|
||
type ListOrderInfo struct {
|
||
Total int `json:"total"`
|
||
Page int `json:"Page"`
|
||
Pages int `json:"pages"`
|
||
List []*ListOrderItemInfo `json:"list"`
|
||
}
|
||
|
||
// 提供给合作方确认订单所用。 注:1、10分钟内未确认的订单系统自动取消。2、确认失败的订单请不要做餐。 2016年7月4号起,将由百度外卖负责完成订单。届时,对接方无需调用完成订单接口,继续调用可能导致订单结算有问题。
|
||
func (a *API) OrderConfirm(orderID string) (err error) {
|
||
data, err := a.AccessAPI("order.confirm", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
fmt.Println(data)
|
||
return err
|
||
}
|
||
|
||
// 仅择时达和新零售标品服务包的订单,商家可调用此接口将订单置为已拣货完成状态。订单超过预计拣货完成时间未调用此接口,系统会自动更新为已拣货完成状态。
|
||
// https://open-be.ele.me/dev/api/doc/v3/#api-Order_Up-order_pickcomplete
|
||
func (a *API) OrderPickComplete(orderID string) (err error) {
|
||
_, err = a.AccessAPI("order.pickcomplete", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
// 提供给合作方取消订单所用。 注:1、百度物流配送且已经确认的订单无法取消。
|
||
func (a *API) OrderCancel(orderID, cancelType, cancelReason string) (err error) {
|
||
_, err = a.AccessAPI("order.cancel", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"type": cancelType,
|
||
"reason": cancelReason,
|
||
})
|
||
return err
|
||
}
|
||
|
||
// 蜂鸟众包订单呼叫骑士配送,仅限蜂鸟众包商户调用
|
||
func (a *API) OrderCallDelivery(orderID string) (err error) {
|
||
_, err = a.AccessAPI("order.callDelivery", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
// 蜂鸟众包订单取消呼叫骑士配送,仅限蜂鸟众包商户调用。
|
||
func (a *API) OrderCancelDelivery(orderID string) (err error) {
|
||
_, err = a.AccessAPI("order.cancelDelivery", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
//饿了么自配送订单接入骑手状态
|
||
func (a *API) OrderselfDeliveryStateSync(orderID, phone string) (err error) {
|
||
_, err = a.AccessAPI("order.selfDeliveryStateSync", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"phone": phone,
|
||
"distributor_id": 201,
|
||
"state": 21,
|
||
})
|
||
return err
|
||
}
|
||
|
||
type PushRiderInfo struct {
|
||
DistributorId int `json:"distributor_id"` // 固定值:201
|
||
Knight Knight `json:"knight"`
|
||
OrderId string // 订单id
|
||
State int // 配送状态,传固定值:21 开始配送(已废弃,已接入商家不影响)
|
||
SelfStatus int `json:"selfStatus"` // 配送状态
|
||
SelfStatusDesc string `json:"selfStatusDesc"` // 配送状态文案描述
|
||
SelfSubStatus int `json:"selfSubStatus"` // 配送取消(6)子原因:
|
||
SelfSubStatusDesc string `json:"selfSubStatusDesc"` // 配送异常子状态文案描述
|
||
DistributorInfoDTO DistributorInfoDTO `json:"distributorInfoDTO"` // 配送服务商信息
|
||
}
|
||
type Knight struct {
|
||
Id int64 `json:"id"` // 骑手id,商家自定义
|
||
Name string `json:"name"` // 骑手姓名
|
||
Phone string `json:"phone"` // 骑手手机号码
|
||
}
|
||
|
||
type DistributorInfoDTO struct {
|
||
DistributorTypeId string `json:"distributorTypeId"` // 配送商类型id:
|
||
DistributorName string `json:"distributorName"` // 配送商名称
|
||
DistributorPhone string `json:"distributorPhone"` // 配送商电话
|
||
}
|
||
|
||
// OrderselfDeliveryStateSync2 饿了么自配送订单接入骑手状态
|
||
func (a *API) OrderselfDeliveryStateSync2(info *PushRiderInfo) (err error) {
|
||
_, err = a.AccessAPI("order.selfDeliveryStateSync", utils.Struct2MapByJson(info))
|
||
return err
|
||
}
|
||
|
||
// 饿了么自配送订单回传订单已送出状态
|
||
// 此接口目前只支持饿了么侧订单调用
|
||
func (a *API) OrderSendOut(orderID, phone string) (err error) {
|
||
_, err = a.AccessAPI("order.sendout", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"phone": phone,
|
||
})
|
||
return err
|
||
}
|
||
|
||
// 饿了么自配送订单回传订单送达状态,调用成功后订单状态变为已完成。需先调用订单送出接口,且接单5分钟后可调用
|
||
func (a *API) OrderComplete(orderID, phone string) (err error) {
|
||
_, err = a.AccessAPI("order.complete", map[string]interface{}{
|
||
"order_id": orderID,
|
||
// "phone": phone,
|
||
})
|
||
return err
|
||
}
|
||
|
||
// 提供给合作方在配送异常或物流拒单后选择自行配送
|
||
func (a *API) OrderSwitchselfdelivery(orderID string) (err error) {
|
||
_, err = a.AccessAPI("order.switchselfdelivery", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
// 查看订单详情
|
||
func (a *API) OrderGet(orderID string) (orderMap map[string]interface{}, err error) {
|
||
result, err := a.AccessAPI("order.get", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
if err == nil {
|
||
return result.Data.(map[string]interface{}), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) OrderGet2(orderID string) (order *OrderDetailInfo, err error) {
|
||
result, err := a.AccessAPI("order.get", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
if err == nil {
|
||
err = utils.Map2StructByJson(result.Data, &order, true)
|
||
}
|
||
return order, err
|
||
}
|
||
|
||
func (a *API) OrderStatusGet(orderID string) (status int, err error) {
|
||
result, err := a.AccessAPI("order.status.get", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
if err == nil {
|
||
status = int(utils.ForceInterface2Int64(result.Data.(map[string]interface{})["status"]))
|
||
}
|
||
return status, err
|
||
}
|
||
|
||
// 设置订单快递单号
|
||
func (a *API) OrderExpressCreate(shopID string, expressList []*ExpressInfo) (status int, err error) {
|
||
result, err := a.AccessAPI("order.express.create", map[string]interface{}{
|
||
KeyShopID: shopID,
|
||
"express_list": expressList,
|
||
})
|
||
if err == nil {
|
||
return int(utils.MustInterface2Int64(result.Data.(map[string]interface{})["status"])), nil
|
||
}
|
||
return 0, err
|
||
}
|
||
|
||
func (a *API) OrderPrivateInfo(orderID string) (mobileInfo *PrivateMobileInfo, err error) {
|
||
result, err := a.AccessAPI("order.privateinfo", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
if err == nil {
|
||
mapData := result.Data.(map[string]interface{})
|
||
mobileInfo = &PrivateMobileInfo{
|
||
ShortNumber: mapData["short_number"].(string),
|
||
}
|
||
expireDate := utils.Interface2String(mapData["expire_date"])
|
||
if expireDate != "" {
|
||
tmpTime := utils.Str2Time(expireDate)
|
||
mobileInfo.ExpireDate = &tmpTime
|
||
}
|
||
return mobileInfo, nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) OrderDeliveryGet(orderID string) (deliveryInfo map[string]interface{}, err error) {
|
||
result, err := a.AccessAPI("order.delivery.get", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
if err == nil {
|
||
return result.Data.(map[string]interface{}), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
func (a *API) OrderIdConvert(orderID string, isElemeOrder bool) (convertedOrderID string, err error) {
|
||
key := "order_id"
|
||
resultKey := "eleme_order_id"
|
||
if isElemeOrder {
|
||
key = "eleme_order_id"
|
||
resultKey = "order_id"
|
||
}
|
||
result, err := a.AccessAPI("order.id.convert", map[string]interface{}{
|
||
key: orderID,
|
||
})
|
||
if err == nil {
|
||
return utils.Interface2String(result.Data.(map[string]interface{})[resultKey]), nil
|
||
}
|
||
return "", err
|
||
}
|
||
|
||
// 查看订单列表
|
||
// https://open-be.ele.me/dev/api/doc/v3/#api-Order_Up-order_list
|
||
// page从1开始
|
||
func (a *API) OrderList(shopID string, baiduShopID int64, startTime, endTime int64, status int, page int) (listOrderInfo *ListOrderInfo, err error) {
|
||
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||
if startTime > 0 {
|
||
params["start_time"] = startTime
|
||
}
|
||
if endTime > 0 {
|
||
params["end_time"] = endTime
|
||
}
|
||
if status > 0 {
|
||
params["status"] = status
|
||
}
|
||
if page > 0 {
|
||
params["page"] = page
|
||
}
|
||
result, err := a.AccessAPI("order.list", params)
|
||
if err == nil {
|
||
err = utils.Map2StructByJson(result.Data, &listOrderInfo, true)
|
||
}
|
||
return listOrderInfo, err
|
||
}
|
||
|
||
func (a *API) OrderListAll(shopID string, baiduShopID int64, startTime, endTime int64, status int) (listOrder []*ListOrderItemInfo, err error) {
|
||
page := 1
|
||
for {
|
||
result, err := a.OrderList(shopID, baiduShopID, startTime, endTime, status, page)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
listOrder = append(listOrder, result.List...)
|
||
if result.Page >= result.Pages {
|
||
break
|
||
}
|
||
page++
|
||
}
|
||
return listOrder, nil
|
||
}
|
||
|
||
// 查看部分退款订单详情
|
||
func (a *API) OrderPartRefundGet(orderID string) (orderMap map[string]interface{}, err error) {
|
||
result, err := a.AccessAPI("order.partrefund.get", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
if err == nil {
|
||
return result.Data.(map[string]interface{}), nil
|
||
}
|
||
return nil, err
|
||
}
|
||
|
||
// func (a *API) OrderPartRefundGet2(orderID string) (partRefundInfo *CBPartRefundInfo, err error) {
|
||
// result, err := a.OrderPartRefundGet(orderID)
|
||
// if err == nil {
|
||
// err = utils.Map2StructByJson(result, &partRefundInfo, true)
|
||
// }
|
||
// return partRefundInfo, err
|
||
// }
|
||
|
||
func (a *API) SmartOrderIdConvert(orderID string) (convertedOrderID string, err error) {
|
||
return a.OrderIdConvert(orderID, isOrderIDEleme(orderID))
|
||
}
|
||
|
||
func isOrderIDEleme(orderID string) bool {
|
||
return len(orderID) == len("3026328756122155111")
|
||
}
|
||
|
||
func (a *API) OrderAgreeRefund(orderID string) (err error) {
|
||
_, err = a.AccessAPI("order.agreerefund", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderDisagreeRefund(orderID, refuseReason string) (err error) {
|
||
_, err = a.AccessAPI("order.disagreerefund", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"refuse_reason": refuseReason,
|
||
})
|
||
return err
|
||
}
|
||
|
||
//售后 同意用户多次部分取消
|
||
func (a *API) OrderPartRefund(orderID string, removeSkuList []*RefundSku) (err error) {
|
||
_, err = a.AccessAPI("order.manyTimesPartrefund", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"products": removeSkuList,
|
||
})
|
||
return err
|
||
}
|
||
|
||
//售后 同意用户多次部分取消
|
||
func (a *API) OrderAgreePartRefund(orderID string, removeSkuList []*RefundSku, refundID string) (err error) {
|
||
_, err = a.AccessAPI("order.agreepartrefund", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"products": removeSkuList,
|
||
"refund_id": refundID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
//售后 同意退货退款
|
||
func (a *API) OrderAgreeReturnGoods(orderID, refundOrderID string) (err error) {
|
||
_, err = a.AccessAPI("order.agreereturngoods", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"refund_order_id": refundOrderID,
|
||
})
|
||
return err
|
||
}
|
||
|
||
//售后 拒绝退货退款
|
||
func (a *API) OrderDisagreeReturnGoods(orderID, refundOrderID, reason string) (err error) {
|
||
data, err := a.AccessAPI("order.disagreereturngoods", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"refund_order_id": refundOrderID,
|
||
"refuse_code": "5",
|
||
"refuse_reason": reason,
|
||
})
|
||
fmt.Println(data)
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderCheckout(orderID, pickUpCode string) (err error) {
|
||
_, err = a.AccessAPI("order.checkout", map[string]interface{}{
|
||
"order_id": orderID,
|
||
"pick_up_code": pickUpCode,
|
||
})
|
||
return err
|
||
}
|
||
|
||
func (a *API) OrderQueryAcceptancecode(orderID string) (err error) {
|
||
_, err = a.AccessAPI("order.query.acceptancecode", map[string]interface{}{
|
||
"order_id": orderID,
|
||
})
|
||
return err
|
||
}
|