From e1a80a862a9b17d18aaf8f3dbacf5c27d183fe50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 23 Nov 2023 10:26:00 +0800 Subject: [PATCH] 1 --- platformapi/ebaiapi/order.go | 15 ++++++++++----- platformapi/ebaiapi/order_test.go | 6 ++++-- platformapi/ebaiapi/shop.go | 20 +++++++++++++++----- platformapi/ebaiapi/shop_sku.go | 6 +----- platformapi/ebaiapi/shop_test.go | 4 ++-- platformapi/jdapi/jdapi_test.go | 4 ++-- platformapi/jdapi/order_test.go | 2 +- 7 files changed, 35 insertions(+), 22 deletions(-) diff --git a/platformapi/ebaiapi/order.go b/platformapi/ebaiapi/order.go index 35b6d3f1..2778963d 100644 --- a/platformapi/ebaiapi/order.go +++ b/platformapi/ebaiapi/order.go @@ -552,6 +552,8 @@ func (a *API) OrderListAll(shopID string, baiduShopID int64, startTime, endTime break } page++ + // 这个地方暂停是应为接口请求超频 + time.Sleep(1 * time.Second) } return listOrder, nil } @@ -664,20 +666,23 @@ func (a *API) EbaiRefundOrder(param *RefundOrderExamine) error { } // GetReverseOrder 根据订单号获取详细订单详情 -func (a *API) GetReverseOrder(orderId string) ([]interface{}, error) { +func (a *API) GetReverseOrder(orderId string) ([]interface{}, bool, error) { refundOrder, err := a.AccessAPI("order.reverse.query", map[string]interface{}{ "order_id": orderId, }) if err != nil { - return nil, err + return nil, false, err } if len(refundOrder.Data.(map[string]interface{})["reverse_order_list"].([]interface{})) == 0 { - return nil, err + return nil, false, err } if len(refundOrder.Data.(map[string]interface{})["reverse_order_list"].([]interface{})[0].(map[string]interface{})) == 0 { - return nil, nil + return nil, false, nil } - return refundOrder.Data.(map[string]interface{})["reverse_order_list"].([]interface{})[0].(map[string]interface{})["sub_reverse_order_list"].([]interface{}), nil + + data := refundOrder.Data.(map[string]interface{})["reverse_order_list"].([]interface{})[0].(map[string]interface{}) + isAll := utils.MustInterface2Int64(data["is_refund_all"]) == 1 + return data["sub_reverse_order_list"].([]interface{}), isAll, nil } // RefundOrderExamine 商家审核是售后单 diff --git a/platformapi/ebaiapi/order_test.go b/platformapi/ebaiapi/order_test.go index a10f1c43..7e3819f7 100644 --- a/platformapi/ebaiapi/order_test.go +++ b/platformapi/ebaiapi/order_test.go @@ -30,7 +30,7 @@ func TestOrderAgreePartRefund(t *testing.T) { ReasonRemarks: "", } refundProductList := make([]*RefundProductList, 0, 0) - date, _ := api.GetReverseOrder("4060630055899448055") + date, _, _ := api.GetReverseOrder("4060630055899448055") for _, v := range date { v2 := v.(map[string]interface{}) refundProduct := &RefundProductList{ @@ -65,7 +65,9 @@ func TestOrderAgreeRefund(t *testing.T) { } func TestGetReverseOrder(t *testing.T) { - date, _ := api.GetReverseOrder("4098670052313925323") + date, isAll, err := api.GetReverseOrder("4037190131865481753") + fmt.Println(isAll) + fmt.Println(err) for _, v := range date { fmt.Println(v) } diff --git a/platformapi/ebaiapi/shop.go b/platformapi/ebaiapi/shop.go index 28b57e3e..e25e2473 100644 --- a/platformapi/ebaiapi/shop.go +++ b/platformapi/ebaiapi/shop.go @@ -24,6 +24,15 @@ const ( ShopBusStatusBookingNextDay = 5 // 表示必须跨天预订 ) +const ( + ShopCheckStatusNew = 1 // 门店审核状态 : 新增 + ShopCheckStatusWaitCheck = 2 // 门店审核状态 : 待审核 + ShopCheckStatusGoLiveFail = 3 // 门店审核状态 : 上线驳回 + ShopCheckStatusCheckSuccess = 4 // 门店审核状态 : 审核通过 + ShopCheckStatusUpdateWaitCheck = 5 // 门店审核状态 : 修改待审核 + ShopCheckStatusCheckFail = 6 // 门店审核状态 : 审核驳回 +) + const ( PlatformFlagElm = "1" PlatformFlagBaidu = "2" @@ -268,12 +277,13 @@ func (a *API) ShopOffline(shopID string, baiduShopID int64) (err error) { } func (a *API) ShopClose(shopID string, baiduShopID int64) (err error) { - params := a.genShopIDParams(shopID, baiduShopID, 0) - _, err = a.AccessAPI("shop.close", params) - if err == nil { - return nil + status, _ := a.ShopBusStatusGet(shopID, baiduShopID, PlatformFlagElm) + if status != ShopBusStatusOpening { + params := a.genShopIDParams(shopID, baiduShopID, 0) + _, err = a.AccessAPI("shop.close", params) + return err } - return err + return nil } func (a *API) SupplierList() (supplierInfo map[string]interface{}, err error) { diff --git a/platformapi/ebaiapi/shop_sku.go b/platformapi/ebaiapi/shop_sku.go index dfdf070a..159adc25 100644 --- a/platformapi/ebaiapi/shop_sku.go +++ b/platformapi/ebaiapi/shop_sku.go @@ -2,7 +2,6 @@ package ebaiapi import ( "fmt" - "git.rosy.net.cn/jx-callback/globals" "regexp" "strings" @@ -226,7 +225,6 @@ func genSkuIDParams(skuIDstr string, customSkuID, upc string) map[string]interfa } // category相关的函数,shop_custom_id可重 - func (a *API) ShopCategoryCreate(shopID string, parentID int64, name string, rank int) (catID int64, err error) { result, err := a.AccessAPI("sku.shop.category.create", map[string]interface{}{ KeyShopID: shopID, @@ -301,7 +299,6 @@ func (a *API) SkuCreate(trackInfo, shopID string, customSkuID int64, params map[ KeyCustomSkuID: customSkuID, } if params["upc"] == nil { - // defParams["upc_type"] = UPCTypePrivate defParams["upc"] = "upc-" + utils.Int2Str(int(customSkuID)) } /*if params["brand_id"] == nil { @@ -310,10 +307,9 @@ func (a *API) SkuCreate(trackInfo, shopID string, customSkuID int64, params map[ if params["brand_name"] == nil { defParams["brand_name"] = "无" // 很狗血的是,你还必须填个无才行。。。 }*/ + // params = utils.MergeMaps(params, defParams) result, err := a.AccessAPI2("sku.create", params, trackInfo) - globals.SugarLogger.Debugf("========result := %s", utils.Format4Output(result, false)) - globals.SugarLogger.Debugf("========result := %v", err) if err == nil && result.Data != nil { return utils.Interface2Int64WithDefault(result.Data.(map[string]interface{})[KeySkuID], 0), nil } diff --git a/platformapi/ebaiapi/shop_test.go b/platformapi/ebaiapi/shop_test.go index 281e13e7..96d0533b 100644 --- a/platformapi/ebaiapi/shop_test.go +++ b/platformapi/ebaiapi/shop_test.go @@ -104,7 +104,7 @@ func TestShopUpdate(t *testing.T) { } func TestShopBusStatusGet(t *testing.T) { - result, err := api.ShopBusStatusGet("", 100000117217, PlatformFlagElm) + result, err := api.ShopBusStatusGet("", 1119844487, PlatformFlagElm) if err != nil { t.Fatal(err) } else { @@ -113,7 +113,7 @@ func TestShopBusStatusGet(t *testing.T) { } func TestShopStatusGet(t *testing.T) { - result, err := api.ShopStatusGet("", 200000081608) + result, err := api.ShopStatusGet("", 1119844487) if err != nil { t.Fatal(err) } else { diff --git a/platformapi/jdapi/jdapi_test.go b/platformapi/jdapi/jdapi_test.go index 558db238..e4196167 100644 --- a/platformapi/jdapi/jdapi_test.go +++ b/platformapi/jdapi/jdapi_test.go @@ -29,12 +29,12 @@ func init() { // 天天果园 //api = New("c45e6510-00ba-4be2-977e-bcb9c9792cc7", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26") // 京东果园 320406 - //api = New("c454ef86-2213-4860-9a31-f2ef7e883386", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4") + api = New("c454ef86-2213-4860-9a31-f2ef7e883386", "1dba76d40cac446ca500c0391a0b6c9d", "a88d031a1e7b462cb1579f12e97fe7f4") // 果切 //api = New("3ef42248-1247-4efa-8624-43cd3a3b97ae", "5d5577a2506f41b8b4ec520ba83490f5", "0b01b9eeb15b41dab1c3d05d95c17a26") // 京东超市 359459 - api = New("21ff22c5-0716-4c05-9468-8e4dde2b1cd6", "21b627c23ea04c69b64b48d0b361213e", "51cd27a748e64c829b4b7f83f4844610") + //api = New("21ff22c5-0716-4c05-9468-8e4dde2b1cd6", "21b627c23ea04c69b64b48d0b361213e", "51cd27a748e64c829b4b7f83f4844610") //prod zs // api = New("6f8d3290-0120-4ad7-8b53-943c67c84f3f", "789279b9ae814ba091ac52815566b54d", "5d668cd227644637bb0fd73ed8118ec8") // const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHCT3RM3CQG7IJIPUQ3THS5UIUYWMKINM7ETUOQB7OBPOPZVCT3ZJY55243TDVXLO25PP4UYSPTTPMNQ7HPMWOJKJ3BJWGVHD243MXH7NZWW264TKN5UOCJBSSSOKD2QQII" diff --git a/platformapi/jdapi/order_test.go b/platformapi/jdapi/order_test.go index 8423c0de..39d7cd17 100644 --- a/platformapi/jdapi/order_test.go +++ b/platformapi/jdapi/order_test.go @@ -91,7 +91,7 @@ func TestOrderSerllerDelivery(t *testing.T) { } func TestDeliveryEndOrder(t *testing.T) { - result, err := api.DeliveryEndOrder("813344594000041", "") + result, err := api.DeliveryEndOrder("2326939731000094", "") if err != nil { t.Fatal(err.Error()) }