添加美团配送运费获取
This commit is contained in:
@@ -553,6 +553,7 @@ func (a *API) OrderLogisticsCancel(orderID int64, reason string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
// OrderLogisticsStatus 获取订单状态
|
||||
func (a *API) OrderLogisticsStatus(orderID int64) (status int64, err error) {
|
||||
result, err := a.AccessAPI("order/logistics/status", true, map[string]interface{}{
|
||||
KeyOrderID: orderID,
|
||||
@@ -565,6 +566,27 @@ func (a *API) OrderLogisticsStatus(orderID int64) (status int64, err error) {
|
||||
return utils.Interface2Int64WithDefault(data["logistics_status"], 0), err
|
||||
}
|
||||
|
||||
// OrderLogisticsFee 获取订单配送费
|
||||
func (a *API) OrderLogisticsFee(orderID int64) (payFee float64, err error) {
|
||||
result, err := a.AccessAPI("order/logistics/status", true, map[string]interface{}{
|
||||
KeyOrderID: orderID,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
data := result.(map[string]interface{})
|
||||
// 美团运单,骑手确认订单之后取消的话就需要扣除全部的运单费用了
|
||||
if utils.Interface2Int64WithDefault(data["logistics_status"], 0) == utils.Str2Int64WithDefault(WaybillStatusCanceled, 0) {
|
||||
if utils.Interface2Int64WithDefault(data["confirm_time"], 0) != 0 {
|
||||
return utils.TryInterface2Float64(data["pay_amount"])
|
||||
} else {
|
||||
return 0, nil
|
||||
}
|
||||
}
|
||||
|
||||
return utils.TryInterface2Float64(data["pay_amount"])
|
||||
}
|
||||
|
||||
// 拉取用户真实手机号(必接)
|
||||
// https://developer.waimai.meituan.com/home/docDetail/222
|
||||
// limit最大为MaxBatchPullPhoneNumberLimit = 1000
|
||||
|
||||
@@ -77,7 +77,18 @@ func TestOrderApplyPartRefund(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderLogisticsStatus(t *testing.T) {
|
||||
result, err := api.OrderLogisticsStatus(140382472052682640)
|
||||
result, err := api.OrderLogisticsStatus(1100687990339131759)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result == 0 {
|
||||
t.Fatal("result should have value")
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestOrderLogisticsFee(t *testing.T) {
|
||||
result, err := api.OrderLogisticsFee(1100687990339131759)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user