- 修正各平台与拉取订单相关的API的bug
This commit is contained in:
@@ -476,7 +476,7 @@ func (a *API) OrderListAll(shopID string, baiduShopID int64, startTime, endTime
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
listOrder = append(listOrder, result.List...)
|
listOrder = append(listOrder, result.List...)
|
||||||
if result.Page == result.Pages {
|
if result.Page >= result.Pages {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
page++
|
page++
|
||||||
|
|||||||
@@ -33,6 +33,15 @@ func TestOrderList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOrderListAll(t *testing.T) {
|
||||||
|
result, err := api.OrderListAll("", 32267089397, 1563379200, 1563465599, 0)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else {
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestOrderPartRefundGet(t *testing.T) {
|
func TestOrderPartRefundGet(t *testing.T) {
|
||||||
result, err := api.OrderPartRefundGet("1557459492221457830")
|
result, err := api.OrderPartRefundGet("1557459492221457830")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -177,6 +177,139 @@ type OrderSettlementInfo struct {
|
|||||||
VenderSkuGoodsDiscountMoney int64 `json:"venderSkuGoodsDiscountMoney"`
|
VenderSkuGoodsDiscountMoney int64 `json:"venderSkuGoodsDiscountMoney"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OrderProductInfo struct {
|
||||||
|
AdjustMode int `json:"adjustMode"`
|
||||||
|
CanteenMoney int `json:"canteenMoney"`
|
||||||
|
CategoryID string `json:"categoryId"`
|
||||||
|
FirstCategoryName string `json:"firstCategoryName"`
|
||||||
|
IsGift bool `json:"isGift"`
|
||||||
|
PromotionType int `json:"promotionType"`
|
||||||
|
SkuCount int `json:"skuCount"`
|
||||||
|
SkuID int `json:"skuId"`
|
||||||
|
SkuJdPrice int `json:"skuJdPrice"`
|
||||||
|
SkuName string `json:"skuName"`
|
||||||
|
SkuSpuID int `json:"skuSpuId"`
|
||||||
|
SkuStockOwner int `json:"skuStockOwner"`
|
||||||
|
SkuStorePrice int `json:"skuStorePrice"`
|
||||||
|
SkuWeight float64 `json:"skuWeight"`
|
||||||
|
UpcCode string `json:"upcCode,omitempty"`
|
||||||
|
SpecialServiceTag string `json:"specialServiceTag,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderInfo struct {
|
||||||
|
AdjustCount int `json:"adjustCount"`
|
||||||
|
AdjustID int `json:"adjustId"`
|
||||||
|
AdjustIsExists bool `json:"adjustIsExists"`
|
||||||
|
AppVersion string `json:"appVersion"`
|
||||||
|
ArtificerPortraitURL string `json:"artificerPortraitUrl"`
|
||||||
|
BusinessTag string `json:"businessTag"`
|
||||||
|
BusinessType int `json:"businessType"`
|
||||||
|
BuyerCity string `json:"buyerCity"`
|
||||||
|
BuyerCityName string `json:"buyerCityName"`
|
||||||
|
BuyerCoordType int `json:"buyerCoordType"`
|
||||||
|
BuyerCountry string `json:"buyerCountry"`
|
||||||
|
BuyerCountryName string `json:"buyerCountryName"`
|
||||||
|
BuyerFullAddress string `json:"buyerFullAddress"`
|
||||||
|
BuyerFullName string `json:"buyerFullName"`
|
||||||
|
BuyerIP int `json:"buyerIp"`
|
||||||
|
BuyerLat float64 `json:"buyerLat"`
|
||||||
|
BuyerLng float64 `json:"buyerLng"`
|
||||||
|
BuyerMobile string `json:"buyerMobile"`
|
||||||
|
BuyerPin string `json:"buyerPin"`
|
||||||
|
BuyerPinType int `json:"buyerPinType"`
|
||||||
|
BuyerPoi string `json:"buyerPoi"`
|
||||||
|
BuyerProvince string `json:"buyerProvince"`
|
||||||
|
CancelDeadline string `json:"cancelDeadline"`
|
||||||
|
CancelOperator string `json:"cancelOperator"`
|
||||||
|
CancelOrderIsReadable bool `json:"cancelOrderIsReadable"`
|
||||||
|
CancelRequestTime string `json:"cancelRequestTime"`
|
||||||
|
ClientOrderPreStartDeliveryTime string `json:"clientOrderPreStartDeliveryTime"`
|
||||||
|
DeliveryBillNo string `json:"deliveryBillNo"`
|
||||||
|
DeliveryCarrierName string `json:"deliveryCarrierName"`
|
||||||
|
DeliveryCarrierNo string `json:"deliveryCarrierNo"`
|
||||||
|
DeliveryDelayAgreed int `json:"deliveryDelayAgreed"`
|
||||||
|
DeliveryPackageVolume float64 `json:"deliveryPackageVolume"`
|
||||||
|
DeliveryPackageWeight float64 `json:"deliveryPackageWeight"`
|
||||||
|
DeliveryStationName string `json:"deliveryStationName"`
|
||||||
|
DeliveryStationNo string `json:"deliveryStationNo"`
|
||||||
|
DeliveryStationNoIsv string `json:"deliveryStationNoIsv"`
|
||||||
|
DeliveryType int `json:"deliveryType"`
|
||||||
|
EquipmentID string `json:"equipmentId"`
|
||||||
|
GrabMark int `json:"grabMark"`
|
||||||
|
IndustryTag int `json:"industryTag"`
|
||||||
|
IsDeleted bool `json:"isDeleted"`
|
||||||
|
IsGroupon bool `json:"isGroupon"`
|
||||||
|
IsJDGetCash bool `json:"isJDGetCash"`
|
||||||
|
LastFourDigitsOfBuyerMobile string `json:"lastFourDigitsOfBuyerMobile"`
|
||||||
|
LocalDeliveryMoney int `json:"localDeliveryMoney"`
|
||||||
|
MerchantPaymentDistanceFreightMoney int `json:"merchantPaymentDistanceFreightMoney"`
|
||||||
|
OrderAcceptTime string `json:"orderAcceptTime"`
|
||||||
|
OrderAdditionFreightMoney int `json:"orderAdditionFreightMoney"`
|
||||||
|
OrderAgingType int `json:"orderAgingType"`
|
||||||
|
OrderBalanceUsed int `json:"orderBalanceUsed"`
|
||||||
|
OrderBaseFreightMoney int `json:"orderBaseFreightMoney"`
|
||||||
|
OrderBaseReceivableFreight int `json:"orderBaseReceivableFreight"`
|
||||||
|
OrderBuyerPayableMoney int `json:"orderBuyerPayableMoney"`
|
||||||
|
OrderBuyerRemark string `json:"orderBuyerRemark"`
|
||||||
|
OrderCancelRemark string `json:"orderCancelRemark"`
|
||||||
|
OrderCancelTime string `json:"orderCancelTime"`
|
||||||
|
OrderDiscountMoney int `json:"orderDiscountMoney"`
|
||||||
|
OrderDistanceStepFreight int `json:"orderDistanceStepFreight"`
|
||||||
|
OrderFinanceOrgCode int `json:"orderFinanceOrgCode"`
|
||||||
|
OrderFreightMoney int `json:"orderFreightMoney"`
|
||||||
|
OrderGoodsMoney int `json:"orderGoodsMoney"`
|
||||||
|
OrderID int64 `json:"orderId"`
|
||||||
|
OrderInvoiceOpenMark int `json:"orderInvoiceOpenMark"`
|
||||||
|
OrderIsClosed bool `json:"orderIsClosed"`
|
||||||
|
OrderJingdouMoney int `json:"orderJingdouMoney"`
|
||||||
|
OrderLadderFreightMoney int `json:"orderLadderFreightMoney"`
|
||||||
|
OrderNum int `json:"orderNum"`
|
||||||
|
OrderPayType int `json:"orderPayType"`
|
||||||
|
OrderPreDeliveryTime string `json:"orderPreDeliveryTime"`
|
||||||
|
OrderPreEndDeliveryTime string `json:"orderPreEndDeliveryTime"`
|
||||||
|
OrderPreStartDeliveryTime string `json:"orderPreStartDeliveryTime"`
|
||||||
|
OrderPurchaseTime string `json:"orderPurchaseTime"`
|
||||||
|
OrderReceivableFreight int `json:"orderReceivableFreight"`
|
||||||
|
OrderSkuType int `json:"orderSkuType"`
|
||||||
|
OrderStartTime string `json:"orderStartTime"`
|
||||||
|
OrderStatus int `json:"orderStatus"`
|
||||||
|
OrderStatusTime string `json:"orderStatusTime"`
|
||||||
|
OrderStockOwner int `json:"orderStockOwner"`
|
||||||
|
OrderTakeSelfCode string `json:"orderTakeSelfCode"`
|
||||||
|
OrderTotalMoney int `json:"orderTotalMoney"`
|
||||||
|
OrderType int `json:"orderType"`
|
||||||
|
OrderVenderChargeMoney int `json:"orderVenderChargeMoney"`
|
||||||
|
OrgCode string `json:"orgCode"`
|
||||||
|
PackagingMoney int `json:"packagingMoney"`
|
||||||
|
PayChannel int `json:"payChannel"`
|
||||||
|
PickDeadline string `json:"pickDeadline"`
|
||||||
|
PickMark int `json:"pickMark"`
|
||||||
|
PlatformPointsDeductionMoney int `json:"platformPointsDeductionMoney"`
|
||||||
|
PrescriptionDTO struct {
|
||||||
|
IsRigorous bool `json:"isRigorous"`
|
||||||
|
} `json:"prescriptionDTO"`
|
||||||
|
PrintMark int `json:"printMark"`
|
||||||
|
ProduceStationName string `json:"produceStationName"`
|
||||||
|
ProduceStationNo string `json:"produceStationNo"`
|
||||||
|
ProduceStationNoIsv string `json:"produceStationNoIsv"`
|
||||||
|
Product []*OrderProductInfo `json:"product"`
|
||||||
|
SrcInnerOrderID int `json:"srcInnerOrderId"`
|
||||||
|
SrcInnerType int `json:"srcInnerType"`
|
||||||
|
SrcOrderID string `json:"srcOrderId"`
|
||||||
|
SrcOrderType int `json:"srcOrderType"`
|
||||||
|
SrcPlatID int `json:"srcPlatId"`
|
||||||
|
StoreLat float64 `json:"storeLat"`
|
||||||
|
StoreLng float64 `json:"storeLng"`
|
||||||
|
Tips int `json:"tips"`
|
||||||
|
Ts string `json:"ts"`
|
||||||
|
UpdatePin string `json:"updatePin"`
|
||||||
|
UserTip int `json:"userTip"`
|
||||||
|
VenderBalanceDeductMoney int `json:"venderBalanceDeductMoney"`
|
||||||
|
VenderIntegralDeductMoney int `json:"venderIntegralDeductMoney"`
|
||||||
|
VenderProcessResult string `json:"venderProcessResult"`
|
||||||
|
Yn bool `json:"yn"`
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrCanNotFindOrder = errors.New("can not find order")
|
ErrCanNotFindOrder = errors.New("can not find order")
|
||||||
)
|
)
|
||||||
@@ -203,6 +336,14 @@ func (a *API) OrderQuery(jdParams map[string]interface{}) (retVal []interface{},
|
|||||||
return retVal, totalCount, err
|
return retVal, totalCount, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) OrderQuery2(jdParams map[string]interface{}) (retVal []*OrderInfo, totalCount int, err error) {
|
||||||
|
orderList, totalCount, err := a.OrderQuery(jdParams)
|
||||||
|
if err == nil {
|
||||||
|
err = utils.Map2StructByJson(orderList, &retVal, true)
|
||||||
|
}
|
||||||
|
return retVal, totalCount, err
|
||||||
|
}
|
||||||
|
|
||||||
// orderFreightMoney 基础运费
|
// orderFreightMoney 基础运费
|
||||||
// tips 商家承担小费
|
// tips 商家承担小费
|
||||||
// merchantPaymentDistanceFreightMoney 取件服务费(开票)(正向单展示远距离运费;售后单则展示达达售后运费)
|
// merchantPaymentDistanceFreightMoney 取件服务费(开票)(正向单展示远距离运费;售后单则展示达达售后运费)
|
||||||
@@ -220,27 +361,6 @@ func (a *API) QuerySingleOrder(orderId string) (map[string]interface{}, error) {
|
|||||||
return result[0].(map[string]interface{}), nil
|
return result[0].(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) LegacyQuerySingleOrder(orderId string) (map[string]interface{}, error) {
|
|
||||||
jdParams := make(map[string]interface{})
|
|
||||||
jdParams["orderId"] = orderId
|
|
||||||
|
|
||||||
result, err := a.AccessAPI("order/es/query", jdParams)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dataStr, _ := result["data"].(string)
|
|
||||||
var data map[string]interface{}
|
|
||||||
utils.UnmarshalUseNumber([]byte(dataStr), &data)
|
|
||||||
result["data"] = data
|
|
||||||
|
|
||||||
var dataResult map[string]interface{}
|
|
||||||
utils.UnmarshalUseNumber([]byte(data["result"].(string)), &dataResult)
|
|
||||||
data["result"] = dataResult
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 商家确认接单接口
|
// 商家确认接单接口
|
||||||
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=c1a15129d1374e9da7fa35487f878604
|
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=c1a15129d1374e9da7fa35487f878604
|
||||||
func (a *API) OrderAcceptOperate(orderId string, isAgreed bool, userName string) error {
|
func (a *API) OrderAcceptOperate(orderId string, isAgreed bool, userName string) error {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ func TestOrderQuery(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("OrderQuery return error:%v", err)
|
t.Fatalf("OrderQuery return error:%v", err)
|
||||||
}
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
|
||||||
if len(result) == 0 || totalCount == 0 {
|
if len(result) == 0 || totalCount == 0 {
|
||||||
t.Fatal("OrderQuery return empty data")
|
t.Fatal("OrderQuery return empty data")
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const (
|
|||||||
ErrCodeAccessLimited = 711 // 接口调用过于频繁,触发流控,请降低调用频率
|
ErrCodeAccessLimited = 711 // 接口调用过于频繁,触发流控,请降低调用频率
|
||||||
|
|
||||||
ErrCodeNoAppFood = 805 // 不存在此菜品
|
ErrCodeNoAppFood = 805 // 不存在此菜品
|
||||||
|
ErrCodeNoSuchOrder = 808 // 不存在此订单
|
||||||
ErrCodeSkuCategoryNotExist = 1021 // 菜品分类不存在
|
ErrCodeSkuCategoryNotExist = 1021 // 菜品分类不存在
|
||||||
ErrCodeSkuCategoryExist = 1037 // 菜品分类已存在
|
ErrCodeSkuCategoryExist = 1037 // 菜品分类已存在
|
||||||
)
|
)
|
||||||
@@ -159,6 +160,7 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
|||||||
if jsonResult1 == nil {
|
if jsonResult1 == nil {
|
||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
}
|
}
|
||||||
|
retVal = jsonResult1[resultKey]
|
||||||
if errObj, ok := jsonResult1["error"]; ok {
|
if errObj, ok := jsonResult1["error"]; ok {
|
||||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||||
errorInfo := errObj.(map[string]interface{})
|
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
|
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||||
}
|
}
|
||||||
retVal = jsonResult1[resultKey]
|
|
||||||
return platformapi.ErrLevelSuccess, nil
|
return platformapi.ErrLevelSuccess, nil
|
||||||
})
|
})
|
||||||
err = platformapi.RebuildError(err, bizParams, []string{
|
err = platformapi.RebuildError(err, bizParams, []string{
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package mtwmapi
|
package mtwmapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -84,6 +86,10 @@ const (
|
|||||||
ExtrasPromotionTypeShanGouBaoPin = 56 // 闪购爆品
|
ExtrasPromotionTypeShanGouBaoPin = 56 // 闪购爆品
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
MaxGap4GetOrderIdByDaySeq = 100
|
||||||
|
)
|
||||||
|
|
||||||
type RefundSku struct {
|
type RefundSku struct {
|
||||||
AppFoodCode string `json:"app_food_code"`
|
AppFoodCode string `json:"app_food_code"`
|
||||||
SkuID string `json:"sku_id,omitempty"`
|
SkuID string `json:"sku_id,omitempty"`
|
||||||
@@ -297,6 +303,11 @@ type OrderActInfo struct {
|
|||||||
} `json:"act_detail_list"`
|
} `json:"act_detail_list"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetOrderIdByDaySeqResult struct {
|
||||||
|
Result string `json:"result"`
|
||||||
|
OrderIDs []int64 `json:"order_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) OrderReceived(orderID int64) (err error) {
|
func (a *API) OrderReceived(orderID int64) (err error) {
|
||||||
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
|
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
|
||||||
KeyOrderID: orderID,
|
KeyOrderID: orderID,
|
||||||
@@ -508,3 +519,34 @@ func (a *API) GetOrderActDetail(queryData []*GetOrderActDetailParam) (orderActLi
|
|||||||
}
|
}
|
||||||
return orderActList, err
|
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 (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
@@ -113,3 +114,11 @@ func TestGetOrderActDetaill(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -281,6 +281,11 @@ func Time2TimeStr(t time.Time) string {
|
|||||||
return t.Format("15:04:05")
|
return t.Format("15:04:05")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Time2Date(t time.Time) time.Time {
|
||||||
|
year, month, day := t.Date()
|
||||||
|
return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
|
||||||
|
}
|
||||||
|
|
||||||
func Time2DateStr(t time.Time) string {
|
func Time2DateStr(t time.Time) string {
|
||||||
return t.Format("2006-01-02")
|
return t.Format("2006-01-02")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user