function invokeListOrdersByNextToken(MarketplaceWebServiceOrders_Interface $service, $request, $tokens)
{
    try {
        $response = $service->listOrdersByNextToken($request);
        print_r($response);
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        ListOrdersByNextTokenResponse\n";
        if ($response->isSetListOrdersByNextTokenResult()) {
            echo "            ListOrdersByNextTokenResult\n";
            $listOrdersByNextTokenResult = $response->getListOrdersByNextTokenResult();
            if ($listOrdersByNextTokenResult->isSetCreatedBefore()) {
                echo "                CreatedBefore\n";
                echo "                    " . $listOrdersByNextTokenResult->getCreatedBefore() . "\n";
            }
            if ($listOrdersByNextTokenResult->isSetLastUpdatedBefore()) {
                echo "                LastUpdatedBefore\n";
                echo "                    " . $listOrdersByNextTokenResult->getLastUpdatedBefore() . "\n";
            }
            if ($listOrdersByNextTokenResult->isSetOrders()) {
                echo "                Orders\n";
                $orders = $listOrdersByNextTokenResult->getOrders();
                $orderList = $orders->getOrder();
                foreach ($orderList as $order) {
                    echo "                    Order\n";
                    if ($order->isSetAmazonOrderId()) {
                        echo "                        AmazonOrderId\n";
                        echo "                            " . $order->getAmazonOrderId() . "\n";
                    }
                    if ($order->isSetSellerOrderId()) {
                        echo "                        SellerOrderId\n";
                        echo "                            " . $order->getSellerOrderId() . "\n";
                    }
                    if ($order->isSetPurchaseDate()) {
                        echo "                        PurchaseDate\n";
                        echo "                            " . $order->getPurchaseDate() . "\n";
                    }
                    if ($order->isSetLastUpdateDate()) {
                        echo "                        LastUpdateDate\n";
                        echo "                            " . $order->getLastUpdateDate() . "\n";
                    }
                    if ($order->isSetOrderStatus()) {
                        echo "                        OrderStatus\n";
                        echo "                            " . $order->getOrderStatus() . "\n";
                    }
                    if ($order->isSetFulfillmentChannel()) {
                        echo "                        FulfillmentChannel\n";
                        echo "                            " . $order->getFulfillmentChannel() . "\n";
                    }
                    if ($order->isSetSalesChannel()) {
                        echo "                        SalesChannel\n";
                        echo "                            " . $order->getSalesChannel() . "\n";
                    }
                    if ($order->isSetOrderChannel()) {
                        echo "                        OrderChannel\n";
                        echo "                            " . $order->getOrderChannel() . "\n";
                    }
                    if ($order->isSetShipServiceLevel()) {
                        echo "                        ShipServiceLevel\n";
                        echo "                            " . $order->getShipServiceLevel() . "\n";
                    }
                    if ($order->isSetShippingAddress()) {
                        echo "                        ShippingAddress\n";
                        $shippingAddress = $order->getShippingAddress();
                        if ($shippingAddress->isSetName()) {
                            echo "                            Name\n";
                            echo "                                " . $shippingAddress->getName() . "\n";
                        }
                        if ($shippingAddress->isSetAddressLine1()) {
                            echo "                            AddressLine1\n";
                            echo "                                " . $shippingAddress->getAddressLine1() . "\n";
                        }
                        if ($shippingAddress->isSetAddressLine2()) {
                            echo "                            AddressLine2\n";
                            echo "                                " . $shippingAddress->getAddressLine2() . "\n";
                        }
                        if ($shippingAddress->isSetAddressLine3()) {
                            echo "                            AddressLine3\n";
                            echo "                                " . $shippingAddress->getAddressLine3() . "\n";
                        }
                        if ($shippingAddress->isSetCity()) {
                            echo "                            City\n";
                            echo "                                " . $shippingAddress->getCity() . "\n";
                        }
                        if ($shippingAddress->isSetCounty()) {
                            echo "                            County\n";
                            echo "                                " . $shippingAddress->getCounty() . "\n";
                        }
                        if ($shippingAddress->isSetDistrict()) {
                            echo "                            District\n";
                            echo "                                " . $shippingAddress->getDistrict() . "\n";
                        }
                        if ($shippingAddress->isSetStateOrRegion()) {
                            echo "                            StateOrRegion\n";
                            echo "                                " . $shippingAddress->getStateOrRegion() . "\n";
                        }
                        if ($shippingAddress->isSetPostalCode()) {
                            echo "                            PostalCode\n";
                            echo "                                " . $shippingAddress->getPostalCode() . "\n";
                        }
                        if ($shippingAddress->isSetCountryCode()) {
                            echo "                            CountryCode\n";
                            echo "                                " . $shippingAddress->getCountryCode() . "\n";
                        }
                        if ($shippingAddress->isSetPhone()) {
                            echo "                            Phone\n";
                            echo "                                " . $shippingAddress->getPhone() . "\n";
                        }
                    }
                    if ($order->isSetOrderTotal()) {
                        echo "                        OrderTotal\n";
                        $orderTotal = $order->getOrderTotal();
                        if ($orderTotal->isSetCurrencyCode()) {
                            echo "                            CurrencyCode\n";
                            echo "                                " . $orderTotal->getCurrencyCode() . "\n";
                        }
                        if ($orderTotal->isSetAmount()) {
                            echo "                            Amount\n";
                            echo "                                " . $orderTotal->getAmount() . "\n";
                        }
                    }
                    if ($order->isSetNumberOfItemsShipped()) {
                        echo "                        NumberOfItemsShipped\n";
                        echo "                            " . $order->getNumberOfItemsShipped() . "\n";
                    }
                    if ($order->isSetNumberOfItemsUnshipped()) {
                        echo "                        NumberOfItemsUnshipped\n";
                        echo "                            " . $order->getNumberOfItemsUnshipped() . "\n";
                    }
                    if ($order->isSetPaymentExecutionDetail()) {
                        echo "                        PaymentExecutionDetail\n";
                        $paymentExecutionDetail = $order->getPaymentExecutionDetail();
                        $paymentExecutionDetailItemList = $paymentExecutionDetail->getPaymentExecutionDetailItem();
                        foreach ($paymentExecutionDetailItemList as $paymentExecutionDetailItem) {
                            echo "                            PaymentExecutionDetailItem\n";
                            if ($paymentExecutionDetailItem->isSetPayment()) {
                                echo "                                Payment\n";
                                $payment = $paymentExecutionDetailItem->getPayment();
                                if ($payment->isSetCurrencyCode()) {
                                    echo "                                    CurrencyCode\n";
                                    echo "                                        " . $payment->getCurrencyCode() . "\n";
                                }
                                if ($payment->isSetAmount()) {
                                    echo "                                    Amount\n";
                                    echo "                                        " . $payment->getAmount() . "\n";
                                }
                            }
                            if ($paymentExecutionDetailItem->isSetSubPaymentMethod()) {
                                echo "                                SubPaymentMethod\n";
                                echo "                                    " . $paymentExecutionDetailItem->getSubPaymentMethod() . "\n";
                            }
                        }
                    }
                    if ($order->isSetPaymentMethod()) {
                        echo "                        PaymentMethod\n";
                        echo "                            " . $order->getPaymentMethod() . "\n";
                    }
                    if ($order->isSetMarketplaceId()) {
                        echo "                        MarketplaceId\n";
                        echo "                            " . $order->getMarketplaceId() . "\n";
                    }
                    if ($order->isSetBuyerEmail()) {
                        echo "                        BuyerEmail\n";
                        echo "                            " . $order->getBuyerEmail() . "\n";
                    }
                    if ($order->isSetBuyerName()) {
                        echo "                        BuyerName\n";
                        echo "                            " . $order->getBuyerName() . "\n";
                    }
                    if ($order->isSetShipmentServiceLevelCategory()) {
                        echo "                        ShipmentServiceLevelCategory\n";
                        echo "                            " . $order->getShipmentServiceLevelCategory() . "\n";
                    }
                }
            }
            if ($listOrdersByNextTokenResult->isSetNextToken()) {
                echo "                NextToken\n";
                echo "                    " . $listOrdersByNextTokenResult->getNextToken() . "\n";
                $tokens = $listOrdersByNextTokenResult->getNextToken();
                return $tokens;
            } else {
                return 0;
            }
        }
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
    } catch (MarketplaceWebServiceOrders_Exception $ex) {
        echo "Caught Exception: " . $ex->getMessage() . "\n";
        echo "Response Status Code: " . $ex->getStatusCode() . "\n";
        echo "Error Code: " . $ex->getErrorCode() . "\n";
        echo "Error Type: " . $ex->getErrorType() . "\n";
        echo "Request ID: " . $ex->getRequestId() . "\n";
        echo "XML: " . $ex->getXML() . "\n";
    }
}
function invokeListOrdersByNextToken(MarketplaceWebServiceOrders_Interface $service, $request, $tokens)
{
    try {
        $response = $service->listOrdersByNextToken($request);
        echo '我执行了,invokeListOrdersByNextToken,,';
        echo "Service Response\n";
        echo "=============================================================================\n";
        echo "        ListOrdersByNextTokenResponse\n";
        if ($response->isSetListOrdersByNextTokenResult()) {
            echo "            ListOrdersByNextTokenResult\n";
            $listOrdersByNextTokenResult = $response->getListOrdersByNextTokenResult();
            if ($listOrdersByNextTokenResult->isSetCreatedBefore()) {
                echo "                CreatedBefore\n";
                echo "                    " . $listOrdersByNextTokenResult->getCreatedBefore() . "\n";
            }
            if ($listOrdersByNextTokenResult->isSetLastUpdatedBefore()) {
                echo "                LastUpdatedBefore\n";
                echo "                    " . $listOrdersByNextTokenResult->getLastUpdatedBefore() . "\n";
            }
            if ($listOrdersByNextTokenResult->isSetOrders()) {
                echo "                Orders\n";
                $orders = $listOrdersByNextTokenResult->getOrders();
                $orderList = $orders->getOrder();
                foreach ($orderList as $order) {
                    $val = '';
                    if ($order->isSetSellerOrderId()) {
                        //         echo("                        SellerOrderId\n");
                        //         echo("                            " . $order->getSellerOrderId() . "\n");
                    }
                    if ($order->isSetPurchaseDate()) {
                        $CreatedDate = strtotime($order->getPurchaseDate());
                    }
                    if ($order->isSetLastUpdateDate()) {
                        $PaidTime = strtotime($order->getLastUpdateDate());
                    }
                    $orderstatus = '';
                    if ($order->isSetOrderStatus()) {
                        if ($order->getOrderStatus() == 'Unshipped') {
                            $orderstatus = 822;
                        }
                    }
                    if ($order->isSetAmazonOrderId() && $orderstatus == '822') {
                        $val = $order->getAmazonOrderId();
                        $request = new MarketplaceWebServiceOrders_Model_ListOrderItemsRequest();
                        $request->setSellerId(MERCHANT_ID);
                        $request->setAmazonOrderId($val);
                        if ($val != '') {
                            invokeListOrderItems($service, $request, $val, $account);
                        }
                    }
                    if ($order->isSetFulfillmentChannel()) {
                        // echo("                        FulfillmentChannel\n");
                        // echo("                            " . $order->getFulfillmentChannel() . "\n");
                    }
                    if ($order->isSetSalesChannel()) {
                        //  echo("                        SalesChannel\n");
                        //  echo("                            " . $order->getSalesChannel() . "\n");
                    }
                    if ($order->isSetOrderChannel()) {
                        //  echo("                        OrderChannel\n");
                        //  echo("                            " . $order->getOrderChannel() . "\n");
                    }
                    if ($order->isSetShipServiceLevel()) {
                        //  echo("                        ShipServiceLevel\n");
                        //  echo("                            " . $order->getShipServiceLevel() . "\n");
                    }
                    $Street1 = '';
                    $Street2 = '';
                    $CityName = '';
                    $StateOrProvince = '';
                    if ($order->isSetShippingAddress()) {
                        $shippingAddress = $order->getShippingAddress();
                        if ($shippingAddress->isSetName()) {
                            $Name = mysql_escape_string($shippingAddress->getName());
                        }
                        if ($shippingAddress->isSetAddressLine1()) {
                            $Street1 = mysql_escape_string($shippingAddress->getAddressLine1());
                        }
                        if ($shippingAddress->isSetAddressLine2()) {
                            $Street2 = mysql_escape_string($shippingAddress->getAddressLine2());
                        }
                        if ($shippingAddress->isSetAddressLine3()) {
                            //    echo("                                " . $shippingAddress->getAddressLine3() . "\n");
                        }
                        if ($shippingAddress->isSetCity()) {
                            $CityName = mysql_escape_string($shippingAddress->getCity());
                        }
                        if ($shippingAddress->isSetCounty()) {
                            $CountryName = $shippingAddress->getCounty();
                        }
                        if ($shippingAddress->isSetDistrict()) {
                            //    echo("                                " . $shippingAddress->getDistrict() . "\n");
                        }
                        if ($shippingAddress->isSetStateOrRegion()) {
                            $StateOrProvince = $shippingAddress->getStateOrRegion();
                        }
                        if ($shippingAddress->isSetPostalCode()) {
                            $PostalCode = $shippingAddress->getPostalCode();
                        }
                        if ($shippingAddress->isSetCountryCode()) {
                            $Country = $shippingAddress->getCountryCode();
                        }
                        if ($shippingAddress->isSetPhone()) {
                            $Phone = $shippingAddress->getPhone();
                        }
                    }
                    if ($order->isSetOrderTotal()) {
                        $orderTotal = $order->getOrderTotal();
                        if ($orderTotal->isSetCurrencyCode()) {
                            $Currency = $orderTotal->getCurrencyCode();
                        }
                        if ($orderTotal->isSetAmount()) {
                            $AmountPaid = $orderTotal->getAmount();
                        }
                    }
                    if ($order->isSetNumberOfItemsShipped()) {
                        // echo("                            " . $order->getNumberOfItemsShipped() . "\n");
                    }
                    if ($order->isSetNumberOfItemsUnshipped()) {
                        //  echo("                            " . $order->getNumberOfItemsUnshipped() . "\n");
                    }
                    if ($order->isSetPaymentExecutionDetail()) {
                        $paymentExecutionDetail = $order->getPaymentExecutionDetail();
                        $paymentExecutionDetailItemList = $paymentExecutionDetail->getPaymentExecutionDetailItem();
                        foreach ($paymentExecutionDetailItemList as $paymentExecutionDetailItem) {
                            // echo("                            PaymentExecutionDetailItem\n");
                            if ($paymentExecutionDetailItem->isSetPayment()) {
                                //  echo("                                Payment\n");
                                $payment = $paymentExecutionDetailItem->getPayment();
                                if ($payment->isSetCurrencyCode()) {
                                    // echo("                                    CurrencyCode\n");
                                    // echo("                                        " . $payment->getCurrencyCode() . "\n");
                                }
                                if ($payment->isSetAmount()) {
                                    //  echo("                                    Amount\n");
                                    // echo("                                        " . $payment->getAmount() . "\n");
                                }
                            }
                            if ($paymentExecutionDetailItem->isSetSubPaymentMethod()) {
                                //  echo("                                SubPaymentMethod\n");
                                //  echo("                                    " . $paymentExecutionDetailItem->getSubPaymentMethod() . "\n");
                            }
                        }
                    }
                    if ($order->isSetPaymentMethod()) {
                        //echo("                        PaymentMethod\n");
                        //echo("                            " . $order->getPaymentMethod() . "\n");
                    }
                    if ($order->isSetMarketplaceId()) {
                        //echo("                        MarketplaceId\n");
                        // echo("                            " . $order->getMarketplaceId() . "\n");
                    }
                    if ($order->isSetBuyerEmail()) {
                        //   echo("                        BuyerEmail\n");
                        //    echo("                            " . $order->getBuyerEmail() . "\n");
                        $Email = $order->getBuyerEmail();
                    }
                    if ($order->isSetBuyerName()) {
                        $UserID = mysql_escape_string($order->getBuyerName());
                    }
                    if ($order->isSetShipmentServiceLevelCategory()) {
                        //echo("                        ShipmentServiceLevelCategory\n");
                        // echo("                            " . $order->getShipmentServiceLevelCategory() . "\n");
                    }
                    $Country_q = countryname_change($Country);
                    $sql = "INSERT INTO `ebay_order` (`ebay_paystatus`,`ebay_ordersn` ,`ebay_tid` ,`ebay_ptid` ,`ebay_orderid` ,";
                    $sql .= "`ebay_createdtime` ,`ebay_paidtime` ,`ebay_userid` ,`ebay_username` ,`ebay_usermail` ,`ebay_street` ,";
                    $sql .= "`ebay_street1` ,`ebay_city` ,`ebay_state` ,`ebay_couny` ,`ebay_countryname` ,`ebay_postcode` ,`ebay_phone`";
                    $sql .= " ,`ebay_currency` ,`ebay_total` ,`ebay_status`,`ebay_user`,`ebay_shipfee`,`ebay_account`,`recordnumber`,`ebay_addtime`,`ebay_note`,`ebay_site`,`eBayPaymentStatus`,`PayPalEmailAddress`,`ShippedTime`,`RefundAmount`,`ebay_warehouse`,`order_no`)VALUES ('Complete','{$val}', '{$tid}' , '{$ptid}' , '{$orderid}' , '{$CreatedDate}' , '{$PaidTime}' , '{$UserID}' ,";
                    $sql .= " '{$Name}' , '{$Email}' , '{$Street1}' , '{$Street2}' , '{$CityName}','{$StateOrProvince}' , '{$Country}' , '{$Country_q}' , '{$PostalCode}' , '{$Phone}' , '{$Currency}' , '{$AmountPaid}' , '{$orderstatus}','{$user}','{$shipingfee}','{$account}','" . ($addrecordnumber == '' ? $val : $addrecordnumber) . "','{$mctime}','{$BuyerCheckoutMessage}','{$site}','{$eBayPaymentStatus}','{$PayPalEmailAddress}','{$ShippedTime}','{$RefundAmount}','{$defaultstoreid}','{$order_no}')";
                    $sg = "select * from ebay_order where ebay_ordersn ='{$val}' ";
                    $sg = $dbcon->execute($sg);
                    $sg = $dbcon->getResultArray($sg);
                    if (count($sg) == 0) {
                        $dbcon->execute($sql);
                        addLog("ordersn:{$val} 添加成功。");
                    } else {
                        addLog("ordersn:{$val} 在数据库中已经存在。");
                    }
                }
            }
            if ($listOrdersByNextTokenResult->isSetNextToken()) {
                echo "                NextToken\n";
                echo "                    " . $listOrdersByNextTokenResult->getNextToken() . "\n";
                $tokens = $listOrdersByNextTokenResult->getNextToken();
                return $tokens;
            } else {
                return 0;
            }
        }
        if ($response->isSetResponseMetadata()) {
            echo "            ResponseMetadata\n";
            $responseMetadata = $response->getResponseMetadata();
            if ($responseMetadata->isSetRequestId()) {
                echo "                RequestId\n";
                echo "                    " . $responseMetadata->getRequestId() . "\n";
            }
        }
    } catch (MarketplaceWebServiceOrders_Exception $ex) {
        echo "Caught Exception: " . $ex->getMessage() . "\n";
        echo "Response Status Code: " . $ex->getStatusCode() . "\n";
        echo "Error Code: " . $ex->getErrorCode() . "\n";
        echo "Error Type: " . $ex->getErrorType() . "\n";
        echo "Request ID: " . $ex->getRequestId() . "\n";
        echo "XML: " . $ex->getXML() . "\n";
    }
}
Exemplo n.º 3
0
 function invokeListOrdersByNextToken(MarketplaceWebServiceOrders_Interface $service, $request)
 {
     $AmazonOrderIds = array();
     $return_array = array();
     $NextToken = '';
     try {
         $response = $service->listOrdersByNextToken($request);
         if ($response->isSetListOrdersByNextTokenResult()) {
             $listOrdersByNextTokenResult = $response->getListOrdersByNextTokenResult();
             if ($listOrdersByNextTokenResult->isSetNextToken()) {
                 $NextToken = $listOrdersByNextTokenResult->getNextToken();
             }
             if ($listOrdersByNextTokenResult->isSetOrders()) {
                 $orders = $listOrdersByNextTokenResult->getOrders();
                 $orderList = $orders->getOrder();
                 foreach ($orderList as $order) {
                     if ($order->isSetAmazonOrderId()) {
                         $AmazonOrderIds[] = $order->getAmazonOrderId();
                     }
                 }
             }
         }
         $return_array = array($NextToken, $AmazonOrderIds);
         return $return_array;
     } catch (MarketplaceWebServiceOrders_Exception $ex) {
         echo "Caught Exception: " . $ex->getMessage() . "\n";
         echo "Response Status Code: " . $ex->getStatusCode() . "\n";
         echo "Error Code: " . $ex->getErrorCode() . "\n";
         echo "Error Type: " . $ex->getErrorType() . "\n";
         echo "Request ID: " . $ex->getRequestId() . "\n";
         echo "XML: " . $ex->getXML() . "\n";
         echo "ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n";
     }
 }