上市订单并通过ISO 8601日期到Amazon MWS [英] Listing orders and passing ISO 8601 date to Amazon MWS

查看:107
本文介绍了上市订单并通过ISO 8601日期到Amazon MWS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从亚马逊MWS检索订单的最佳方法是什么?

What would be the best way to retrieve orders from Amazon MWS?

我当前的代码如下...

My current code is as follows...

MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig();
config.ServiceURL = productsURL;

MarketplaceWebServiceOrders.MarketplaceWebServiceOrdersClient service = new MarketplaceWebServiceOrdersClient(appname, version, accesskeyID, secretkey, config);             

ListOrdersRequest request = new ListOrdersRequest();
request.MarketplaceId = new MarketplaceIdList();
request.MarketplaceId.Id = new List<string>(new string[] { marketids[0] });
request.SellerId = merchantID;
request.OrderStatus = new OrderStatusList() { Status = new List<OrderStatusEnum>() { OrderStatusEnum.Unshipped, OrderStatusEnum.PartiallyShipped } };
request.CreatedAfter = Convert.ToDateTime(dc.Settings.SingleOrDefault().lastOrdersRetrieved);

ListOrdersResponse response = service.ListOrders(request);

我在传递ISO日期时遇到问题,如果您在代码中看到其他任何问题,请随时告诉我.

I am having issues passing the ISO Date across, also if you see any other issues with the code please feel free to let me know.

推荐答案

如果您在请求之后立即寻找创建的内容,那么它根本找不到任何东西,就像使用Amazon一样,您只能抓取最后2个分钟的订单数据.

If your looking for something created after the immediate second you make the request, it wont find anything at all as with Amazon you can only grab up to the last 2 minutes of data for orders.

我在尝试设置从现在到5分钟的时间时遇到了问题.与Amazon支持人员交谈后,他们提供了以下信息:"

I had an issue with trying to set time from Now - 5 minutes. After speaking to Amazon support they provided the following nugget: "

在Orders API中,如果您未指定结束时间(CreatedBefore或LastUpdatedBefore),它将假设现在(实际上现在是负2)分钟).并在回应中告诉您确切的时间用作截止时间."

In Orders API, if you don't specify an end time (CreatedBefore or LastUpdatedBefore), it will assume now (actually, now minus 2 minutes). And in its response, it will tell you exactly what time it used as the cutoff time."

在您的情况下,您将希望删除 CreatedAfter 请求,并让Amazon为您选择.

In your case you will want to remove the CreatedAfter request and let Amazon choose for you.

如果您随后要查找创建后的参数,则可以获取Amazon提供的响应时间,并将其传递给创建后的参数.

If you are then looking for the created after, you can grab the response time Amazon gave and pass that in to your created after param.

我现在列出订单的方法如下,请注意,这只会列出要控制台的订单,但是数据将以相同的方式返回:

The method I have right now to list orders is as follows, mind you this will just list the orders to console, but the data gets returned all the same:

public List<string> ListOrders(MarketplaceWebServiceOrders.MarketplaceWebServiceOrders    service, string merchantId, List<OrderStatusEnum> orderStatus)
    {
        List<string> salesOrderIds = new List<string>();

        ListOrdersRequest listOrdersRequest = new ListOrdersRequest();

        DateTime createdAfter = DateTime.Now.Add(new TimeSpan(-1, 0, 0));
        DateTime createdbefore = DateTime.Now.Add(new TimeSpan(0, -15, 0));

        listOrdersRequest.CreatedAfter = createdAfter;
        listOrdersRequest.CreatedBefore = createdbefore;
        listOrdersRequest.SellerId = merchantId;
        listOrdersRequest.OrderStatus = new OrderStatusList();

        foreach (OrderStatusEnum status in orderStatus)
        {
            listOrdersRequest.OrderStatus.Status.Add(status);
        }

        listOrdersRequest.FulfillmentChannel = new FulfillmentChannelList();
        listOrdersRequest.FulfillmentChannel.Channel = new List<FulfillmentChannelEnum>();
        listOrdersRequest.FulfillmentChannel.Channel.Add(FulfillmentChannelEnum.MFN);


        listOrdersRequest.MarketplaceId = new MarketplaceIdList();
        listOrdersRequest.MarketplaceId.Id = new List<string>();
        listOrdersRequest.MarketplaceId.Id.Add("yourID");

        ListOrdersResponse listOrdersResponse = service.ListOrders(listOrdersRequest);

        int i = 0;

        foreach (Order order in listOrdersResponse.ListOrdersResult.Orders.Order)
        {
            i++;
            Console.WriteLine("Amazon Order ID:             \t" + order.AmazonOrderId);
            Console.WriteLine("Buyer Name:                  \t" + order.BuyerName);
            Console.WriteLine("Buyer Email:                 \t" + order.BuyerEmail);
            Console.WriteLine("Fulfillment Channel:         \t" + order.FulfillmentChannel);
            Console.WriteLine("Order Status:                \t" + order.OrderStatus);
            Console.WriteLine("Order Total:                 \t" + order.OrderTotal);
            Console.WriteLine("Number of Items Shipped:     \t" + order.NumberOfItemsShipped);
            Console.WriteLine("Number of Items Unshipped:   \t" + order.NumberOfItemsUnshipped);
            Console.WriteLine("Purchase Date:               \t" + order.PurchaseDate);
            Console.WriteLine("===========================================================");

            salesOrderIds.Add(order.AmazonOrderId);


        }

        Console.WriteLine("We returned a total of {0} records. ", i);
        return salesOrderIds;
    }

这篇关于上市订单并通过ISO 8601日期到Amazon MWS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆