无法使用GetSellingManagerSaleRecord返回正确的顺序

时间:2015-04-15 00:35:32

标签: ebay-api

我在devbay.net上使用eBay SDK for PHP。

首先我加载GetSellingManagerSoldListings,搜索SaleRecordID = 129317:

$service = new TradingService();
$request = new Types\GetSellingManagerSoldListingsRequestType();
$request->Search = new Types\SellingManagerSearchType();
$request->Search->SearchType = 'SaleRecordID';
$request->Search->SearchValue = '129317';
$result = $service->GetSellingManagerSoldListings($request);
print_r($result->SaleRecord[0]);

其中给出了以下回复:

DTS\eBaySDK\Trading\Types\SellingManagerSoldOrderType Object
(
    [values:DTS\eBaySDK\Types\BaseType:private] => Array
        (
            [SellingManagerSoldTransaction] => DTS\eBaySDK\Types\UnboundType Object
                (
                    [data:DTS\eBaySDK\Types\UnboundType:private] => Array
                        (
                            [0] => DTS\eBaySDK\Trading\Types\SellingManagerSoldTransactionType Object
                                (
                                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                                        (
                                            [TransactionID] => *removed*
                                            [SaleRecordID] => 129242
                                            [ItemID] => *removed*
                                            [QuantitySold] => 1
                                            [ItemTitle] => *removed*
                                            [ListingType] => FixedPriceItem
                                            [Relisted] => 
                                            [SecondChanceOfferSent] => 
                                            [CustomLabel] => *removed*
                                            [SoldOn] => eBay
                                            [ListedOn] => DTS\eBaySDK\Types\UnboundType Object
                                                (
                                                    [data:DTS\eBaySDK\Types\UnboundType:private] => Array
                                                        (
                                                            [0] => eBay
                                                        )

                                                    [position:DTS\eBaySDK\Types\UnboundType:private] => 0
                                                    [class:DTS\eBaySDK\Types\UnboundType:private] => DTS\eBaySDK\Trading\Types\SellingManagerSoldTransactionType
                                                    [property:DTS\eBaySDK\Types\UnboundType:private] => ListedOn
                                                    [expectedType:DTS\eBaySDK\Types\UnboundType:private] => string
                                                )

                                            [CharityListing] => 
                                            [OrderLineItemID] => *removed*
                                        )

                                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                                        (
                                            [data] => 
                                            [mimeType] => 
                                        )

                                )

                            [1] => DTS\eBaySDK\Trading\Types\SellingManagerSoldTransactionType Object
                                (
                                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                                        (
                                            [TransactionID] => *removed*
                                            [SaleRecordID] => 129243
                                            [ItemID] => *removed*
                                            [QuantitySold] => 1
                                            [ItemTitle] => *removed*
                                            [ListingType] => FixedPriceItem
                                            [Relisted] => 
                                            [SecondChanceOfferSent] => 
                                            [CustomLabel] => *removed*
                                            [SoldOn] => eBay
                                            [ListedOn] => DTS\eBaySDK\Types\UnboundType Object
                                                (
                                                    [data:DTS\eBaySDK\Types\UnboundType:private] => Array
                                                        (
                                                            [0] => eBay
                                                        )

                                                    [position:DTS\eBaySDK\Types\UnboundType:private] => 0
                                                    [class:DTS\eBaySDK\Types\UnboundType:private] => DTS\eBaySDK\Trading\Types\SellingManagerSoldTransactionType
                                                    [property:DTS\eBaySDK\Types\UnboundType:private] => ListedOn
                                                    [expectedType:DTS\eBaySDK\Types\UnboundType:private] => string
                                                )

                                            [CharityListing] => 
                                            [OrderLineItemID] => *removed*
                                        )

                                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                                        (
                                            [data] => 
                                            [mimeType] => 
                                        )

                                )

                        )

                    [position:DTS\eBaySDK\Types\UnboundType:private] => 0
                    [class:DTS\eBaySDK\Types\UnboundType:private] => DTS\eBaySDK\Trading\Types\SellingManagerSoldOrderType
                    [property:DTS\eBaySDK\Types\UnboundType:private] => SellingManagerSoldTransaction
                    [expectedType:DTS\eBaySDK\Types\UnboundType:private] => DTS\eBaySDK\Trading\Types\SellingManagerSoldTransactionType
                )

            [ShippingAddress] => DTS\eBaySDK\Trading\Types\AddressType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [Name] => *removed*
                            [PostalCode] => 2761
                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [ShippingDetails] => DTS\eBaySDK\Trading\Types\ShippingDetailsType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [ShippingType] => NotSpecified
                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [TotalAmount] => DTS\eBaySDK\Trading\Types\AmountType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [currencyID] => AUD
                            [value] => 294.95
                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [TotalQuantity] => 2
            [ActualShippingCost] => DTS\eBaySDK\Trading\Types\AmountType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [currencyID] => AUD
                            [value] => 0
                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [OrderStatus] => DTS\eBaySDK\Trading\Types\SellingManagerOrderStatusType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [CheckoutStatus] => CheckoutComplete
                            [PaidStatus] => PartiallyPaid
                            [ShippedStatus] => Shipped
                            [PaymentMethodUsed] => PayPal
                            [FeedbackSent] => 1
                            [TotalEmailsSent] => 3
                            [ShippedTime] => DateTime Object
                                (
                                    [date] => 2015-04-06 21:10:09
                                    [timezone_type] => 2
                                    [timezone] => Z
                                )

                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [SalePrice] => DTS\eBaySDK\Trading\Types\AmountType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [currencyID] => AUD
                            [value] => 589.9
                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [DaysSinceSale] => 5
            [BuyerID] => *removed*
            [BuyerEmail] => *removed*
            [SaleRecordID] => 129317
            [CreationTime] => DateTime Object
                (
                    [date] => 2015-04-03 10:19:48
                    [timezone_type] => 2
                    [timezone] => Z
                )

        )

    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
        (
            [data] => 
            [mimeType] => 
        )

)

接下来我想加载相关的GetSellingManagerSaleRecord。问题是我找不到可以加载正确记录的ID组合。以下是我的尝试:

加载错误的结果,SalesRecordID = 129242 ..我需要129317:

$service = new TradingService();
$request = new Types\GetSellingManagerSaleRecordRequestType();
$request->OrderLineItemID = $result->SaleRecord[0]->SellingManagerSoldTransaction[0]->OrderLineItemID;
$result2 = $service->GetSellingManagerSaleRecord($request);

加载错误的结果,SalesRecordID = 129243 ..我需要129317:

$service = new TradingService();
$request = new Types\GetSellingManagerSaleRecordRequestType();
$request->OrderLineItemID = $result->SaleRecord[0]->SellingManagerSoldTransaction[1]->OrderLineItemID;
$result2 = $service->GetSellingManagerSaleRecord($request);

ErrorCode 21916340,销售记录不存在:

$service = new TradingService();
$request = new Types\GetSellingManagerSaleRecordRequestType();
$transaction = $result->SaleRecord[0]->SellingManagerSoldTransaction[0];
$request->OrderLineItemID = $transaction->ItemID . '-' . $transaction->TransactionID;
$result2 = $service->GetSellingManagerSaleRecord($request);

ErrorCode 21916340,销售记录不存在:

$service = new TradingService();
$request = new Types\GetSellingManagerSaleRecordRequestType();
$request->OrderID = $result->SaleRecord[0]->SaleRecordID;
$result2 = $service->GetSellingManagerSaleRecord($request);

ErrorCode 21916340,销售记录不存在:

$service = new TradingService();
$request = new Types\GetSellingManagerSaleRecordRequestType();
$transaction = $result->SaleRecord[0]->SellingManagerSoldTransaction[0];
$request->ItemID = $transaction->ItemID;
$request->TransactionID = $transaction->TransactionID;
$result2 = $service->GetSellingManagerSaleRecord($request);

1 个答案:

答案 0 :(得分:3)

我不熟悉eBay API的售后服务方面,但根据您要实现的目标,以下内容可能有效。

由于GetSellingManagerSaleRecord不允许您传递已知的SaleRecordID,因此您可以发送OrderID代替。由于每个SaleRecord都有一个关联的订单,您可以使用GetOrders来获取它的ID。

$service = new TradingService();
$request = new Types\GetSellingManagerSoldListingsRequestType();
$request->Search = new Types\SellingManagerSearchType();
$request->Search->SearchType = 'SaleRecordID';
$request->Search->SearchValue = '129317';
$response = $service->GetSellingManagerSoldListings($request);

/**
 * Get the OrderLineItemID of the first transaction in the Sale Record.
 * This would work as well as all the transactions will come from the same order.
 * $orderLineItemID = $response->SaleRecord[0]->SellingManagerSoldTransaction[1]->OrderLineItemID;
 */
$orderLineItemID = $response->SaleRecord[0]->SellingManagerSoldTransaction[0]->OrderLineItemID;

/**
 * Now look up the order.
 */
$request = new Types\GetOrdersRequestType();
$request->OrderIDArray = new Types\OrderIDArrayType();
$request->OrderIDArray->OrderID[] = $orderLineItemID;
$response = $service->getOrders($request);
$orderID = $response->OrderArray->Order[0]->OrderID;

/**
 * Now use the OrderID to call GetSellingManagerSaleRecord.
 */
$request = new Types\GetSellingManagerSaleRecordRequestType();
$request->OrderID = $orderID;
$response = $service->getSellingManagerSaleRecord($request);
/**
 * Check we got the correct SaleRecord.
 */
$saleRecordID = $response->SellingManagerSoldOrder->SaleRecordID;
assert('$saleRecordID === 129317');

除了调用GetSellingManagerSoldListings之外,您还可以调用GetOrders来获取SaleRecordIDs列表。例如:

$request = new Types\GetOrdersRequestType();
$request->NumberOfDays = 30;
$response = $service->getOrders($request);

foreach ($response->OrderArray->Order as $order) {
    printf("SaleRecordID %s\n", $order->ShippingDetails->SellingManagerSalesRecordNumber);
}