Esempio n. 1
0
 private function _make_common_order_list_data($transaction_details)
 {
     $action = 'orderdetail';
     $api_type = "xml";
     //$transaction_details['order_id']=16275;
     $order_gateway_url = $transaction_details['zencart_gateway_url'] . "/" . $action . "/?id=" . $transaction_details['order_id'] . "&domain=" . $transaction_details['domain'] . "&api_type=" . $api_type;
     echo $order_gateway_url . "\n";
     $ch = curl_init();
     $header[] = "Content-type: text/xml";
     //定义content-type为xml
     curl_setopt($ch, CURLOPT_URL, $order_gateway_url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     $response = curl_exec($ch);
     curl_close($ch);
     $arr = parseNamespaceXml(trim($response));
     //echo $arr['Domain']."\n";
     //echo $order_gateway_url;
     //$ship_to_country = $this->mixture_model->get_country_name_in_english_by_code(strtoupper($transaction_details['shipping_address']['country_id']));
     $ship_to_country = $arr['Country'];
     $import_date = date('Y-m-d H:i:s');
     $item_titles = array();
     $item_ids = array();
     $item_qties = array();
     $item_codes = array();
     $item_price = array();
     //var_dump($arr['Products']['Product']);
     //var_dump($arr);
     if ($arr['ItemNum'] == 1) {
         $arr['Products']['Product'] = $arr['Products'];
     }
     foreach ($arr['Products']['Product'] as $key => $product) {
         //var_dump($product);
         //echo $key.":".$value."\n";
         /*
         				if ($this->sale_model->check_exists('product_makeup_sku', array('makeup_sku' => trim($product['Model']) )))
         				{
         					$makeup_sku=$this->product_makeup_sku_model->fetch_makeup_sku_by_sku(trim($product['Model']));
         					$sku_arr=explode(',', $makeup_sku->sku);
         					$qty_arr=explode(',', $makeup_sku->qty);
         					foreach($sku_arr as $key=>$value)
         					{
         						$count_sku=(int)$product['Qty']*$qty_arr[$key];
         						$item_titles[] = trim(base64_decode($product['Title']));
         						$item_qties[] = $count_sku;
         						$item_ids[] = (int)$product['Id'];
         						$item_codes[] = trim($value);
         						$item_price[] = trim($product['Price']);
         						
         					}
         				}else{*/
         $item_titles[] = trim(base64_decode($product['Title']));
         $item_qties[] = (int) $product['Qty'];
         $item_ids[] = (int) $product['Id'];
         $item_codes[] = trim($product['Model']);
         $item_price[] = trim($product['Price']);
         //}
     }
     //$is_register='SGS';// strpos($arr['ShippingMethod'], 'Registered Air Mail') !== false
     $is_register = 'CHS';
     $sp_country = array('ITALY', 'SPAIN', 'PORTUGAL', 'FRANCE', 'BELGIUM', 'LUXEMBOURG', 'MONACO', 'NETHERLANDS', 'UNITED KIONGDOM', 'IRELAND', 'GERMANY');
     $sp_country1 = array('SWEDEN', 'DENMARK', 'FINLAND', 'NORWAY');
     if ($arr['Gross'] < 15 && $arr['Shippingamt'] == '1.99' || $arr['Gross'] >= 15) {
         if (strtoupper($ship_to_country) == 'UNITED STATES') {
             $is_register = 'EUB';
         }
         if (strtoupper($ship_to_country) == 'BRAZIL') {
             $is_register = 'CNR';
         }
         if (in_array(strtoupper($ship_to_country), $sp_country)) {
             $is_register = 'CHR';
         }
         if (in_array(strtoupper($ship_to_country), $sp_country1)) {
             $is_register = 'SGR';
         }
         if (!in_array(strtoupper($ship_to_country), $sp_country1) && !in_array(strtoupper($ship_to_country), $sp_country)) {
             $is_register = 'SGR';
         }
     }
     if (strpos($arr['ShippingMethod'], 'DHL Rates') !== false) {
         $is_register = 'DHL';
     }
     if (strpos($arr['ShippingMethod'], 'EMS Rates') !== false) {
         $is_register = 'EMS';
     }
     $order_status = $this->order_statuses['wait_for_purchase'];
     $sp_country = array('RUSSIA', 'UKRAINE', 'SPAIN', 'ROMANIA', 'VIETNAM', 'MALAYSIA', 'PHILIPPINES', 'ZAMBIA', 'SOUTH AFRICA', 'UGANDA', 'EGYPT', 'SUDAN', 'LIBYA', 'TUNISIA', 'ALGERIA', 'MOROCCO', 'ETHIOPIA', 'KENYA', 'TANZANIA', 'RWANDA', 'SEYCHELLES', 'MALI', 'SIERRA LEONE', 'LIBERIA', "Côte d'Ivoire", 'REPUBLIC OF IVORY COAST', 'GHANA', 'NIGER', 'NIGERIA', 'BENIN', 'CHAD', 'CENTRAL AFRICAN REPUBLIC', 'CAMEROON', 'ANGOLA');
     if ($arr['Gross'] > 200 || $arr['PaymentMethod'] != 'PayPal' || count($item_codes) >= 2 || in_array(strtoupper($ship_to_country), $sp_country)) {
         $order_status = $this->order_statuses['wait_for_confirmation'];
     }
     $auction_sites = explode(" ", preg_replace("/\\s/", " ", $arr['Domain']));
     if ($arr['StoreId'] == 'www.7daysget.com') {
         $auction_sites = '7DG';
     }
     if ($arr['StoreId'] == 'www.screamprice.com') {
         $auction_sites = 'SP';
     }
     $item_no = $arr['ItemNo'];
     $sys_remark = $this->_create_sys_remark($import_date, $item_no);
     $note = !empty($arr['Note']) ? trim(base64_decode($arr['Note'])) : '';
     $note_array = array();
     $note_array = unserialize($note);
     foreach ($note_array as $key => $value) {
         $note_array[$key] = iconv("GB2312", "UTF-8", $value);
     }
     //echo implode('', $note_array);die();
     $data = array('list_date' => $arr['ListDate'], 'list_time' => $arr['ListTime'], 'time_zone' => 'PDT', 'created_at' => $arr['DatePurchased'], 'payment_status' => isset($arr['PaymentStatus']) && !empty($arr['PaymentStatus']) ? $arr['PaymentStatus'] : 'NONE', 'name' => $arr['Name'], 'item_title_str' => implode(ITEM_TITLE_SEP, $item_titles), 'item_id_str' => implode(',', $item_ids), 'item_price_str' => implode(',', $item_price), 'qty_str' => implode(',', $item_qties), 'sku_str' => implode(',', $item_codes), 'currency' => $arr['Currency'], 'gross' => $arr['Gross'], 'fee' => 0, 'net' => $arr['Net'], 'shippingamt' => $arr['Shippingamt'], 'note' => implode('', $note_array), 'from_email' => $arr['FromeMail'], 'to_email' => $this->zencart_web_paypal, 'transaction_id' => isset($arr['PaypalTransactionId']) && !empty($arr['PaypalTransactionId']) ? $arr['PaypalTransactionId'] : '', 'item_no' => $item_no, 'is_register' => $is_register, 'payment_type' => $arr['PaymentMethod'], 'counterparty_status' => '', 'address_status' => '', 'shipping_handling_amount' => '', 'insurance_amount' => 0, 'sales_tax' => $arr['SalesTax'], 'auction_site' => $auction_sites, 'auction_site_type' => 'zencart', 'buyer_id' => $arr['FromeMail'], 'item_url' => '', 'closing_date' => '', 'reference_txn_id' => '', 'invoice_number' => '', 'subscription_number' => '', 'custom_number' => '', 'receipt_id' => '', 'sys_remark' => $sys_remark, 'address_line_1' => preg_replace("/\\s/", " ", $arr['AddressLine']), 'address_line_2' => '', 'town_city' => $arr['TownCity'], 'state_province' => isset($arr['StateProvince']) ? $arr['StateProvince'] : '', 'zip_code' => $arr['ZipCode'], 'country' => $ship_to_country, 'contact_phone_number' => isset($arr['ContactPhoneNumber']) && !empty($arr['ContactPhoneNumber']) ? $arr['ContactPhoneNumber'] : '', 'balance_impact' => '', 'income_type' => '', 'input_date' => $import_date, 'input_from_row' => $arr['InputFromRow'], 'paid_time' => '', 'remote_ip' => $arr['RemoteIp'], 'domain' => $arr['StoreId'], 'order_status' => isset($arr['PaymentStatus']) && $arr['PaymentStatus'] == 'Completed' ? $this->order_statuses['wait_for_confirmation'] : $this->order_statuses['wait_for_finance_confirmation']);
     foreach (explode(',', $data['sku_str']) as $sku) {
         if (!$this->product_model->fetch_product_id(strtoupper($sku)) || 1 == 1) {
             $data['order_status'] = $this->order_statuses['wait_for_confirmation'];
         }
     }
     //var_dump($item_titles);
     //var_dump($item_qties);
     return $data;
 }
 public function get_epacket_specification_print_lable_url($track_code)
 {
     //$product_mode = FALSE;
     $this->CI =& get_instance();
     $this->CI->load->config('config_epacket_specification');
     $ems_token = $this->CI->config->item('ems_token');
     $ems_url = $this->CI->config->item('ems_url');
     $ems_label_url = $this->CI->config->item('ems_label_url');
     $version = $this->CI->config->item('version');
     $orders = array($track_code);
     $xml = epacket_specification_print_lable($orders);
     $order_gateway_url = $ems_url . "print/batch/";
     var_dump($order_gateway_url);
     var_dump($xml);
     //var_dump(utf8_encode($xml));
     //die($order_gateway_url);
     /* 开始提交xml了 */
     $ch = curl_init();
     $header[] = "Content-type: text/xml";
     //定义content-type为xml
     $header[] = "version: " . $version;
     $header[] = "authenticate: " . $ems_token;
     curl_setopt($ch, CURLOPT_URL, $order_gateway_url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
     $response = curl_exec($ch);
     if (curl_errno($ch)) {
         print curl_error($ch);
     }
     curl_close($ch);
     var_dump($response);
     $arr = parseNamespaceXml($response);
     $download_url = isset($arr['description']) ? $arr['description'] : '';
     $this->epacket_model->save_specification_download_url($download_url, $track_code);
     echo "starting confirm packet\n";
     $order = $this->epacket_model->get_specification_epacket_confirm_list_with_track_number($track_code);
     if (!isset($order->lable_download_url)) {
         return false;
     }
     $this->_print_label($order);
 }