353 lines
19 KiB
Go
353 lines
19 KiB
Go
package ebaiapi
|
||
|
||
import "time"
|
||
|
||
const (
|
||
MerchantOrderReverseApplyCancel = "1" // 商户发起全退
|
||
MerchantOrderReverseApplyPartCancel = "2" // 商户发起部分退款
|
||
)
|
||
|
||
const (
|
||
OrderCommodityType = "4" // 商品子单类型 1:称重品、2:标品、3:按件称重、4:虚拟商品子单
|
||
OrderVirtualType = "0" // 商品类型为虚拟商品是有效;0:普通实物商品 1:包装费子单 2:处方服务费子单、3:附加0.01费子单、4:配送费子单
|
||
)
|
||
|
||
const (
|
||
OrderDeliveryStatusCreate = 1 // 生成运单
|
||
OrderDeliveryStatusWaitRider = 2 // 配送待分配
|
||
OrderDeliveryStatusReceived = 3 // 骑士接单
|
||
OrderDeliveryStatusToStore = 8 // 骑手到店
|
||
OrderDeliveryStatusSend = 20 // 骑手送出
|
||
OrderDeliveryStatusSendOver = 30 // 配送完成
|
||
OrderDeliveryStatusCancel = 6 // 配送取消
|
||
OrderDeliveryStatusAbnormal = 7 // 配送异常
|
||
OrderDeliveryStatusRefusal = 110 // 配送拒单
|
||
)
|
||
|
||
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
|
||
SubBizOrderID string `json:"sub_biz_order_id"`
|
||
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"`
|
||
}
|
||
|
||
type PushRiderInfo struct {
|
||
DistributorId int `json:"distributor_id"` // 固定值:201
|
||
Knight Knight `json:"knight"`
|
||
OrderId string `json:"order_id"` // 订单id
|
||
State int `json:"state"` // 配送状态,传固定值:21 开始配送(已废弃,已接入商家不影响)
|
||
SelfStatus int `json:"selfStatus"` // 配送状态 1:生成运单 2:配送待分配3:骑士接单(必传)8:骑士到店(必传)20:骑手送出(必传)30:配送完成(必传)6:配送取消(必传)7:配送异常(必传)101:配送拒单
|
||
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"` // 配送商电话
|
||
}
|
||
|
||
// RefundOrderExamine 商家审核是售后单
|
||
type RefundOrderExamine struct {
|
||
ReverseOrderId string `json:"reverse_order_id" required:"true"` // 逆向单ID
|
||
OrderId string `json:"order_id" required:"true"` // 订单id
|
||
IdempotentId string `json:"idempotent_id" required:"true"` // 请求唯一标示
|
||
ActionType string `json:"action_type" required:"true"` // 逆向单审批操作类型,枚举值:【1-同意全单/部分退款申请 、 2-拒绝全单/部分退款申请、 3-同意退货申请 、 4-拒绝退货申请】
|
||
ReasonCode string `json:"reason_code" required:"false"` // 当拒绝场景必填,即action_type = 2 or action_type =4 时 必填,枚举值: 7019-双方协商一致不再取消订单、 7020-商品已经备货完成、 7021-商品已送出、 7802-商品发出时完好、 7803-用户未举证/举证无效、 7804-商品影响二次销售、 7805-商品不符合7天无理由退款、 7302-未收到退货(仅退货单支持传入该code)、 7001-其他原因
|
||
ReasonRemarks string `json:"reason_remarks" required:"false"` // 原因备注说明信息
|
||
RefundProductList []*RefundProductList `json:"refund_product_list" required:"false"` // 订单id
|
||
}
|
||
|
||
type RefundProductList struct {
|
||
SubBizOrderId string `json:"sub_biz_order_id" required:"false"` // 商品子单ID
|
||
PlatformSkuId string `json:"platform_sku_id" required:"false"` // 平台商品ID
|
||
Number string `json:"number"`
|
||
RefundAmount string `json:"refund_amount"`
|
||
}
|
||
|
||
// OrderReverseApplyParam 商家发起取消订单或者部分退款
|
||
type OrderReverseApplyParam struct {
|
||
OrderId string `json:"order_id"` // 订单号
|
||
IdempotentId string `json:"idempotent_id"` // 幂等id (商家自定义,同一操作重试需保证幂等Id一致)
|
||
RefundType string `json:"refund_type"` // 申请退款类型, 枚举值:1 全退 , 2 部分退(按商品部分退),如 部分退(2) 则 refund_product_list 参数不能为空
|
||
ReasonCode string `json:"reason_code"` // 发起退款原因 code,枚举值:7015-商品已售完、 7017-无骑手接单/无运力、 7053-骑手无法配送、 7054-无法联系到用户(未接听、关机、号码错误)、 7018-商户暂时不营业、 7070-拣货人力不足、 7908-补差退款、 7001-其他原因、 7052-药师审核处方笺不通过(仅支持医药处方订单)、7080-包装费退款(仅支持订单级包装费可选)
|
||
ReasonRemarks string `json:"reason_remarks"` // 详细原因信息,reason_code为7001时必填
|
||
NeedIvrUser int64 `json:"need_ivr_user"` // 非必填,reason_code为7015 缺货售中部分取消退款场景,是否需要平台外呼通知用户,仅refund_type=2时 传入有效;枚举值: 1:通知 , 0 or null :不通知
|
||
RefundProductList []*RefundProductListParam `json:"refund_product_list"` // 申请退款商品列表信息(非必填),部分退( refund_type = 2)时,refund_product_list 必填
|
||
}
|
||
|
||
// RefundProductListParam 申请退款商品列表信息
|
||
type RefundProductListParam struct {
|
||
SubBizOrderId string `json:"sub_biz_order_id"` // 子单ID,对应订单中商品唯一ID
|
||
PlatformSkuId string `json:"platform_sku_id"` // 平台商品ID
|
||
Number string `json:"number"` // 申请退款件数(整型),范围:1-商品最大可退(通过order.reverse.consult接口查询),称重品金支持按金额退款,需指定refund_amount进行退款,传入数量无效
|
||
RefundAmount string `json:"refund_amount"` // 申请退款金额(单位 分,整型)
|
||
FundCalculateType string `json:"fund_calculate_type"` // 非必填,部分退类型:0按件数退,1按照金额退, 默认为按件数退(0); 按件退 number字段必传, 按金额退 refund_amount字段必传
|
||
}
|
||
|
||
// OrderSelfDeliveryLocationSync 自配送订单骑手位置回传
|
||
type OrderSelfDeliveryLocationSync struct {
|
||
OrderId string `json:"order_id"` // 订单号
|
||
Location *RiderLocation `json:"location"`
|
||
}
|
||
|
||
// RiderLocation 骑手坐标
|
||
type RiderLocation struct {
|
||
UTC string `json:"utc"` // 当前时间,格式:10位时间戳
|
||
Altitude string `json:"altitude"` // 海拔高度,如无,可传入固定值
|
||
Latitude string `json:"latitude"` // 纬度,建议使用高德坐标 39.90038
|
||
Longitude string `json:"longitude"` // 经度,建议使用高德坐标 116.389149
|
||
}
|
||
|
||
// ReverseSkuList 售后单信息详情获取
|
||
type ReverseSkuList struct {
|
||
ApplyQuantity int `json:"apply_quantity"` // 申请数量
|
||
ApplyRefundTime int64 `json:"apply_refund_time"` // 申请时间
|
||
ApplyRefundUserAmount int `json:"apply_refund_user_amount"` // 子订单用户申请金额
|
||
CommodityType int `json:"commodity_type"` // 商品子单类型, 1:称重品、2:标品、3:按件称重、4:虚拟商品子单
|
||
CustomSkuId string `json:"custom_sku_id"` // 商品自定义id
|
||
CustomSkuSpecId string `json:"custom_sku_spec_id"` // 商品多规格自定义id
|
||
FreeGift bool `json:"free_gift"` // 是否是赠品子单,true 是, false 否
|
||
FundCalculateType int `json:"fund_calculate_type"` // 商品子单 退款算价类型 ,枚举值:0按件数退,1按照金额退
|
||
GiftRelatedSubBizOrderIdList []interface{} `json:"gift_related_sub_biz_order_id_list"` // 赠品子单关联的主品子单Id列表 (free_gift = true 时,有效)
|
||
IsCombine bool `json:"is_combine"` // 是否为组合品
|
||
LastRefundStatus int `json:"last_refund_status"` // 该退单的上一个退款状态:0初始化,10申请,20拒绝,30仲裁,40关闭,50成功,60失败
|
||
PlatformSkuId int64 `json:"platform_sku_id"` // 饿了么商品ID
|
||
RefundOrderId int64 `json:"refund_order_id"` // 零售退款单ID
|
||
RefundQuantity int `json:"refund_quantity"` // 商家同意件数,件数单位:整型
|
||
RefundStatus int `json:"refund_status"` // 商品子单本次退款状态,枚举值:10 申请;20 拒绝;30 仲裁;40 关闭;50 成功;60 失败
|
||
RefundUserAmount int `json:"refund_user_amount"` // 该逆向单实际退款给用户的金额,单位分
|
||
RefundWeight int `json:"refund_weight"` // 商品子单退款额重量信息, 单位:g
|
||
SkuName string `json:"sku_name"` // sku 商品名称
|
||
SkuSpecId string `json:"sku_spec_id"` // 多规格商品id
|
||
SubBizOrderId string `json:"sub_biz_order_id"` // 商品子单唯一标识
|
||
Upc string `json:"upc"` // upc
|
||
VirtualType string `json:"virtual_type"` // 0:普通实物商品 1:包装费子单 2:处方服务费子单、3:附加0.01费子单、4:配送费子单
|
||
DiscountDetail struct {
|
||
AgentDiscountAmount int `json:"agent_discount_amount"` // 本次退款总金额中 包含的【代理商】承担金额,单位:分
|
||
DiscountTotalAmount int `json:"discount_total_amount"` // 本次退款总金额中的补贴总额,单位:分
|
||
MerchantDiscountAmount int `json:"merchant_discount_amount"` // 本次退款总金额中 包含的【商家】承担金额,单位:分
|
||
PlatformDiscountAmount int `json:"platform_discount_amount"` // 本次退款总金额中 包含的【平台】承担金额,单位:分
|
||
TotalPrice int `json:"total_price"` // 商品原总价 = (用户实付 + 补贴总额 discount_total_amount )
|
||
UserDiscountAmount int `json:"user_discount_amount"` // 本次退款总金额中 包含的【用户】承担金额,单位:分
|
||
} `json:"discount_detail"` // 商品子单的退款分摊明细详情
|
||
}
|