- 修正各平台与拉取订单相关的API的bug
This commit is contained in:
@@ -45,6 +45,7 @@ const (
|
||||
ErrCodeAccessLimited = 711 // 接口调用过于频繁,触发流控,请降低调用频率
|
||||
|
||||
ErrCodeNoAppFood = 805 // 不存在此菜品
|
||||
ErrCodeNoSuchOrder = 808 // 不存在此订单
|
||||
ErrCodeSkuCategoryNotExist = 1021 // 菜品分类不存在
|
||||
ErrCodeSkuCategoryExist = 1037 // 菜品分类已存在
|
||||
)
|
||||
@@ -159,6 +160,7 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
retVal = jsonResult1[resultKey]
|
||||
if errObj, ok := jsonResult1["error"]; ok {
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
errorInfo := errObj.(map[string]interface{})
|
||||
@@ -168,7 +170,6 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
}
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
}
|
||||
retVal = jsonResult1[resultKey]
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
})
|
||||
err = platformapi.RebuildError(err, bizParams, []string{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
@@ -84,6 +86,10 @@ const (
|
||||
ExtrasPromotionTypeShanGouBaoPin = 56 // 闪购爆品
|
||||
)
|
||||
|
||||
const (
|
||||
MaxGap4GetOrderIdByDaySeq = 100
|
||||
)
|
||||
|
||||
type RefundSku struct {
|
||||
AppFoodCode string `json:"app_food_code"`
|
||||
SkuID string `json:"sku_id,omitempty"`
|
||||
@@ -297,6 +303,11 @@ type OrderActInfo struct {
|
||||
} `json:"act_detail_list"`
|
||||
}
|
||||
|
||||
type GetOrderIdByDaySeqResult struct {
|
||||
Result string `json:"result"`
|
||||
OrderIDs []int64 `json:"order_ids"`
|
||||
}
|
||||
|
||||
func (a *API) OrderReceived(orderID int64) (err error) {
|
||||
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
|
||||
KeyOrderID: orderID,
|
||||
@@ -508,3 +519,34 @@ func (a *API) GetOrderActDetail(queryData []*GetOrderActDetailParam) (orderActLi
|
||||
}
|
||||
return orderActList, err
|
||||
}
|
||||
|
||||
func (a *API) GetOrderDaySeq(poiCode string) (daySeq int, err error) {
|
||||
params := map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
}
|
||||
result, err := a.AccessAPI("order/getOrderDaySeq", true, params)
|
||||
if err == nil {
|
||||
daySeq = int(utils.MustInterface2Int64(result.(map[string]interface{})["day_seq"]))
|
||||
}
|
||||
return daySeq, err
|
||||
}
|
||||
|
||||
// 订单流水号的开始序号,门店内每日的订单流水号都是从1开始。
|
||||
// 订单流水号的结束序号,注意开始流水号与结束流水号的跨度需小于100,即差值最大为99
|
||||
// 这个函数在给定的区间范围全部没有订单时,返回错误808,但如果有部分订单,返回的错误是0
|
||||
func (a *API) GetOrderIdByDaySeq(poiCode string, dateTime time.Time, seqStart, seqEnd int) (vendorOrderIDs []int64, err error) {
|
||||
params := map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"date_time": dateTime.Format("20060102"),
|
||||
"day_seq_start": seqStart,
|
||||
"day_seq_end": seqEnd,
|
||||
}
|
||||
result, err := a.AccessAPI("ecommerce/order/getOrderIdByDaySeq", true, params)
|
||||
if extErr, ok := err.(*utils.ErrorWithCode); (ok && extErr.IntCode() == 0) || err == nil {
|
||||
var data GetOrderIdByDaySeqResult
|
||||
if err2 := utils.UnmarshalUseNumber([]byte(utils.Interface2String(result)), &data); err2 == nil {
|
||||
vendorOrderIDs = data.OrderIDs
|
||||
}
|
||||
}
|
||||
return vendorOrderIDs, err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package mtwmapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -113,3 +114,11 @@ func TestGetOrderActDetaill(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetOrderIdByDaySeq(t *testing.T) {
|
||||
result, err := api.GetOrderIdByDaySeq("7111597", utils.Time2Date(time.Now()), 1, 100)
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user