增加饿了么取消订单申请索赔
This commit is contained in:
60
platformapi/ebaiapi/order_compensation.go
Normal file
60
platformapi/ebaiapi/order_compensation.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package ebaiapi
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// ApplyCompensation 饿了么订单索赔
|
||||
func (a *API) ApplyCompensation(orderID string, detailList []*ApplyCompensationList) ([]*ApplyCompensationStatus, error) {
|
||||
result, err := a.AccessAPI("order.apply.compensation", map[string]interface{}{
|
||||
"order_id": orderID,
|
||||
"detail_list": detailList,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.ErrNo != 0 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
byteDate, err := json.Marshal(result.Data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
applyCompensationResultList := &ApplyCompensationResultList{}
|
||||
if err := json.Unmarshal(byteDate, applyCompensationResultList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return applyCompensationResultList.ResultList, nil
|
||||
}
|
||||
|
||||
// ApplyCompensationList 请求参数
|
||||
type ApplyCompensationList struct {
|
||||
RefundId string `json:"refund_id"` // 逆向单id
|
||||
CompensationReason string `json:"compensation_reason"` // 申请索赔原因code
|
||||
Description string `json:"description"` // 申请索赔描述
|
||||
}
|
||||
|
||||
// ApplyCompensationResultList 返回参数
|
||||
type ApplyCompensationResultList struct {
|
||||
OrderId string `json:"order_id"`
|
||||
ResultList []*ApplyCompensationStatus `json:"result_list"`
|
||||
}
|
||||
type ApplyCompensationStatus struct {
|
||||
RefundId string `json:"refund_id"` // 逆向单id
|
||||
CompensationStatusCode string `json:"compensation_status_code"` // 索赔状态编码
|
||||
CompensationStatusDesc string `json:"compensation_status_desc"` // 索赔状态描述
|
||||
CompensationFailCode string `json:"compensation_fail_code"` // 索赔失败code
|
||||
CompensationFailDesc string `json:"compensation_fail_desc"` // 索赔失败描述
|
||||
}
|
||||
|
||||
const (
|
||||
CompensationCodeE1 = "E1" // 长时间无骑手接单,导致订单取消
|
||||
CompensationCodeE2 = "E2" // 长时间无骑手接单,导致订单取消
|
||||
CompensationCodeE3 = "E3" // 骑手接单后未完成配送,导致订单取消
|
||||
CompensationCodeE4 = "E4" // 配送时间过长导致订单被取消或退单
|
||||
CompensationCodeE5 = "E5" // 配送时间过长导致订单被取消或退单
|
||||
CompensationCodeE6 = "E6" // 骑手虚假完成配送,导致用户退单
|
||||
CompensationCodeE7 = "E7" // 骑手导致外卖破损或错送漏送
|
||||
CompensationCodeE8 = "E8" // 骑手态度差
|
||||
CompensationCodeE9 = "E9" // 配送超时或者异常,导致订单取消
|
||||
)
|
||||
@@ -19,13 +19,14 @@ func TestCancelOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderGet(t *testing.T) {
|
||||
result, err := api.OrderGet("4089516015081595490")
|
||||
result, err := api.OrderGet("4032856015365860035")
|
||||
products := result["products"].([]interface{})[0].([]interface{})
|
||||
for _, product2 := range products {
|
||||
product := product2.(map[string]interface{})
|
||||
SkuID := int(utils.Str2Int64WithDefault(utils.Interface2String(product[KeyCustomSkuID]), 0))
|
||||
if SkuID == 0 {
|
||||
if product["upc"] != nil {
|
||||
fmt.Println(strings.Split(product["upc"].(string), "-"))
|
||||
SkuID = utils.Str2Int(strings.Split(product["upc"].(string), "-")[1])
|
||||
} else if product["baidu_product_id"] != nil {
|
||||
globals.SugarLogger.Debugf("-----baidu_product_id := %s", product["baidu_product_id"].(string))
|
||||
@@ -136,7 +137,7 @@ func TestOrderListAll(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderPartRefundGet(t *testing.T) {
|
||||
result, err := api.OrderPartRefundGet("4033500150064003740")
|
||||
result, err := api.OrderPartRefundGet("4089040181400256193")
|
||||
fmt.Println(utils.MustInterface2Int64(result["merchant_income"]))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -185,8 +185,8 @@ func TestGetOrder(t *testing.T) {
|
||||
|
||||
func TestQueryOrder(t *testing.T) {
|
||||
api = New("6705486294797503379", "c1e6c280-e618-4103-9d0a-673bc54fb22e", "51658", "")
|
||||
api.accessToken = "25a4ac91-8be3-47fa-8b45-1dcd9556780d"
|
||||
data, err := api.QueryOrder("1100558321115378179") // 1100537991119839487 1100536591119839487
|
||||
api.accessToken = "b267ad9e-eaef-48d7-a987-1814c0c27315"
|
||||
data, err := api.QueryOrder("3801487132448868438") // 1100537991119839487 1100536591119839487
|
||||
globals.SugarLogger.Debug("data:= %s", utils.Format4Output(data, false))
|
||||
globals.SugarLogger.Debug("err:= %s", utils.Format4Output(err, false))
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ const (
|
||||
OrderStatusDelivered = 3 //已送达
|
||||
OrderStatusException = 5 //异常
|
||||
|
||||
WayBillPressureOrderTime = 1200000 // 蜂鸟分配骑手超过二十分钟不扣款
|
||||
WayBillPressureOrderTime = 1200000 // 蜂鸟分配骑手超过二十分钟不扣款
|
||||
WayBillPressureOrderTime2 = 60000 // 蜂鸟分配骑手超过不足一分钟不扣款
|
||||
)
|
||||
|
||||
// 蜂鸟预下单
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestPrintMsg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPrinterStatus(t *testing.T) {
|
||||
status, err := api.GetPrinterStatus("deviceid", "devicesecret")
|
||||
status, err := api.GetPrinterStatus("ZW202104501422", "")
|
||||
handleError(t, err)
|
||||
baseapi.SugarLogger.Debug(status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user