コード例 #1
0
 public function complete_sale_merged_orders()
 {
     $all_wait_complete_merged_orders_transaction_ids = $this->order_model->fetch_all_wait_complete_merged_orders();
     var_dump($all_wait_complete_merged_orders_transaction_ids);
     foreach ($all_wait_complete_merged_orders_transaction_ids as $all_wait_complete_merged_orders_transaction_id) {
         $ebay_orders = $this->ebay_order_model->get_ebay_order_by_paypal_transaction_id($all_wait_complete_merged_orders_transaction_id['transaction_id']);
         $order = $this->order_model->get_order($all_wait_complete_merged_orders_transaction_id['old_id']);
         if (empty($order)) {
             return;
         }
         // skip Epacket order
         if ($order->is_register == 'H') {
             return;
         }
         if (empty($order->to_email)) {
             return;
         }
         $ebay_ids = $this->config->item('ebay_id');
         $ebay_id = $order->ebay_id;
         if (empty($ebay_id)) {
             $ebay_id = $ebay_ids[$order->to_email];
             if (empty($ebay_id)) {
                 return;
             }
         }
         $item_ids = explode(',', $order->item_id_str);
         $item_titles = explode(ITEM_TITLE_SEP, $order->item_title_str);
         $track_numbers = explode(',', $order->track_number);
         $order_id = $all_wait_complete_merged_orders_transaction_id['old_id'];
         foreach ($ebay_orders as $ebay_order) {
             $shipping_method = shipping_method($order->is_register);
             $shipping_carrier = $this->_shipping_carrier($shipping_method, $order->country);
             $shipping_date = get_utc_time($order->ship_confirm_date);
             $shipping_note = $shipping_method->name_en;
             $data = array('order_id' => $order_id, 'ebay_id' => $ebay_id, 'track_numbers' => $track_numbers, 'item_id' => $ebay_order->item_id, 'transaction_id' => $ebay_order->transaction_id, 'shipping_carrier' => $shipping_carrier, 'shipping_date' => $shipping_date, 'shipping_note' => $shipping_note);
             print_r($data);
             $this->_proccess_complete_sale($data);
             $data_order = array('is_shiped_ebay' => 1);
             $this->order_model->update_order_merged_list_information($all_wait_complete_merged_orders_transaction_id['transaction_id'], $data_order);
         }
     }
 }
コード例 #2
0
function get_seller_transactions($appToken, $itemInfo)
{
    $itemsPerPage = $itemInfo['itemsPerPage'];
    $pageIndex = $itemInfo['pageIndex'];
    $begin_time = $itemInfo['begin_time'];
    $end_time = $itemInfo['end_time'];
    $create_time_from = get_utc_time('-30 days');
    $requestXMLBody = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<GetSellerTransactions xmlns="urn:ebay:apis:eBLBaseComponents">
  <RequesterCredentials>
    <eBayAuthToken>{$appToken}</eBayAuthToken>
  </RequesterCredentials>
  <DetailLevel>ReturnAll</DetailLevel>
  <Version>741</Version>
  <IncludeFinalValueFee>true</IncludeFinalValueFee>
  <IncludeContainingOrder>true</IncludeContainingOrder>
  <ModTimeFrom>{$begin_time}</ModTimeFrom>
  <ModTimeTo>{$end_time}</ModTimeTo>
  <Pagination>
    <EntriesPerPage>{$itemsPerPage}</EntriesPerPage>
    <PageNumber>{$pageIndex}</PageNumber>
  </Pagination>
</GetSellerTransactions>
XML;
    return $requestXMLBody;
}
コード例 #3
0
ファイル: amazon.php プロジェクト: ohjack/mallerp_standard
 public function test()
 {
     $this->load->config('config_mws_api');
     $amazon_app = $this->config->item('amazon_app');
     //var_dump($amazon_app);
     foreach ($amazon_app as $amazon) {
         $serviceUrl = $amazon['serviceUrl'];
         $amazon_api = array('ServiceURL' => $serviceUrl, 'ProxyHost' => null, 'ProxyPort' => -1, 'MaxErrorRetry' => 3);
         $all_order_id = array();
         $service = new MarketplaceWebServiceOrders_Client($amazon['AWS_ACCESS_KEY_ID'], $amazon['AWS_SECRET_ACCESS_KEY'], $this->config->item('APPLICATION_NAME'), $this->config->item('APPLICATION_VERSION'), $amazon_api);
         $request = new MarketplaceWebServiceOrders_Model_ListOrdersRequest();
         $request->setSellerId($amazon['MERCHANT_ID']);
         //$request->setCreatedAfter(new DateTime('2012-12-17 00:00:00', new DateTimeZone('UTC')));
         $beginning_time = $this->order_model->get_amazon_import_beginning_time();
         $end_time = date('Y-m-d H:i:s', mktime(substr($beginning_time, 11, 2) + 24, substr($beginning_time, 14, 2), substr($beginning_time, 17, 2), substr($beginning_time, 5, 2), substr($beginning_time, 8, 2), substr($beginning_time, 0, 4)));
         $startdate = strtotime($end_time);
         $enddate = strtotime(str_replace("Z", "", str_replace("T", " ", get_utc_time('-20 minutes'))));
         if ($enddate - $startdate <= 0) {
             $end_time = get_utc_time('-20 minutes');
         }
         $end_time = str_replace("Z", "", str_replace("T", " ", $end_time));
         echo "beginning_time[utc]:" . $beginning_time;
         echo "end_time[utc]:" . $end_time;
         //die();
         //$request->setLastUpdatedAfter(new DateTime('2013-01-21 08:43:14', new DateTimeZone('UTC')));
         //$request->setLastUpdatedBefore(new DateTime('2013-01-21 11:10:25', new DateTimeZone('UTC')));
         $request->setLastUpdatedAfter(new DateTime($beginning_time, new DateTimeZone('UTC')));
         $request->setLastUpdatedBefore(new DateTime($end_time, new DateTimeZone('UTC')));
         $orderStatuses = new MarketplaceWebServiceOrders_Model_OrderStatusList();
         $orderStatuses->setStatus(array('Unshipped', 'PartiallyShipped'));
         $request->setOrderStatus($orderStatuses);
         $marketplaceIdList = new MarketplaceWebServiceOrders_Model_MarketplaceIdList();
         $marketplaceIdList->setId(array($amazon['MARKETPLACE_ID']));
         $request->setMarketplaceId($marketplaceIdList);
         $orderids = $this->invokeListOrders($service, $request);
         $all_order_id = $orderids[1];
         //var_dump($orderids);die();
         $next_token = $orderids[0];
         while ($next_token != '') {
             $request = new MarketplaceWebServiceOrders_Model_ListOrdersByNextTokenRequest();
             $request->setSellerId($amazon['MERCHANT_ID']);
             $request->setNextToken($orderids[0]);
             $orderids = $this->invokeListOrdersByNextToken($service, $request);
             $next_token = $orderids[0];
             $all_order_id = array_merge($all_order_id, $orderids[1]);
             //var_dump($orderids);
         }
         //var_dump($all_order_id);
         foreach ($all_order_id as $order_id) {
             $order_info = array();
             $items = array();
             $data = array();
             $amazon_pdf_data = array();
             $amazon_ack_failed_data = array();
             $request = new MarketplaceWebServiceOrders_Model_GetOrderRequest();
             $request->setSellerId($amazon['MERCHANT_ID']);
             $request->setAmazonOrderId(array($order_id));
             // object or array of parameters
             $order_info = $this->invokeGetOrder($service, $request);
             //var_dump($order_info);
             $request = new MarketplaceWebServiceOrders_Model_ListOrderItemsRequest();
             $request->setSellerId($amazon['MERCHANT_ID']);
             $request->setAmazonOrderId($order_id);
             // object or array of parameters
             $items = $this->invokeListOrderItems($service, $request);
             //var_dump($items);
             if (!isset($order_info['AmazonOrderId'])) {
                 $this->log_report($order_id);
                 $amazon_ack_failed_data = array('amazonorderid' => $order_id, 'sellerid' => $amazon['MERCHANT_ID']);
                 if (!$this->order_model->check_amazon_ack_failed_exists($order_id)) {
                     $this->order_model->add_amazon_ack_failed($amazon_ack_failed_data);
                 }
                 continue;
             }
             $data = $this->_make_common_order_list_data($order_info, $items);
             //var_dump($data);
             if ($this->order_model->check_exists('order_list', array('transaction_id' => $data['transaction_id']))) {
                 echo $data['transaction_id'] . "存在\n";
                 /*
                 					$invoice_begin=2372;
                 					$invoice_id=$invoice_begin+$this->order_model->fetch_all_amazon_count()+1;
                 					$amazon_pdf_data=array(
                 						'amazonorderid'=>$order_info['AmazonOrderId'],
                 						'sellerid'=>$amazon['MERCHANT_ID'],
                 						'invoice_id'=>$invoice_id,
                 						);
                 					if(!$this->order_model->check_wait_create_amazon_pdf_exists($order_id))
                 					{
                 						$this->order_model->add_wait_create_amazon_pdf($amazon_pdf_data);
                 					}*/
             } else {
                 $this->order_model->add_order($data);
                 $invoice_begin = 2372;
                 $invoice_id = $invoice_begin + $this->order_model->fetch_all_amazon_count() + 1;
                 $amazon_pdf_data = array('amazonorderid' => $order_info['AmazonOrderId'], 'sellerid' => $amazon['MERCHANT_ID'], 'invoice_id' => $invoice_id);
                 if (!$this->order_model->check_wait_create_amazon_pdf_exists($order_id) && $order_info['AmazonOrderId'] != '') {
                     $this->order_model->add_wait_create_amazon_pdf($amazon_pdf_data);
                 }
                 echo $data['transaction_id'] . "保存成功\n";
             }
             sleep(2);
         }
         $this->order_model->update_amazon_import_beginning_time(array('value' => $end_time));
     }
 }
コード例 #4
0
 public function complete_sale_merged_orders()
 {
     $all_wait_complete_merged_orders_transaction_ids = $this->order_model->fetch_all_wait_complete_merged_orders();
     var_dump($all_wait_complete_merged_orders_transaction_ids);
     foreach ($all_wait_complete_merged_orders_transaction_ids as $all_wait_complete_merged_orders_transaction_id) {
         $ebay_orders = $this->ebay_order_model->get_ebay_order_by_paypal_transaction_id($all_wait_complete_merged_orders_transaction_id['transaction_id']);
         $order = $this->order_model->get_order($all_wait_complete_merged_orders_transaction_id['old_id']);
         if (empty($order)) {
             continue;
         }
         if ($order->auction_site_type == 'wish') {
             echo "wish merged order:" . $order->id . "\n";
             $this->script->complete_wish_sale(array('order_id' => $order->id));
             continue;
         }
         //echo "********0";var_dump($ebay_orders);
         $ebay_ids = $this->config->item('ebay_id');
         $ebay_id = $order->ebay_id;
         if (empty($ebay_id)) {
             //$ebay_id = $ebay_ids[$order->to_email];
             //if (empty($ebay_id))
             //{
             echo $order->id . "ebay id is empty!\n";
             continue;
             //}
         }
         $item_ids = explode(',', $order->item_id_str);
         $item_titles = explode(ITEM_TITLE_SEP, $order->item_title_str);
         $track_numbers = explode(',', $order->track_number);
         $order_id = $all_wait_complete_merged_orders_transaction_id['old_id'];
         //echo "********1";var_dump($ebay_orders);
         foreach ($ebay_orders as $ebay_order) {
             $shipping_method = shipping_method($order->is_register);
             $shipping_carrier = $this->_shipping_carrier($shipping_method, $order->country);
             $shipping_date = get_utc_time($order->ship_confirm_date);
             $shipping_note = $shipping_method->name_en;
             $data = array('order_id' => $order_id, 'ebay_id' => $ebay_id, 'track_numbers' => $track_numbers, 'item_id' => $ebay_order->item_id, 'transaction_id' => $ebay_order->transaction_id, 'shipping_carrier' => $shipping_carrier, 'shipping_date' => $shipping_date, 'shipping_note' => $shipping_note);
             echo "-----";
             print_r($data);
             $this->_proccess_complete_sale($data);
             $data_order = array('is_shiped_ebay' => 1);
             $this->order_model->update_order_merged_list_information($all_wait_complete_merged_orders_transaction_id['transaction_id'], $data_order);
         }
     }
 }
コード例 #5
0
ファイル: paypal.php プロジェクト: ohjack/mallerp_standard
 public function import_transactions($user_name)
 {
     if (strpos($_SERVER['SCRIPT_FILENAME'], 'paypal_order.php') === FALSE) {
         exit;
     }
     $all_transactions = array();
     $this->user = $user_name;
     $this->uid = $this->order_model->get_user_id_by_name($user_name);
     $this->paypal = $this->paypal_model->get_paypal_account($user_name);
     //把上次时间前推5分钟,覆盖漏单情况
     //$datetimes = explode(":",$this->paypal_model->get_paypal_import_beginning_time($this->user));
     $datetimes = str_replace("Z", "", str_replace("T", " ", $this->paypal_model->get_paypal_import_beginning_time($this->user)));
     $datetime = date('Y-m-d\\TH:i:s\\Z', mktime(substr($datetimes, 11, 2), substr($datetimes, 14, 2) - 2, substr($datetimes, 17, 2), substr($datetimes, 5, 2), substr($datetimes, 8, 2), substr($datetimes, 0, 4)));
     $this->start_time = $datetime;
     //$this->start_time = $this->paypal_model->get_paypal_import_beginning_time($this->user);
     //$this->end_time = get_utc_time('-5 minutes');  // 5 minutes ago
     $this->end_time = date('Y-m-d\\TH:i:s\\Z', mktime(substr($datetimes, 11, 2) + 40, substr($datetimes, 14, 2), substr($datetimes, 17, 2), substr($datetimes, 5, 2), substr($datetimes, 8, 2), substr($datetimes, 0, 4)));
     $startdate = strtotime($this->end_time);
     $enddate = strtotime(get_utc_time('-5 minutes'));
     if ($enddate - $startdate <= 0) {
         $this->end_time = get_utc_time('-5 minutes');
     }
     echo "End time: ", $this->end_time, "\n";
     $start_time = $this->start_time;
     $end_time = $this->end_time;
     //$start_time = '2012-10-19T19:45:59Z';
     //$end_time = '2012-10-19T19:45:59Z';
     $save_end_time = $end_time;
     while ($transactions = $this->process_transaction_search($start_time, $end_time)) {
         $transaction_count = count($transactions);
         if ($transaction_count > 0) {
             $end_time = $transactions[$transaction_count - 1]['timeStamp'];
             $all_transactions = array_merge($all_transactions, $transactions);
             if (strcmp($end_time, $start_time) <= 0 || strcasecmp($save_end_time, $end_time) == 0) {
                 break;
             }
             $save_end_time = $end_time;
         } else {
             break;
         }
     }
     $all_transactions = array_reverse($all_transactions);
     $this->_proccess_import_transactions($all_transactions);
     $this->paypal_model->update_paypal_import_beginning_time(array('value' => $this->end_time), $this->user);
     $this->log_report();
     echo 'Done!';
 }