Exemple #1
0
 public function product_details()
 {
     $this->language->load('app/app');
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $str = str_replace(""", "\"", $this->request->post['param']);
         $param = json_decode($str, true);
         $url = $param['url'];
         $url = str_replace("amp;", "", $url);
         $search = htmlspecialchars_decode($url);
         include_once DIR_SYSTEM . 'taobao.class.php';
         if (preg_match('/[http|https]:\\/\\/[\\w.]+[\\w\\/]*[\\w.]*\\??[\\w=&\\+\\%]*/is', $search)) {
             if (false !== strpos($search, 'taobao.com') || false !== strpos($search, 'tmall.com')) {
                 $url_info = parse_url($search);
                 parse_str($url_info['query'], $param);
                 if (!$param['id'] && $param['tradeID']) {
                     $param['id'] = $param['tradeID'];
                 }
                 if (!$param['id'] && $param['meal_id']) {
                     $param['id'] = $param['meal_id'];
                 }
                 $result = TAOBAO::getItemInfo($param);
                 if ($result) {
                     $result = array_map('strip_tags', $result);
                     $result = array_map('trim', $result);
                     $arr = json_encode(array("data" => array("resultCode" => 1, "result" => $result)));
                     echo $arr;
                 } else {
                     $arr = json_encode(array('data' => array('resultCode' => 0, 'errorMessage' => $this->language->get('error_sold_out'))));
                     echo $arr;
                 }
             }
         }
     } else {
         $arr = json_encode(array('data' => array('resultCode' => 0, 'errorMessage' => $this->language->get('error_post'))));
         echo $arr;
     }
 }
Exemple #2
0
 public function index()
 {
     $this->data['categoryName'] = isset($_GET['categoryName']) ? $_GET['categoryName'] : '';
     $this->data['productCategoryName'] = isset($_GET['productCategoryName']) ? $_GET['productCategoryName'] : '';
     $this->language->load('product/product');
     // $this->document->addScript('catalog/view/javascript/jquery2/product.js');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->load->model('catalog/category');
     if (isset($this->request->get['path'])) {
         $path = '';
         $parts = explode('_', (string) $this->request->get['path']);
         // var_dump($parts);
         $small_id = isset($parts[1]) ? $parts[1] : '';
         $category_id = (int) array_pop($parts);
         $big_id = isset($parts[0]) ? $parts[0] : '';
         // var_dump($big_id.'_'.$small_id);
         //error_log($big_id."_".$small_id."\r\n",3,"./errors.log");
         $this->data['categoryName'] = $this->model_catalog_category->getSingalBigCategory($big_id);
         $this->data['s_categoryName'] = $this->model_catalog_category->getSingalSmallCategory($small_id);
         $this->data['productCategoryName'] = $this->model_catalog_category->getSingalProduct($this->request->get['product_id']);
         $this->data['path1'] = $big_id . '_' . $big_id;
         $this->data['path'] = $this->request->get['path'];
         foreach ($parts as $path_id) {
             if (!$path) {
                 $path = $path_id;
             } else {
                 $path .= '_' . $path_id;
             }
             $category_info = $this->model_catalog_category->getCategory($path_id);
             if ($category_info) {
                 $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $path), 'separator' => $this->language->get('text_separator'));
             }
         }
         // Set the last category breadcrumb
         $category_info = $this->model_catalog_category->getCategory($category_id);
         if ($category_info) {
             $url = '';
             if (isset($this->request->get['sort'])) {
                 $url .= '&sort=' . $this->request->get['sort'];
             }
             if (isset($this->request->get['order'])) {
                 $url .= '&order=' . $this->request->get['order'];
             }
             if (isset($this->request->get['page'])) {
                 $url .= '&page=' . $this->request->get['page'];
             }
             if (isset($this->request->get['limit'])) {
                 $url .= '&limit=' . $this->request->get['limit'];
             }
             $this->data['breadcrumbs'][] = array('text' => $category_info['name'], 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url), 'separator' => $this->language->get('text_separator'));
         }
     } else {
         $this->data['s_categoryName'] = 0;
         if (isset($this->request->get['product_id'])) {
             $get_product_id = $this->request->get['product_id'];
         } else {
             $get_product_id = '';
         }
         $this->data['productCategoryName'] = $this->model_catalog_category->getSingalProduct($get_product_id);
     }
     $this->load->model('catalog/manufacturer');
     if (isset($this->request->get['manufacturer_id'])) {
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator'));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
         if ($manufacturer_info) {
             $this->data['breadcrumbs'][] = array('text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url), 'separator' => $this->language->get('text_separator'));
         }
     }
     if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
         $url = '';
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url), 'separator' => $this->language->get('text_separator'));
     }
     if (isset($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         $product_id = 0;
     }
     $this->load->model('catalog/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     //产品信息
     if ($product_info) {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $product_info['name'], 'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id']), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($product_info['name'] . "-CNstorm");
         $this->document->setDescription($product_info['meta_description']);
         $this->document->setKeywords($product_info['meta_keyword']);
         $this->document->addLink($this->url->link('product/product', 'product_id=' . $this->request->get['product_id']), 'canonical');
         $this->document->addScript('catalog/view/javascript/jquery/tabs.js');
         $this->document->addScript('catalog/view/javascript/jquery/colorbox/jquery.colorbox-min.js');
         $this->document->addStyle('catalog/view/javascript/jquery/colorbox/colorbox.css');
         $this->data['heading_title'] = $product_info['name'];
         $this->data['text_select'] = $this->language->get('text_select');
         $this->data['text_manufacturer'] = $this->language->get('text_manufacturer');
         $this->data['text_model'] = $this->language->get('text_model');
         $this->data['text_reward'] = $this->language->get('text_reward');
         $this->data['text_points'] = $this->language->get('text_points');
         $this->data['text_discount'] = $this->language->get('text_discount');
         $this->data['text_stock'] = $this->language->get('text_stock');
         $this->data['text_price'] = $this->language->get('text_price');
         $this->data['text_tax'] = $this->language->get('text_tax');
         $this->data['text_discount'] = $this->language->get('text_discount');
         $this->data['text_option'] = $this->language->get('text_option');
         $this->data['text_qty'] = $this->language->get('text_qty');
         $this->data['text_minimum'] = sprintf($this->language->get('text_minimum'), $product_info['minimum']);
         $this->data['text_or'] = $this->language->get('text_or');
         $this->data['text_write'] = $this->language->get('text_write');
         $this->data['text_note'] = $this->language->get('text_note');
         $this->data['text_share'] = $this->language->get('text_share');
         $this->data['text_wait'] = $this->language->get('text_wait');
         $this->data['text_tags'] = $this->language->get('text_tags');
         $this->data['text_domestic_freight'] = $this->language->get('text_domestic_freight');
         $this->data['text_origin_of_goods'] = $this->language->get('text_origin_of_goods');
         $this->data['text_colors'] = $this->language->get('text_colors');
         $this->data['text_sizes'] = $this->language->get('text_sizes');
         $this->data['text_goods_note'] = $this->language->get('text_goods_note');
         $this->data['entry_name'] = $this->language->get('entry_name');
         $this->data['entry_review'] = $this->language->get('entry_review');
         $this->data['entry_rating'] = $this->language->get('entry_rating');
         $this->data['entry_good'] = $this->language->get('entry_good');
         $this->data['entry_bad'] = $this->language->get('entry_bad');
         $this->data['entry_captcha'] = $this->language->get('entry_captcha');
         $this->data['button_cart'] = $this->language->get('button_cart');
         $this->data['button_wishlist'] = $this->language->get('button_wishlist');
         $this->data['button_compare'] = $this->language->get('button_compare');
         $this->data['button_upload'] = $this->language->get('button_upload');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->load->model('catalog/review');
         $this->data['tab_description'] = $this->language->get('tab_description');
         $this->data['tab_attribute'] = $this->language->get('tab_attribute');
         $this->data['tab_review'] = sprintf($this->language->get('tab_review'), $product_info['reviews']);
         $this->data['tab_related'] = $this->language->get('tab_related');
         $this->data['product_id'] = $this->request->get['product_id'];
         $this->data['manufacturer'] = $product_info['manufacturer'];
         $this->data['manufacturers'] = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']);
         $this->data['model'] = $product_info['model'];
         $this->data['reward'] = $product_info['reward'];
         $this->data['points'] = $product_info['points'];
         $this->data['hcolor'] = '';
         $this->data['hsize'] = '';
         if ($product_info['quantity'] <= 0) {
             $this->data['stock'] = $product_info['stock_status'];
         } elseif ($this->config->get('config_stock_display')) {
             $this->data['stock'] = $product_info['quantity'];
         } else {
             $this->data['stock'] = $this->language->get('text_instock');
         }
         $this->load->model('tool/image');
         if ($product_info['image']) {
             $this->data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
         } else {
             $this->data['popup'] = '';
         }
         if ($product_info['image']) {
             $this->data['thumb'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
         } else {
             $this->data['thumb'] = '';
         }
         $this->data['images'] = array();
         $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']);
         foreach ($results as $result) {
             $this->data['images'][] = array('popup' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')));
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             // $this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
             $this->data['price'] = $product_info['price'];
         } else {
             $this->data['price'] = false;
         }
         // var_dump($product_info);
         // add by weikun 商品详情页面获取商品的国内运费,商品来源,颜色分类,尺码分类,图片来源
         // 商场名称
         if ($product_info['model']) {
             $this->data['model'] = $product_info['model'];
         } else {
             $this->data['model'] = '';
         }
         // 卖家名称
         if ($product_info['upc']) {
             $this->data['upc'] = $product_info['upc'];
         } else {
             $this->data['upc'] = '';
         }
         // 商品来源
         if ($product_info['mpn']) {
             $this->data['mpn'] = $product_info['mpn'];
         } else {
             $this->data['mpn'] = '';
         }
         if ($product_info['mpnurl']) {
             $this->data['mpnurl'] = $product_info['mpnurl'];
         } else {
             $this->data['mpnurl'] = '';
         }
         // 商品颜色
         if ($product_info['ean']) {
             $ean = explode(',', $product_info['ean']);
             $this->data['ean'] = $ean;
         } else {
             $this->data['ean'] = '';
         }
         // 商品尺寸
         if ($product_info['jan']) {
             $jan = explode(',', $product_info['jan']);
             $this->data['jan'] = $jan;
         } else {
             $this->data['jan'] = '';
         }
         // 国内运费
         if ($product_info['isbn']) {
             $this->data['isbn'] = $product_info['isbn'];
         } else {
             $this->data['isbn'] = '';
         }
         if ($product_info['location']) {
             $site = htmlspecialchars_decode($product_info['location']);
             $result['num_iid'] = 0;
             if (false !== strpos($site, 'taobao.com') || false !== strpos($site, 'tmall.com')) {
                 $url_info = parse_url($site);
                 if (isset($url_info['query'])) {
                     parse_str($url_info['query'], $param);
                     if (!isset($param['id']) && isset($param['tradeID'])) {
                         $param['id'] = $param['tradeID'];
                     }
                     if (!isset($param['id']) && isset($param['meal_id'])) {
                         $param['id'] = $param['meal_id'];
                     }
                     //guanzhiqiang 20150701 从后台取抓取数据,没有则前台抓取,更新api_json至库
                     if (!empty($product_info['api_json'])) {
                         $result = json_decode(str_replace("&quot;", '"', $product_info['api_json']), true);
                     } else {
                         include_once DIR_SYSTEM . 'taobao.class.php';
                         $result = TAOBAO::getItemInfo($param);
                         if (!empty($result)) {
                             $this->db->query("UPDATE " . DB_PREFIX . "product SET api_json='" . $this->db->escape(json_encode($result)) . "', date_modified = NOW() WHERE product_id = '" . (int) $this->request->get['product_id'] . "' LIMIT 1");
                         }
                     }
                     if (is_array($result)) {
                         $result = array_map('strip_tags', $result);
                         $result = array_map('trim', $result);
                     } else {
                         strip_tags($result);
                         trim($result);
                     }
                     $this->result = $result;
                     $result['recommended'] = isset($result['recommended']) ? $result['recommended'] : '';
                     $result['prop_imgs'] = isset($result['prop_imgs']) ? $result['prop_imgs'] : '';
                     $result['item_imgs'] = isset($result['item_imgs']) ? $result['item_imgs'] : '';
                     $result['size_number'] = isset($result['size_number']) ? $result['size_number'] : '';
                     $result['color_number'] = isset($result['color_number']) ? $result['color_number'] : '';
                     $result['price'] = isset($result['price']) ? $result['price'] : '';
                     $result['quantity'] = isset($result['quantity']) ? $result['quantity'] : '';
                     $result['size'] = isset($result['size']) ? $result['size'] : '';
                     $result['color'] = isset($result['color']) ? $result['color'] : '';
                     $result['img_color'] = isset($result['img_color']) ? $result['img_color'] : '';
                     $this->data['recommended'] = json_decode($result['recommended'], true);
                     $this->data['prop_imgs'] = json_decode($result['prop_imgs']);
                     $this->data['item_imgs'] = json_decode($result['item_imgs']);
                     $this->data['size_number'] = json_decode($result['size_number'], true);
                     $this->data['color_number'] = json_decode($result['color_number'], true);
                     $this->session->data['size_color_price'] = json_decode($result['price'], true);
                     $this->session->data['quantity'] = json_decode($result['quantity'], true);
                     // var_dump($this->session->data['size_color_price']);
                     $this->session->data['size_number'] = json_decode($result['size_number'], true);
                     $this->session->data['color_number'] = json_decode($result['color_number'], true);
                     $this->session->data['size'] = $result['size'];
                     $this->session->data['color'] = $result['color'];
                     $this->session->data['img_color'] = json_decode($result['img_color'], true);
                 }
             }
         }
         // end
         if ((double) $product_info['special']) {
             $this->data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $this->data['special'] = false;
         }
         if ($this->config->get('config_tax')) {
             $this->data['tax'] = $this->currency->format((double) $product_info['special'] ? $product_info['special'] : $product_info['price']);
         } else {
             $this->data['tax'] = false;
         }
         $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
         //商品折扣
         $this->data['discounts'] = array();
         foreach ($discounts as $discount) {
             $this->data['discounts'][] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))));
         }
         $this->data['options'] = array();
         /*   $product_options=$this->model_catalog_product->getProductOptions($this->request->get ['product_id']) ;//暂时无用
          
                     foreach ($product_options as $option) {
                         if ($option ['type'] == 'select' || $option ['type'] == 'radio' || $option ['type'] == 'checkbox' || $option ['type'] == 'image') {
                             $option_value_data = array();
         
                             foreach ($option ['option_value'] as $option_value) {
                                 if (!$option_value ['subtract'] || ($option_value ['quantity'] > 0)) {
                                     if ((($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) && (float) $option_value ['price']) {
                                         $price = $this->currency->format($this->tax->calculate($option_value ['price'], $product_info ['tax_class_id'], $this->config->get('config_tax')));
                                     } else {
                                         $price = false;
                                     }
         
                                     $option_value_data [] = array(
                                         'product_option_value_id' => $option_value ['product_option_value_id'],
                                         'option_value_id' => $option_value ['option_value_id'],
                                         'name' => $option_value ['name'],
                                         'image' => $this->model_tool_image->resize($option_value ['image'], 50, 50),
                                         'price' => $price,
                                         'price_prefix' => $option_value ['price_prefix']
                                     );
                                 }
                             }
         
                             $this->data ['options'] [] = array(
                                 'product_option_id' => $option ['product_option_id'],
                                 'option_id' => $option ['option_id'],
                                 'name' => $option ['name'],
                                 'type' => $option ['type'],
                                 'option_value' => $option_value_data,
                                 'required' => $option ['required']
                             );
                         } elseif ($option ['type'] == 'text' || $option ['type'] == 'textarea' || $option ['type'] == 'file' || $option ['type'] == 'date' || $option ['type'] == 'datetime' || $option ['type'] == 'time') {
                             $this->data ['options'] [] = array(
                                 'product_option_id' => $option ['product_option_id'],
                                 'option_id' => $option ['option_id'],
                                 'name' => $option ['name'],
                                 'type' => $option ['type'],
                                 'option_value' => $option ['option_value'],
                                 'required' => $option ['required']
                             );
                         }
                     }*/
         //dump($this->data ['options']);exit;
         if ($product_info['minimum']) {
             $this->data['minimum'] = $product_info['minimum'];
         } else {
             $this->data['minimum'] = 1;
         }
         $this->data['review_status'] = $this->config->get('config_review_status');
         $this->data['reviews'] = sprintf($this->language->get('text_reviews'), (int) $product_info['reviews']);
         $this->data['rating'] = (int) $product_info['rating'];
         $this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
         // $this->data ['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get ['product_id']);//暂时无用 guanzhiqiang 20150626
         $this->data['products'] = array();
         $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
         //产品信息
         //dump($results);
         foreach ($results as $result) {
             if ($result['image']) {
                 $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height'));
             } else {
                 $image = false;
             }
             if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                 $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $price = false;
             }
             if ((double) $result['special']) {
                 $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
             } else {
                 $special = false;
             }
             if ($this->config->get('config_review_status')) {
                 $rating = (int) $result['rating'];
             } else {
                 $rating = false;
             }
             $this->data['products'][] = array('product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']));
         }
         $this->data['tags'] = array();
         if ($product_info['tag']) {
             $tags = explode(',', $product_info['tag']);
             foreach ($tags as $tag) {
                 $this->data['tags'][] = array('tag' => trim($tag), 'href' => $this->url->link('product/search', 'tag=' . trim($tag)));
             }
         }
         $this->data['text_payment_profile'] = $this->language->get('text_payment_profile');
         //   $this->data ['profiles'] = $this->model_catalog_product->getProfiles($product_info ['product_id']); //无数据无用 guanzhiqiang 20150626
         $this->model_catalog_product->updateViewed($this->request->get['product_id']);
         //更新访问量
         $this->data['product_category'] = $this->model_catalog_category->getProductCategory($this->request->get['product_id']);
         //产品分类 guanzhiqiang 20150626
         //大家最爱
         $this->load->model('catalog/product');
         $this->data['love_products'] = $this->model_catalog_product->getLoveProducts(array($this->data['product_category'][0]['parent_id']), 6);
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/details.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/product/details.tpl';
         } else {
             $this->template = 'default/template/product/details.tpl';
         }
         $this->children = array('common/footer', 'common/header_mall');
         $this->response->setOutput($this->render());
     } else {
         $url = '';
         if (isset($this->request->get['path'])) {
             $url .= '&path=' . $this->request->get['path'];
         }
         if (isset($this->request->get['filter'])) {
             $url .= '&filter=' . $this->request->get['filter'];
         }
         if (isset($this->request->get['manufacturer_id'])) {
             $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id'];
         }
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id), 'separator' => $this->language->get('text_separator'));
         $this->document->setTitle($this->language->get('text_error'));
         $this->data['heading_title'] = $this->language->get('text_error');
         $this->data['text_error'] = $this->language->get('text_error');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['continue'] = $this->url->link('common/home');
         $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
         } else {
             $this->template = 'default/template/error/not_found.tpl';
         }
         $this->children = array('common/footer', 'common/header');
         $this->response->setOutput($this->render());
     }
 }
Exemple #3
0
 public function Submit_cart($productId, $customerId)
 {
     $data = array();
     foreach ($productId as $key => $quantity) {
         $product = explode(':', $key);
         $product_id = $product[0];
         if (!empty($product[3])) {
             $note = $product[3];
         } else {
             $note = '';
         }
         if (strlen($product_id) < 8) {
             $stock = true;
             if (!empty($product[1])) {
                 $options = $product[1];
                 $search_color = str_replace("_", ":", $options);
             } else {
                 $options = array();
                 $search_color = '';
             }
             if (!empty($product[2])) {
                 $profile_id = $product[2];
                 $profile_id = $profile_id;
                 $search_size = str_replace("_", ":", $profile_id);
             } else {
                 $profile_id = 0;
                 $search_size = '';
             }
             $product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int) $product_id . "' AND pd.language_id = '" . (int) $this->config->get('config_language_id') . "' AND p.date_available <= NOW() AND p.status = '1'");
             if ($product_query->num_rows) {
                 $option_price = 0;
                 $option_points = 0;
                 $option_weight = 0;
                 $option_data = array();
                 if ($this->customer->isLogged()) {
                     $customer_group_id = $this->customer->getCustomerGroupId();
                 } else {
                     $customer_group_id = $this->config->get('config_customer_group_id');
                 }
                 $price = $product_query->row['price'];
                 // Product Discounts
                 $discount_quantity = 0;
                 foreach ($this->session->data['cart'] as $key_2 => $quantity_2) {
                     $product_2 = explode(':', $key_2);
                     if ($product_2[0] == $product_id) {
                         $discount_quantity += $quantity_2;
                     }
                 }
                 $product_discount_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int) $product_id . "' AND customer_group_id = '" . (int) $customer_group_id . "' AND quantity <= '" . (int) $discount_quantity . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity DESC, priority ASC, price ASC LIMIT 1");
                 if ($product_discount_query->num_rows) {
                     $price = $product_discount_query->row['price'];
                 }
                 // Product Specials
                 $product_special_query = $this->db->query("SELECT price FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int) $product_id . "' AND customer_group_id = '" . (int) $customer_group_id . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY priority ASC, price ASC LIMIT 1");
                 if ($product_special_query->num_rows) {
                     $price = $product_special_query->row['price'];
                 }
                 // Reward Points
                 $product_reward_query = $this->db->query("SELECT points FROM " . DB_PREFIX . "product_reward WHERE product_id = '" . (int) $product_id . "' AND customer_group_id = '" . (int) $customer_group_id . "'");
                 if ($product_reward_query->num_rows) {
                     $reward = $product_reward_query->row['points'];
                 } else {
                     $reward = 0;
                 }
                 // Downloads
                 $download_data = array();
                 $download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_download p2d LEFT JOIN " . DB_PREFIX . "download d ON (p2d.download_id = d.download_id) LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE p2d.product_id = '" . (int) $product_id . "' AND dd.language_id = '" . (int) $this->config->get('config_language_id') . "'");
                 foreach ($download_query->rows as $download) {
                     $download_data[] = array('download_id' => $download['download_id'], 'name' => $download['name'], 'filename' => $download['filename'], 'mask' => $download['mask'], 'remaining' => $download['remaining']);
                 }
                 // Stock
                 if (!$product_query->row['quantity'] || $product_query->row['quantity'] < $quantity) {
                     $stock = false;
                 }
                 $recurring = false;
                 $recurring_frequency = 0;
                 $recurring_price = 0;
                 $recurring_cycle = 0;
                 $recurring_duration = 0;
                 $recurring_trial_status = 0;
                 $recurring_trial_price = 0;
                 $recurring_trial_cycle = 0;
                 $recurring_trial_duration = 0;
                 $recurring_trial_frequency = 0;
                 $profile_name = '';
                 if ($profile_id) {
                     $profile_info = $this->db->query("SELECT * FROM `" . DB_PREFIX . "profile` `p` JOIN `" . DB_PREFIX . "product_profile` `pp` ON `pp`.`profile_id` = `p`.`profile_id` AND `pp`.`product_id` = " . (int) $product_query->row['product_id'] . " JOIN `" . DB_PREFIX . "profile_description` `pd` ON `pd`.`profile_id` = `p`.`profile_id` AND `pd`.`language_id` = " . (int) $this->config->get('config_language_id') . " WHERE `pp`.`profile_id` = " . (int) $profile_id . " AND `status` = 1 AND `pp`.`customer_group_id` = " . (int) $customer_group_id)->row;
                     if ($profile_info) {
                         $profile_name = $profile_info['name'];
                         $recurring = true;
                         $recurring_frequency = $profile_info['frequency'];
                         $recurring_price = $profile_info['price'];
                         $recurring_cycle = $profile_info['cycle'];
                         $recurring_duration = $profile_info['duration'];
                         $recurring_trial_frequency = $profile_info['trial_frequency'];
                         $recurring_trial_status = $profile_info['trial_status'];
                         $recurring_trial_price = $profile_info['trial_price'];
                         $recurring_trial_cycle = $profile_info['trial_cycle'];
                         $recurring_trial_duration = $profile_info['trial_duration'];
                     }
                 }
                 $data[] = array('key' => $key, 'product_id' => $product_query->row['product_id'], 'name' => $product_query->row['name'], 'model' => $product_query->row['model'], 'storename' => $product_query->row['mpn'], 'storeurl' => $product_query->row['mpnurl'], 'yunfei' => $product_query->row['isbn'], 'shipping' => $product_query->row['shipping'], 'image' => $product_query->row['image'], 'location' => $product_query->row['location'], 'source' => 1, 'color' => $search_color, 'size' => $search_size, 'note' => $note, 'option' => $option_data, 'download' => $download_data, 'quantity' => $quantity, 'minimum' => $product_query->row['minimum'], 'subtract' => $product_query->row['subtract'], 'stock' => $stock, 'price' => $price + $option_price, 'total' => ($price + $option_price) * $quantity, 'reward' => $reward * $quantity, 'points' => $product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $quantity : 0, 'tax_class_id' => $product_query->row['tax_class_id'], 'weight' => ($product_query->row['weight'] + $option_weight) * $quantity, 'weight_class_id' => $product_query->row['weight_class_id'], 'length' => $product_query->row['length'], 'width' => $product_query->row['width'], 'height' => $product_query->row['height'], 'length_class_id' => $product_query->row['length_class_id'], 'profile_id' => $profile_id, 'profile_name' => $profile_name, 'recurring' => $recurring, 'recurring_frequency' => $recurring_frequency, 'recurring_price' => $recurring_price, 'recurring_cycle' => $recurring_cycle, 'recurring_duration' => $recurring_duration, 'recurring_trial' => $recurring_trial_status, 'recurring_trial_frequency' => $recurring_trial_frequency, 'recurring_trial_price' => $recurring_trial_price, 'recurring_trial_cycle' => $recurring_trial_cycle, 'recurring_trial_duration' => $recurring_trial_duration);
             }
         } elseif (strlen($product_id) > 8 && strlen($product_id) < 15) {
             //使用key值通过淘宝API接口获取商品详情信息
             $param['id'] = $product_id;
             //颜色
             if (!empty($product[1])) {
                 $search_color = $product[1];
                 $search_color = $search_color;
                 $search_color = str_replace("_", ":", $search_color);
             } else {
                 $search_color = '';
             }
             //var_dump($search_color);
             //尺寸
             if (!empty($product[2])) {
                 $search_size = $product[2];
                 $search_size = $search_size;
                 $search_size = str_replace("_", ":", $search_size);
             } else {
                 $search_size = '';
             }
             //var_dump($search_size);
             include_once DIR_SYSTEM . 'taobao.class.php';
             $searchresult = TAOBAO::getItemInfo($param);
             //var_dump($searchresult);
             $searchresult = array_map('strip_tags', $searchresult);
             $searchresult = array_map('trim', $searchresult);
             $searchresult['size_number'] = json_decode($searchresult['size_number'], true);
             $searchresult['color_number'] = json_decode($searchresult['color_number'], true);
             $image = $searchresult['goodsimg'];
             $size = '';
             if (array_key_exists($search_size, $searchresult['size_number']) && $searchresult['size_number'][$search_size]) {
                 $size = $searchresult['size_number'][$search_size];
                 //var_dump($size);
             }
             $color = '';
             if (array_key_exists($search_color, $searchresult['color_number']) && $searchresult['color_number'][$search_color]) {
                 $color = $searchresult['color_number'][$search_color];
                 //var_dump($color);
             }
             $price = '';
             if ($size && $color) {
                 $price = json_decode($searchresult['price'], true);
                 $pkey = $size . '_' . $color;
                 $searchresult['goodsprice'] = $price[$pkey];
             }
             if ($searchresult['goodsname']) {
                 $data[] = array('key' => $key, 'product_id' => $searchresult['num_iid'], 'name' => $searchresult['goodsname'], 'model' => urldecode($searchresult['model']), 'shipping' => '1', 'image' => $image, 'color' => $color, 'size' => $size, 'note' => $note, 'storename' => $searchresult['storename'], 'storeurl' => $searchresult['storeurl'], 'yunfei' => $searchresult['yunfei'], 'location' => "http://item.taobao.com/item.htm?id=" . $product_id, 'source' => 0, 'option' => array(), 'download' => array(), 'quantity' => $quantity, 'minimum' => '1', 'subtract' => '1', 'stock' => true, 'price' => $searchresult['goodsprice'], 'total' => $searchresult['goodsprice'] * $quantity, 'reward' => 0, 'points' => 0, 'tax_class_id' => '0', 'weight' => (double) 0, 'weight_class_id' => 1, 'length' => '0', 'width' => '0', 'height' => '0', 'length_class_id' => 1, 'profile_id' => 0, 'profile_name' => '0', 'recurring' => false, 'recurring_frequency' => 0, 'recurring_price' => 0, 'recurring_cycle' => 0, 'recurring_duration' => 0, 'recurring_trial' => 0, 'recurring_trial_frequency' => 0, 'recurring_trial_price' => 0, 'recurring_trial_cycle' => 0, 'recurring_trial_duration' => 0);
             } else {
                 $this->remove($key);
             }
         } else {
             $this->remove($key);
         }
     }
     return $data;
 }
Exemple #4
0
 public function getinfo()
 {
     $this->language->load('catalog/product');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('catalog/product');
     $data = array();
     include_once DIR_SYSTEM . 'taobao.class.php';
     if (isset($this->request->post['entry_url'])) {
         $url = trim($this->request->post['entry_url']);
         $site = htmlspecialchars_decode($url);
     }
     //如果该URl地址不是淘宝网和天猫网则返回false
     if (false === strpos($site, 'taobao.com') && false == strpos($site, 'tmall.com')) {
         $data['flag'] = 0;
     }
     //如果该URl地址是淘宝网或者天猫网则调用API接口获取商品详细信息
     $result['num_iid'] = 0;
     if (false !== strpos($site, 'taobao.com') || false !== strpos($site, 'tmall.com')) {
         $data['flag'] = 1;
         if (false !== strpos($site, 'taobao.com')) {
             //商城名
             $data['store_name'] = $this->language->get('entry_tb');
         } else {
             if (false !== strpos($site, 'tmall.com')) {
                 //商城名
                 $data['store_name'] = $this->language->get('entry_tm');
             }
         }
         $url_info = parse_url($site);
         parse_str($url_info['query'], $param);
         if (!$param['id'] && $param['tradeID']) {
             $param['id'] = $param['tradeID'];
         }
         if (!$param['id'] && $param['meal_id']) {
             $param['id'] = $param['meal_id'];
         }
         $result = TAOBAO::getItemInfo($param);
         $data['api_json'] = json_encode($result);
         $result = array_map('strip_tags', $result);
         $result = array_map('trim', $result);
         //淘宝商品id
         //add by fc@cnstorm.com
         $data['num_iid'] = $this->getTBId($site);
         //商品地址
         //modify by fc@cnstorm.com
         $data['good_url'] = 'http://item.taobao.com/item.htm?id=' . $data['num_iid'];
         //商品名称
         $data['good_name'] = $result['goodsname'];
         //商品价格
         $data['good_price'] = $result['goodsprice'];
         //卖家名称
         $data['seller_name'] = $result['goodsseller'];
         //卖家地址
         $data['seller_url'] = $result['sellerurl'];
         //店铺名称
         $data['storename'] = $result['storename'];
         //店铺地址
         $data['store_url'] = $result['storeurl'];
         //商品库存数量
         $data['good_quantity'] = $result['kucun'];
         //商品颜色
         $data['good_color'] = $result['color'];
         //商品尺寸
         $data['good_size'] = $result['size'];
         //商品运费
         $data['good_fee'] = $result['yunfei'];
         //商品图片
         //$data['good_img'] = $result['goodsimg'];
         date_default_timezone_set('PRC');
         //设置中国时区
         $content = file_get_contents($result['goodsimg']);
         $good_img_path = DIR_IMAGE . "data/products/mall/" . date("Ymd") . "/" . date("H") . "/taobao_" . $data['num_iid'] . '.jpg';
         $this->createDir(dirname($good_img_path));
         file_put_contents($good_img_path, $content);
         $this->load->model('tool/image');
         $data['good_img'] = $this->model_tool_image->resize("data/products/mall/" . date("Ymd") . "/" . date("H") . "/taobao_" . $data['num_iid'] . '.jpg', 222, 222);
     }
     $this->response->setOutput(json_encode($data));
 }
Exemple #5
0
 public function index()
 {
     $this->language->load('product/product');
     $url = '';
     $result = array();
     $storename_array = array();
     $this->data['order_zizhu'] = $this->url->link('order/order/order_zizhu', '', 'SSL');
     $this->data['snatch_cul'] = $this->url->link('order/snatch', '', 'SSL');
     if (isset($this->request->post['daigouurl'])) {
         $url = $this->request->post['daigouurl'];
     } else {
         if (isset($this->request->get['search'])) {
             $url = $this->request->get['search'];
         } else {
             $url = "";
         }
     }
     $this->data['url'] = $url;
     $this->load->model('order/order');
     if ($this->customer->getId()) {
         $username_id = $this->customer->getId();
         if (!empty($_COOKIE['taobao_id'])) {
             $taobaoId = $_COOKIE['taobao_id'];
             $arrTaobaoId = explode(',', $taobaoId);
             for ($i = 0; $i < count($arrTaobaoId); $i++) {
                 $sql = 'update ' . DB_PREFIX . 'taobao_product set custom_id=' . $username_id . ' where id= ' . $arrTaobaoId[$i];
                 $this->db->query($sql);
                 //echo $sql.'-';
                 $sql = "update " . DB_PREFIX . "taobao_order set custom_id=" . $username_id . " where id=(select taobao_order_id from " . DB_PREFIX . "taobao_product where id=" . $arrTaobaoId[$i] . ")";
                 $this->db->query($sql);
                 //	echo $sql.'-';
             }
             setcookie('taobao_id', '', -1);
         }
     }
     $total_taobao = $this->model_order_order->get_selfproduct_total();
     $this->data['selfproduct_total'] = $total_taobao;
     $orders = $this->model_order_order->get_selfproduct();
     if ($orders) {
         $this->data['orders'] = $orders;
         foreach ($orders as $order) {
             $storename_array[$order['store_url']] = $order['store_name'];
             $storename_array = array_unique($storename_array);
         }
         $this->data['storenames'] = $storename_array;
     } else {
         $this->data['orders'] = '';
     }
     $this->data['action'] = $this->url->link('order/snatch');
     $this->data['customer_name'] = $this->customer->getFirstname();
     $this->data['api'] = 0;
     $this->data['searchcolor'] = '';
     $this->data['searchsize'] = '';
     if (!empty($url)) {
         $search = htmlspecialchars_decode($url);
         if (preg_match('/[http|https]:\\/\\/[\\w.]+[\\w\\/]*[\\w.]*\\??[\\w=&\\+\\%]*/is', $search)) {
             if (false !== strpos($search, 'taobao.com') || false !== strpos($search, 'tmall.com') || false != strpos($search, 'yao.95095')) {
                 include_once DIR_SYSTEM . 'taobao.class.php';
                 $url_info = parse_url($search);
                 if ($url_info['host'] == 'world.taobao.com') {
                     $productId = substr(strstr($url_info['path'], ".htm", true), 6);
                     $url = 'https://item.taobao.com/item.htm?id=' . $productId;
                     $url_info = parse_url($url);
                 }
                 parse_str($url_info['query'], $param);
                 if (isset($param['id']) && isset($param['tradeID']) && !$param['id'] && $param['tradeID']) {
                     $param['id'] = $param['tradeID'];
                 }
                 if (isset($param['id']) && isset($param['meal_id']) && !$param['id'] && $param['meal_id']) {
                     $param['id'] = $param['meal_id'];
                 }
                 $result = TAOBAO::getItemInfo($param);
                 if ($result) {
                     $result = array_map('strip_tags', $result);
                     $result = array_map('trim', $result);
                 }
                 $search_result = $result;
                 if (isset($search_result['goodsname'])) {
                     $this->document->setTitle($search_result['goodsname']);
                     $this->document->setDescription($search_result['goodsname']);
                     $this->document->setKeywords($search_result['goodsname']);
                     $this->data['heading_title'] = $search_result['goodsname'];
                     $this->data['points'] = '';
                     $this->load->model('tool/image');
                     if ($search_result['goodsprice']) {
                         $this->data['price'] = $search_result['goodsprice'];
                     } else {
                         $this->data['price'] = false;
                     }
                     //add by weikun 商品详情页面获取商品的国内运费,商品来源,颜色分类,尺码分类,图片来源
                     //商品地址
                     if ($search) {
                         $this->data['search'] = $search;
                     } else {
                         $this->data['search'] = '';
                     }
                     //商品主图
                     if ($search_result['goodsimg']) {
                         $this->data['goodsimg'] = $search_result['goodsimg'];
                     } else {
                         $this->data['goodsimg'] = '';
                     }
                     //商场名称
                     if ($search_result['model']) {
                         $this->data['model'] = $search_result['model'];
                     } else {
                         $this->data['model'] = '';
                     }
                     //卖家名称
                     if ($search_result['storename']) {
                         $this->data['storename'] = $search_result['storename'];
                     } else {
                         $this->data['storename'] = '';
                     }
                     //店铺名称
                     if ($search_result['goodsseller']) {
                         $this->data['upc'] = $search_result['goodsseller'];
                     } else {
                         $this->data['upc'] = '';
                     }
                     //店铺地址
                     if ($search_result['storeurl']) {
                         $this->data['storeurl'] = $search_result['storeurl'];
                     } else {
                         $this->data['storeurl'] = '';
                     }
                     //商品颜色
                     $ean_array = json_decode($search_result['color_number'], true);
                     if (count($ean_array)) {
                         foreach ($ean_array as $key => $value) {
                             $ean[] = $value;
                         }
                         $this->data['ean'] = $ean;
                     } else {
                         $this->data['ean'] = '';
                     }
                     //商品尺寸
                     $jan_array = json_decode($search_result['size_number'], true);
                     if (count($jan_array)) {
                         foreach ($jan_array as $key => $value) {
                             $jan[] = $value;
                         }
                         $this->data['jan'] = $jan;
                     } else {
                         $this->data['jan'] = '';
                     }
                     //国内运费
                     if ($search_result['yunfei']) {
                         $this->data['isbn'] = $search_result['yunfei'];
                     } else {
                         $this->data['isbn'] = '';
                     }
                     $this->data['item_imgs'] = json_decode($search_result['item_imgs']);
                     $this->data['size_number'] = json_decode($search_result['size_number'], true);
                     $this->data['color_number'] = json_decode($search_result['color_number'], true);
                     $this->session->data['size_color_price'] = json_decode($search_result['price'], true);
                     $this->session->data['quantity'] = json_decode($result['quantity'], true);
                     $this->session->data['size_number'] = json_decode($search_result['size_number'], true);
                     $this->session->data['color_number'] = json_decode($search_result['color_number'], true);
                     $this->session->data['size'] = $search_result['size'];
                     $this->session->data['color'] = $search_result['color'];
                     $this->session->data['img_color'] = json_decode($search_result['img_color'], true);
                     $this->data['minimum'] = 1;
                     $this->data['num_iid'] = $search_result['num_iid'];
                     $this->data['api'] = 1;
                     $this->template = 'cnstorm/template/order/make_zzg_business.tpl';
                     $this->children = array('common/header_cart', 'common/footer', 'common/uc_business');
                     $this->response->setOutput($this->render());
                 }
             } else {
                 if (false !== strpos($search, '1688.com')) {
                     $result = array();
                     $html = $this->gethtmlcontent($search);
                     $html = iconv('GBK', 'UTF-8', $html);
                     // 商品编号
                     if (preg_match('#1688.com/offer/(.*).html#isU', $search, $matches)) {
                         if (!empty($matches)) {
                             $result['num_iid'] = $matches[1];
                         }
                     }
                     $date = array();
                     // 商品名
                     if (preg_match('#d-title\\">(.*)</h1>#isU', $html, $matches)) {
                         if (!empty($matches[1])) {
                             $date[0] = strip_tags($matches[1]);
                         }
                     }
                     // 图片地址
                     if (preg_match('#vertical-img\\">(.*)<\\/div>#isU', $html, $matches) && preg_match('#<img[^>]*src=\\"(.*)\\"[^>]*>#isU', $matches[1], $src)) {
                         if (!empty($src[1])) {
                             $date[1] = $src[1];
                         }
                     }
                     // 商品价格
                     if (preg_match('#price-original-sku\\">(.*)<\\/div>#isU', $html, $matches) && preg_match_all('#value\\">(.*)<\\/span>#isU', $matches[1], $matches) || preg_match('#price-length-[4-8]\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#\\"n.{10}t\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#<span[^>]*class=\\"price\\">(.*)<\\/span>#isU', $html, $matches)) {
                         if (is_array($matches[1])) {
                             $matches[1] = end($matches[1]);
                         }
                         if (!empty($matches[1])) {
                             if (is_numeric($matches[1])) {
                                 $date[3] = $matches[1];
                             }
                         }
                     }
                     // 商品颜色
                     if (preg_match('#list-leading\\">(.*)<\\/ul>#isU', $html, $matches) && preg_match_all('#text text-single-line\\">(.*)<\\/span>#isU', $matches[1], $matches) || preg_match('#list-leading\\">(.*)<\\/ul>#isU', $html, $matches) && preg_match_all('#<img[^>]*alt="(.*)"[^>]*>#isU', $matches[1], $matches)) {
                         if (!empty($matches[1])) {
                             $date[4] = $matches[1];
                         }
                     }
                     // 商品尺寸
                     if ((preg_match('#table-sku"[^>]*>(.*)<\\/table>#isU', $html, $matches) || preg_match('#full "[^>]*>(.*)<\\/table>#isU', $html, $matches)) && preg_match_all('#<td[^>]*class=\\"name\\"[^>]*>(.*)<\\/td>#isU', $matches[1], $matches) || preg_match_all('#text text-single-line\\">(.*)<\\/span>#isU', $html, $matches)) {
                         foreach ($matches[1] as $v) {
                             if (preg_match('#<img[^>]*alt=\\"(.*)\\"[^>]*>#isU', $v, $matches)) {
                                 if (!empty($matches[1])) {
                                     $date[5][] = $matches[1];
                                 }
                             } else {
                                 $v = strip_tags($v);
                                 if (!empty($v)) {
                                     $date[5][] = $v;
                                 }
                             }
                         }
                     }
                     // 商品运费
                     if (preg_match('#<\\/span><em[^>]*class="value">(.*)<\\/em>#isU', $html, $matches)) {
                         if (!empty($matches[1])) {
                             $date[6] = $matches[1];
                         }
                     }
                     // var_dump($date);
                     if (array_key_exists('0', $date) && $date[0]) {
                         $result['goodsname'] = $date[0];
                     }
                     if (array_key_exists('1', $date) && $date[1]) {
                         $result['goodsimg'] = $date[1];
                     }
                     if (array_key_exists('3', $date) && $date[3]) {
                         $result['goodsprice'] = $date[3];
                     }
                     if (array_key_exists('4', $date) && $date[4]) {
                         $result['ean'] = $date[4];
                     }
                     if (array_key_exists('5', $date) && $date[5]) {
                         $result['jan'] = $date[5];
                     }
                     if (array_key_exists('6', $date) && $date[6]) {
                         $result['yunfei'] = $date['6'];
                     }
                     $result['storename'] = "阿里巴巴";
                     $result['storeurl'] = "http://www.1688.com/";
                     if ($search) {
                         $this->data['search'] = $search;
                     } else {
                         $this->data['search'] = '';
                     }
                     // 商品编号 $result['num_iid']
                     if (isset($result['num_iid']) && $result['num_iid']) {
                         $this->data['num_iid'] = $result['num_iid'];
                     } else {
                         $this->data['num_iid'] = '';
                     }
                     // 商品名字 $result['goodsname']
                     if (isset($result['goodsname']) && $result['goodsname']) {
                         $this->data['heading_title'] = $result['goodsname'];
                     } else {
                         $this->data['heading_title'] = '';
                     }
                     // 商品主图 $result['goodsimg']
                     if (isset($result['goodsimg']) && $result['goodsimg']) {
                         $this->data['goodsimg'] = $result['goodsimg'];
                     } else {
                         $this->data['goodsimg'] = '';
                     }
                     // 商品价格 $result['price']
                     if (isset($result['goodsprice'])) {
                         $this->data['price'] = $result['goodsprice'];
                     } else {
                         $this->data['price'] = '';
                     }
                     // 颜色分类 $result['ean']
                     if (isset($result['ean']) && $result['ean']) {
                         $this->data['ean'] = $result['ean'];
                     } else {
                         $this->data['ean'] = '';
                     }
                     // 尺码大小 $result['jan']
                     if (isset($result['jan']) && $result['jan']) {
                         $this->data['jan'] = $result['jan'];
                     } else {
                         $this->data['jan'] = '';
                     }
                     // 店铺名称
                     if (isset($result['storename']) && $result['storename']) {
                         $this->data['storename'] = $result['storename'];
                     } else {
                         $this->data['storename'] = '';
                     }
                     // 店铺地址
                     if (isset($result['storeurl']) && $result['storeurl']) {
                         $this->data['storeurl'] = $result['storeurl'];
                     } else {
                         $this->data['storeurl'] = '';
                     }
                     // 国内运费
                     if (isset($result['yunfei'])) {
                         $this->data['isbn'] = $result['yunfei'];
                     } else {
                         $this->data['isbn'] = '';
                     }
                     $this->template = 'cnstorm/template/order/make_zzg_business.tpl';
                     $this->children = array('common/header_cart', 'common/footer', 'common/uc_business');
                     $this->response->setOutput($this->render());
                 } else {
                     if (false !== strpos($search, 'dangdang.com')) {
                         $result = array();
                         $html = $this->gethtmlcontent($search);
                         $html = mb_convert_encoding($html, 'UTF-8', 'gbk');
                         // 商品编号
                         if (preg_match('#dangdang.com/(.*).html#isU', $search, $matches)) {
                             // var_dump($matches);
                             if (!empty($matches)) {
                                 $result['num_iid'] = $matches[1];
                             }
                         }
                         // 商品名称
                         if (preg_match('#<h1>(.*)<span#iU', $html, $matches)) {
                             if (!empty($matches)) {
                                 $result['goodsname'] = strip_tags($matches[1]);
                             }
                         }
                         // 商品价格
                         if (preg_match('#<span id=[\\"|\']promo_price[\\"|\']>(.*)</span>#isU', $html, $matches)) {
                             //var_dump ( $matches );
                             if (!empty($matches)) {
                                 $result['goodsprice'] = $matches[1];
                                 $result['goodsprice'] = trim($result['goodsprice'], '&yen;');
                             }
                         } elseif (preg_match('#<span id=[\\"|\']salePriceTag[\\"|\']>(.*)</span>#isU', $html, $matches)) {
                             if (!empty($matches)) {
                                 $result['goodsprice'] = $matches[1];
                             }
                         }
                         // 商品主图
                         if (preg_match('#wsrc=[\\"|\'](.*)[\\"|\']#isU', $html, $matches)) {
                             // var_dump($matches);
                             if (!empty($matches)) {
                                 $result['goodsimg'] = $matches[1];
                             }
                         }
                         // 商品颜色
                         if (preg_match('#<ul class=[\\"|\']color[\\"|\']>(.*)</ul>#isU', $html, $matches)) {
                             if (preg_match_all('#title=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                 if (!empty($matches)) {
                                     $result['ean'] = $matches[1];
                                 }
                             }
                         }
                         // 商品尺寸规格
                         if (preg_match('#<ul class=[\\"|\']size[\\"|\']>(.*)</ul>#isU', $html, $matches)) {
                             if (preg_match_all('#<a[^>]+>(.*)</a>#isU', $matches[1], $matches)) {
                                 if (!empty($matches)) {
                                     $result['jan'] = $matches[1];
                                     unset($result['jan'][array_search("尺码对照表", $result['jan'])]);
                                 }
                             }
                         }
                         // $result['yunfei'] = 0.00;
                         $result['storename'] = "当当网";
                         $result['storeurl'] = "http://www.dangdang.com/";
                         if ($search) {
                             $this->data['search'] = $search;
                         } else {
                             $this->data['search'] = '';
                         }
                         // 商品编号 $result['num_iid']
                         if (isset($result['num_iid']) && $result['num_iid']) {
                             $this->data['num_iid'] = $result['num_iid'];
                         } else {
                             $this->data['num_iid'] = '';
                         }
                         // 商品名字 $result['goodsname']
                         if (isset($result['goodsname']) && $result['goodsname']) {
                             $this->data['heading_title'] = $result['goodsname'];
                         } else {
                             $this->data['heading_title'] = '';
                         }
                         // 商品主图 $result['goodsimg']
                         if (isset($result['goodsimg']) && $result['goodsimg']) {
                             $this->data['goodsimg'] = $result['goodsimg'];
                         } else {
                             $this->data['goodsimg'] = '';
                         }
                         // 商品价格 $result['price']
                         if (isset($result['goodsprice'])) {
                             $this->data['price'] = $result['goodsprice'];
                         } else {
                             $this->data['price'] = '';
                         }
                         // 颜色分类 $result['ean']
                         if (isset($result['ean']) && $result['ean']) {
                             $this->data['ean'] = $result['ean'];
                         } else {
                             $this->data['ean'] = '';
                         }
                         // 尺码大小 $result['jan']
                         if (isset($result['jan']) && $result['jan']) {
                             $this->data['jan'] = $result['jan'];
                         } else {
                             $this->data['jan'] = '';
                         }
                         // 店铺名称
                         if (isset($result['storename']) && $result['storename']) {
                             $this->data['storename'] = $result['storename'];
                         } else {
                             $this->data['storename'] = '';
                         }
                         // 店铺地址
                         if (isset($result['storeurl']) && $result['storeurl']) {
                             $this->data['storeurl'] = $result['storeurl'];
                         } else {
                             $this->data['storeurl'] = '';
                         }
                         // 国内运费
                         if (isset($result['yunfei'])) {
                             $this->data['isbn'] = $result['yunfei'];
                         } else {
                             $this->data['isbn'] = '';
                         }
                         $this->template = 'cnstorm/template/order/make_zzg_business.tpl';
                         $this->children = array('common/header_cart', 'common/footer', 'common/uc_business');
                         $this->response->setOutput($this->render());
                     } else {
                         if (false !== strpos($search, 'amazon.cn')) {
                             $result = array();
                             $html = $this->gethtmlcontent($search);
                             // 商品名
                             if (preg_match('#a-size-large\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#parseasinTitle\\">(.*)<\\/h1>#isU', $html, $matches)) {
                                 $matches[0] = strip_tags($matches[1]);
                                 if (!empty($matches[1])) {
                                     $date[0] = strip_tags($matches[1]);
                                 }
                             }
                             // 图片地址
                             if (preg_match('#<div id=[\\"|\']kib-ma-container-0[\\"|\'][^>]+>(.*)</div>#isU', $html, $matches)) {
                                 if (preg_match('#src=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                     if (!empty($matches)) {
                                         $result['goodsimg'] = $matches[1];
                                     }
                                 }
                             } else {
                                 if (preg_match('#<tr id=[\\"|\']prodImageContainer[\\"|\']>(.*)</tr>#isU', $html, $matches)) {
                                     if (preg_match('#src=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                         if (!empty($matches)) {
                                             $result['goodsimg'] = $matches[1];
                                         }
                                     }
                                 } else {
                                     if (preg_match('#<div class=[\\"|\']main-image-inner-wrapper[\\"|\']>(.*)</div>#isU', $html, $matches)) {
                                         if (preg_match('#src=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['goodsimg'] = $matches[1];
                                             }
                                         }
                                     } else {
                                         if (preg_match('#<div id=[\\"|\']imgTagWrapperId[\\"|\'] class=[\\"|\']imgTagWrapper[\\"|\']>(.*)</div>#isU', $html, $matches)) {
                                             if (preg_match('#data-a-dynamic-image=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                                 if (preg_match('#http(.*)jpg#isU', $matches[1], $matches)) {
                                                     if (!empty($matches[1])) {
                                                         $result['goodsimg'] = 'http' . $matches[1] . 'jpg';
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                             // 商品价格
                             if (preg_match('#id=\\"priceblock_ourprice\\"[^>]*>(.*)<\\/span>#isU', $html, $matches) || preg_match('#priceLarge\\"[^>]*>(.*)<\\/b>#isU', $html, $matches) || preg_match('#id=\\"listPriceValue\\"[^>]*>(.*)<\\/span>#isU', $html, $matches) || preg_match('#a-size-medium a-color-price offer-price a-text-normal\\"[^>]*>(.*)<\\/span>#isU', $html, $matches) || preg_match('#id=\\"priceblock_saleprice\\"[^>]*>(.*)<\\/span>#isU', $html, $matches)) {
                                 if (!empty($matches[1])) {
                                     $matches[1] = str_replace('¥', '', $matches[1]);
                                     $matches[1] = is_array($matches[1] = explode('-', $matches[1])) ? trim(end($matches[1]), ' ') : $matches[1];
                                     $date[3] = $matches[1];
                                 }
                             }
                             if (preg_match('#priceLarge kitsunePrice\\"[^>]*>(.*)<\\/b>#isU', $html, $matches)) {
                                 $matches[1] = str_replace('¥', '', $matches[1]);
                                 $matches[1] = is_array($matches[1] = explode('-', $matches[1])) ? trim(end($matches[1]), ' ') : $matches[1];
                                 $date[3] = $matches[1];
                             }
                             // 商品颜色
                             if (preg_match_all('#<li id=\\"color_name_[0-9]*\\"[^>]*>(.*)<\\/li>#isU', $html, $matches) || preg_match_all('#<div id=\\"variation_color_name*\\"[^>]*>(.*)<\\/div>#isU', $html, $matches)) {
                                 foreach ($matches[1] as $v) {
                                     if (preg_match('#<img[^>]*alt=\\"(.*)\\"[^>]*>#isU', $v, $matches) || preg_match('#selection\\">(.*)<\\/span>#isU', $html, $matches)) {
                                         if (!empty($matches[1])) {
                                             $date[4][] = $matches[1];
                                         }
                                     }
                                 }
                             }
                             // 商品规格
                             if (preg_match_all('#<div class=[\\"|\']swatchInnerText[\\"|\'][^>]+>(.*)</div>#isU', $html, $matches) || preg_match('#native_dropdown_selected_size_name\\"[^>]*>(.*)<\\/select>#isU', $html, $matches) && preg_match_all('#<option[^>]*>(.*)<\\/option>#isU', $matches[1], $matches) || preg_match_all('#<li id=\\"size_name_[0-9]*\\"[^>]*>(.*)<\\/li>#isU', $html, $matches) || preg_match('#a-spacing-top-micro swatches swatchesSquare\\">(.*)<\\/ul>#isU', $html, $matches) && preg_match_all('#<li[^>]*>(.*)<\\/li>#isU', $matches[1], $matches)) {
                                 if (!is_array($matches[1])) {
                                     $date[5] = $matches[1];
                                 } else {
                                     if (array_search("选择", $matches[1], true) !== null) {
                                         unset($matches[1][array_search("选择", $matches[1])]);
                                     }
                                     foreach ($matches[1] as $v) {
                                         if (preg_match('#text\\">(.*)<\\/div>#isU', $v, $matches)) {
                                             if (!empty($matches[1])) {
                                                 $matches[1] = strip_tags($v);
                                                 $date[5][] = $matches[1];
                                             }
                                         } else {
                                             if (!empty($v)) {
                                                 $matches[1] = strip_tags($v);
                                                 $date[5][] = $matches[1];
                                             }
                                         }
                                     }
                                 }
                             }
                             // 商品运费
                             if (preg_match('#ddmMerchantMessage\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#a-size-base a-color-base\\">(.*)<\\/span>#isU', $html, $matches)) {
                                 $matches[1] = strip_tags($matches[1]);
                                 if (is_numeric($matches[1])) {
                                     if (!empty($matches[1])) {
                                         $date[6] = $matches[1];
                                     }
                                 }
                             }
                             // var_dump ( $date );
                             if (array_key_exists('0', $date) && $date[0]) {
                                 $result['goodsname'] = $date[0];
                             }
                             if (array_key_exists('3', $date) && $date[3]) {
                                 $result['goodsprice'] = $date[3];
                             }
                             if (array_key_exists('4', $date) && $date[4]) {
                                 $result['ean'] = $date[4];
                             }
                             if (array_key_exists('5', $date) && $date[5]) {
                                 // unset( $date[5][array_search (" ", $date [5] )] );
                                 //var_dump ( $date [5] );
                                 $result['jan'] = array_filter($date[5]);
                                 //var_dump ( $date [5] );
                             }
                             if (array_key_exists('6', $date) && $date[6]) {
                                 $result['yunfei'] = $date['6'];
                             }
                             $result['storename'] = "亚马逊";
                             $result['storeurl'] = "http://www.amazon.cn/";
                             if ($search) {
                                 $this->data['search'] = $search;
                             } else {
                                 $this->data['search'] = '';
                             }
                             // 商品编号 $result['num_iid']
                             if (isset($result['num_iid']) && $result['num_iid']) {
                                 $this->data['num_iid'] = $result['num_iid'];
                             } else {
                                 $this->data['num_iid'] = '';
                             }
                             // 商品名字 $result['goodsname']
                             if (isset($result['goodsname']) && $result['goodsname']) {
                                 $this->data['heading_title'] = $result['goodsname'];
                             } else {
                                 $this->data['heading_title'] = '';
                             }
                             // 商品主图 $result['goodsimg']
                             if (isset($result['goodsimg']) && $result['goodsimg']) {
                                 $this->data['goodsimg'] = $result['goodsimg'];
                             } else {
                                 $this->data['goodsimg'] = '';
                             }
                             // 商品价格 $result['price']
                             if (isset($result['goodsprice'])) {
                                 $this->data['price'] = $result['goodsprice'];
                             } else {
                                 $this->data['price'] = '';
                             }
                             // 颜色分类 $result['ean']
                             if (isset($result['ean']) && $result['ean']) {
                                 $this->data['ean'] = $result['ean'];
                             } else {
                                 $this->data['ean'] = '';
                             }
                             // 尺码大小 $result['jan']
                             if (isset($result['jan']) && $result['jan']) {
                                 $this->data['jan'] = $result['jan'];
                             } else {
                                 $this->data['jan'] = '';
                             }
                             // 店铺名称
                             if (isset($result['storename']) && $result['storename']) {
                                 $this->data['storename'] = $result['storename'];
                             } else {
                                 $this->data['storename'] = '';
                             }
                             // 店铺地址
                             if (isset($result['storeurl']) && $result['storeurl']) {
                                 $this->data['storeurl'] = $result['storeurl'];
                             } else {
                                 $this->data['storeurl'] = '';
                             }
                             // 国内运费
                             if (isset($result['yunfei'])) {
                                 $this->data['isbn'] = $result['yunfei'];
                             } else {
                                 $this->data['isbn'] = 0.0;
                             }
                             $this->template = 'cnstorm/template/order/make_zzg_business.tpl';
                             $this->children = array('common/header_cart', 'common/footer', 'common/uc_business');
                             $this->response->setOutput($this->render());
                         } else {
                             if (false !== strpos($search, 'jd.com')) {
                                 $result = array();
                                 $html = $this->gethtmlcontent($search);
                                 $html = mb_convert_encoding($html, 'UTF-8', 'gb2312');
                                 // 商品编号
                                 if (preg_match('#jd.com/(.*).html#isU', $search, $matches)) {
                                     // var_dump($matches);
                                     if (!empty($matches)) {
                                         $result['num_iid'] = $matches[1];
                                     }
                                 }
                                 // 商品名称
                                 if (preg_match('#<h1>(.*)</h1>#isU', $html, $matches)) {
                                     if (!empty($matches)) {
                                         $result['goodsname'] = strip_tags($matches[1]);
                                     }
                                 }
                                 // 商品价格
                                 if (isset($result['num_iid']) && $result['num_iid']) {
                                     $price_url = 'http://p.3.cn/prices/get?skuid=J_' . $result['num_iid'];
                                     $price_html = $this->gethtmlcontent($price_url);
                                     $p_price = explode(',', $price_html);
                                     $price = explode(':', $p_price[1]);
                                     $price = trim($price[1], '"');
                                     $result['goodsprice'] = trim($price, '"');
                                 }
                                 // 商品主图
                                 if (preg_match('#jqimg=[\\"|\'](.*)[\\"|\']#isU', $html, $matches)) {
                                     // var_dump($matches);
                                     if (!empty($matches)) {
                                         $result['goodsimg'] = $matches[1];
                                     }
                                 } elseif (preg_match('#<img width=[\\"|\']350[\\"|\'] height=[\\"|\']350[\\"|\']  data-img=[\\"|\']1[\\"|\'] src=[\\"|\'](.*)[\\"|\'] alt=[\\"|\'](.*)[\\"|\']>#isU', $html, $matches)) {
                                     if (!empty($matches)) {
                                         $result['goodsimg'] = $matches[1];
                                     }
                                 }
                                 // 商品颜色
                                 if (preg_match('#<li id=[\\"|\']choose-color[\\"|\'] class=[\\"|\']choose-color-shouji[\\"|\']>(.*)</li>#isU', $html, $matches)) {
                                     if (preg_match_all('#<i>(.*)</i>#isU', $matches[1], $matches)) {
                                         if (!empty($matches)) {
                                             $result['ean'] = $matches[1];
                                         }
                                     }
                                 }
                                 // 商品尺寸规格
                                 if (preg_match('#<li id=[\\"|\']choose-version[\\"|\']>(.*)</li>#isU', $html, $matches)) {
                                     if (preg_match_all('#<a[^>]+>(.*)</a>#isU', $matches[1], $matches)) {
                                         if (!empty($matches)) {
                                             $result['jan'] = $matches[1];
                                         }
                                     }
                                 }
                                 $result['yunfei'] = 0.0;
                                 $result['storename'] = "京东商城";
                                 $result['storeurl'] = "http://www.jd.com/";
                                 if ($search) {
                                     $this->data['search'] = $search;
                                 } else {
                                     $this->data['search'] = '';
                                 }
                                 // 商品编号 $result['num_iid']
                                 if (isset($result['num_iid']) && $result['num_iid']) {
                                     $this->data['num_iid'] = $result['num_iid'];
                                 } else {
                                     $this->data['num_iid'] = '';
                                 }
                                 // 商品名字 $result['goodsname']
                                 if (isset($result['goodsname']) && $result['goodsname']) {
                                     $this->data['heading_title'] = $result['goodsname'];
                                 } else {
                                     $this->data['heading_title'] = '';
                                 }
                                 // 商品主图 $result['goodsimg']
                                 if (isset($result['goodsimg']) && $result['goodsimg']) {
                                     $this->data['goodsimg'] = $result['goodsimg'];
                                 } else {
                                     $this->data['goodsimg'] = '';
                                 }
                                 // 商品价格 $result['price']
                                 if (isset($result['goodsprice'])) {
                                     $this->data['price'] = $result['goodsprice'];
                                 } else {
                                     $this->data['price'] = '';
                                 }
                                 // 颜色分类 $result['ean']
                                 if (isset($result['ean']) && $result['ean']) {
                                     $this->data['ean'] = $result['ean'];
                                 } else {
                                     $this->data['ean'] = '';
                                 }
                                 // 尺码大小 $result['jan']
                                 if (isset($result['jan']) && $result['jan']) {
                                     $this->data['jan'] = $result['jan'];
                                 } else {
                                     $this->data['jan'] = '';
                                 }
                                 // 店铺名称
                                 if (isset($result['storename']) && $result['storename']) {
                                     $this->data['storename'] = $result['storename'];
                                 } else {
                                     $this->data['storename'] = '';
                                 }
                                 // 店铺地址
                                 if (isset($result['storeurl']) && $result['storeurl']) {
                                     $this->data['storeurl'] = $result['storeurl'];
                                 } else {
                                     $this->data['storeurl'] = '';
                                 }
                                 // 国内运费
                                 if (isset($result['yunfei'])) {
                                     $this->data['isbn'] = $result['yunfei'];
                                 } else {
                                     $this->data['isbn'] = '';
                                 }
                                 $this->template = 'cnstorm/template/order/make_zzg_business.tpl';
                                 $this->children = array('common/header_cart', 'common/footer', 'common/uc_business');
                                 $this->response->setOutput($this->render());
                             } else {
                                 $this->document->setTitle($this->language->get('text_error'));
                                 $this->data['heading_title'] = $this->language->get('text_error');
                                 $this->data['text_error'] = $this->language->get('text_error');
                                 $this->data['button_continue'] = $this->language->get('button_continue');
                                 $this->data['continue'] = $this->url->link('common/home');
                                 $this->response->addHeader($this->request->server['SERVER_PROTOCOL'] . '/1.1 404 Not Found');
                                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/snatch_noresults.tpl')) {
                                     $this->template = $this->config->get('config_template') . '/template/error/snatch_noresults.tpl';
                                 } else {
                                     $this->template = 'cnstorm/template/error/snatch_noresults.tpl';
                                 }
                                 $this->children = array('common/column_left', 'common/footer', 'common/header');
                                 $this->response->setOutput($this->render());
                                 $this->redirect($this->url->link('order/snatch', '', 'SSL'));
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $this->template = 'cnstorm/template/order/make_zzg_business.tpl';
         $this->children = array('common/header_cart', 'common/footer', 'common/uc_business');
         $this->response->setOutput($this->render());
     }
 }
 public function iteminfo()
 {
     error_reporting(E_ALL);
     ini_set('display_errors', 'On');
     $this->load->model('order/order');
     $total_taobao = $this->model_order_order->get_selfproduct_total();
     $this->data['selfproduct_total'] = $total_taobao;
     $orders = $this->model_order_order->get_selfproduct();
     if ($orders) {
         $this->data['orders'] = $orders;
         foreach ($orders as $order) {
             $storename_array[$order['store_url']] = $order['store_name'];
             $storename_array = array_unique($storename_array);
         }
         $this->data['storenames'] = $storename_array;
     } else {
         $this->data['orders'] = '';
     }
     $this->language->load('product/product');
     $url = '';
     $result = array();
     if (isset($this->request->get['search'])) {
         $url = $this->request->get['search'];
     }
     //插件抓取商品
     //add by fc
     $flag = false;
     if (isset($this->request->post['url'])) {
         $url = $this->request->post['url'];
         $flag = true;
     }
     //end
     $search = urldecode($url);
     $search = htmlspecialchars_decode($url);
     $this->data['searchcolor'] = '';
     $this->data['searchsize'] = '';
     $this->data['colorname'] = '';
     $this->data['sizename'] = '';
     $this->data['api'] = 0;
     if (false !== strpos($search, 'taobao.com') || false !== strpos($search, 'tmall.com') || false != strpos($search, 'yao.95095')) {
         include_once DIR_SYSTEM . 'taobao.class.php';
         $url_info = parse_url($search);
         if ($url_info['host'] == 'world.taobao.com') {
             $productId = substr(strstr($url_info['path'], ".htm", true), 6);
             $url = 'https://item.taobao.com/item.htm?id=' . $productId;
             $url_info = parse_url($url);
         }
         $url_info['query'] = isset($url_info['query']) ? $url_info['query'] : '';
         $param['id'] = '';
         $url_info['query'] = str_replace('&amp;', '&', $url_info['query']);
         parse_str($url_info['query'], $param);
         if (!isset($param['id']) && isset($param['tradeID'])) {
             $param['id'] = $param['tradeID'];
         }
         if (!isset($param['id']) && isset($param['meal_id'])) {
             $param['id'] = $param['meal_id'];
         }
         $result = TAOBAO::getItemInfo($param);
         $customer_id = $this->customer->getId();
         if ($result) {
             $result = array_map('strip_tags', $result);
             $result = array_map('trim', $result);
         }
         $this->load->model('catalog/product');
         $search_result = $result;
         if (isset($search_result['goodsname'])) {
             $this->data['title'] = $search_result['goodsname'];
             $this->data['keywords'] = $search_result['goodsname'];
             $this->data['description'] = $search_result['goodsname'];
             $this->data['heading_title'] = $search_result['goodsname'];
             $this->data['points'] = '';
             $this->load->model('tool/image');
             if ($search_result['goodsprice']) {
                 $this->data['price'] = $search_result['goodsprice'];
             } else {
                 $this->data['price'] = false;
             }
             // add by weikun 商品详情页面获取商品的国内运费,商品来源,颜色分类,尺码分类,图片来源
             // 商品地址
             if ($search) {
                 $this->data['search'] = $search;
             } else {
                 $this->data['search'] = '';
             }
             // 商品主图
             if ($search_result['goodsimg']) {
                 $this->data['goodsimg'] = $search_result['goodsimg'];
             } else {
                 $this->data['goodsimg'] = '';
             }
             // 商场名称
             if ($search_result['model']) {
                 $this->data['model'] = $search_result['model'];
             } else {
                 $this->data['model'] = '';
             }
             // 店铺名称
             if ($search_result['storename']) {
                 $this->data['storename'] = $search_result['storename'];
             } else {
                 $this->data['storename'] = '';
             }
             // 店铺地址
             if ($search_result['storeurl']) {
                 $this->data['storeurl'] = $search_result['storeurl'];
             } else {
                 $this->data['storeurl'] = '';
             }
             // 卖家名称
             if ($search_result['goodsseller']) {
                 $this->data['upc'] = $search_result['goodsseller'];
             } else {
                 $this->data['upc'] = '';
             }
             // 商品颜色
             $ean_array = json_decode($search_result['color_number'], true);
             if (count($ean_array)) {
                 foreach ($ean_array as $key => $value) {
                     $ean[] = $value;
                 }
                 $this->data['ean'] = $ean;
             } else {
                 $this->data['ean'] = '';
             }
             // 商品尺寸
             $jan_array = json_decode($search_result['size_number'], true);
             if (count($jan_array)) {
                 foreach ($jan_array as $key => $value) {
                     $jan[] = $value;
                 }
                 $this->data['jan'] = $jan;
             } else {
                 $this->data['jan'] = '';
             }
             // 国内运费
             if ($search_result['yunfei']) {
                 $this->data['isbn'] = $search_result['yunfei'];
             } else {
                 $this->data['isbn'] = 0.0;
             }
             $this->data['item_imgs'] = json_decode($search_result['item_imgs']);
             $this->data['size_number'] = json_decode($search_result['size_number'], true);
             $this->data['color_number'] = json_decode($search_result['color_number'], true);
             $this->session->data['size_color_price'] = json_decode($search_result['price'], true);
             $this->session->data['quantity'] = json_decode($result['quantity'], true);
             $this->session->data['size_number'] = json_decode($search_result['size_number'], true);
             $this->session->data['color_number'] = json_decode($search_result['color_number'], true);
             $this->session->data['size'] = $search_result['size'];
             $this->session->data['color'] = $search_result['color'];
             $this->session->data['img_color'] = json_decode($search_result['img_color'], true);
             $this->data['minimum'] = 1;
             $this->data['num_iid'] = $search_result['num_iid'];
         }
         $this->data['api'] = 1;
         if ($flag) {
             $this->data['prifex'] = 'TB';
             $this->data['search'] = isset($this->data['num_iid']) ? 'http://item.taobao.com/item.htm?id=' . $this->data['num_iid'] : '';
             $this->data['property'] = array();
             if ($this->data['jan']) {
                 $this->data['property']['尺码'] = isset($this->data['jan']) ? $this->data['jan'] : '';
             }
             if ($this->data['ean']) {
                 $this->data['property']['颜色分类'] = isset($this->data['ean']) ? $this->data['ean'] : '';
             }
             $this->data['promotion_in_item'] = $this->session->data['size_color_price'];
             if (isset($this->data['jan']) && is_array($this->data['jan']) || isset($this->data['ean'])) {
                 $not_quantity = '';
                 foreach ($this->data['jan'] as $size) {
                     foreach ($this->data['ean'] as $color) {
                         if (!in_array($size . '_' . $color, array_keys($this->session->data['quantity']))) {
                             $not_quantity = $not_quantity . $size . $color . ',';
                         }
                     }
                 }
                 if ($not_quantity != '') {
                     // $not_quantity = substr($not_quantity, 0, strlen($not_quantity) - 1);
                     $this->data['not_quantity'] = explode(',', $not_quantity);
                 }
             }
             echo json_encode($this->data);
         } else {
             // var_dump($this->data);
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                 $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
             } else {
                 $this->template = 'default/template/product/zzg_snatch_info.tpl';
             }
             $this->response->setOutput($this->render());
         }
     } else {
         if (false !== strpos($search, '1688.com')) {
             $result = array();
             $html = $this->gethtmlcontent($search);
             $html = iconv('GBK', 'UTF-8', $html);
             // 商品编号
             if (preg_match('#1688.com/offer/(.*).html#isU', $search, $matches)) {
                 if (!empty($matches)) {
                     $result['num_iid'] = $matches[1];
                 }
             }
             // 商品名
             if (preg_match('#d-title\\">(.*)</h1>#isU', $html, $matches)) {
                 if (!empty($matches[1])) {
                     $date[0] = strip_tags($matches[1]);
                 }
             }
             // 图片地址
             if (preg_match('#vertical-img\\">(.*)<\\/div>#isU', $html, $matches) && preg_match('#<img[^>]*src=\\"(.*)\\"[^>]*>#isU', $matches[1], $src)) {
                 if (!empty($src[1])) {
                     $date[1] = $src[1];
                 }
             }
             // 商品价格
             if (preg_match('#price-original-sku\\">(.*)<\\/div>#isU', $html, $matches) && preg_match_all('#value\\">(.*)<\\/span>#isU', $matches[1], $matches) || preg_match('#price-length-[4-8]\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#\\"n.{10}t\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#<span[^>]*class=\\"price\\">(.*)<\\/span>#isU', $html, $matches)) {
                 if (is_array($matches[1])) {
                     $matches[1] = end($matches[1]);
                 }
                 if (!empty($matches[1])) {
                     if (is_numeric($matches[1])) {
                         $date[3] = $matches[1];
                     }
                 }
             }
             // 商品颜色
             if (preg_match('#list-leading\\">(.*)<\\/ul>#isU', $html, $matches) && preg_match_all('#text text-single-line\\">(.*)<\\/span>#isU', $matches[1], $matches) || preg_match('#list-leading\\">(.*)<\\/ul>#isU', $html, $matches) && preg_match_all('#<img[^>]*alt="(.*)"[^>]*>#isU', $matches[1], $matches) || preg_match_all('#unit-detail-spec-operator\\"[\\s]*data-unit-config=\'\\{\\"name\\":\\"(.*)\\"\\}\'#isU', $html, $matches)) {
                 if (!empty($matches[1])) {
                     $date[4] = $matches[1];
                 }
             }
             // 商品尺寸
             if ((preg_match('#table-sku"[^>]*>(.*)<\\/table>#isU', $html, $matches) || preg_match('#full "[^>]*>(.*)<\\/table>#isU', $html, $matches)) && preg_match_all('#<td[^>]*class=\\"name\\"[^>]*>(.*)<\\/td>#isU', $matches[1], $matches) || preg_match_all('#text text-single-line\\">(.*)<\\/span>#isU', $html, $matches) || preg_match_all('#tr[\\s]*.*data-sku-config=\'\\{\\"skuName":\\"(.*)\\"#isU', $html, $matches)) {
                 foreach ($matches[1] as $v) {
                     if (preg_match('#<img[^>]*alt=\\"(.*)\\"[^>]*>#isU', $v, $matches)) {
                         if (!empty($matches[1])) {
                             $date[5][] = $matches[1];
                         }
                     } else {
                         $v = strip_tags($v);
                         if (!empty($v)) {
                             $date[5][] = $v;
                         }
                     }
                 }
             }
             // 商品运费
             if (preg_match('#<\\/span><em[^>]*class="value">(.*)<\\/em>#isU', $html, $matches)) {
                 if (!empty($matches[1])) {
                     $date[6] = $matches[1];
                 }
             }
             // 商铺名称
             if (preg_match('#<a[^>]*class="has-tips"[^>]*href="(.*)"[^>]*><span class="info">(.*)<\\/span><\\/a>#isU', $html, $matches)) {
                 if (!empty($matches[1])) {
                     $pos = strpos($matches[1], '.');
                     $str = substr($matches[1], 0, $pos);
                     //var_dump ( $str );
                     $date[8] = $str . '.1688.com';
                 }
                 if (!empty($matches[2])) {
                     $date[7] = $matches[2];
                 }
             }
             if (isset($date)) {
                 if (array_key_exists('0', $date) && $date[0]) {
                     $result['goodsname'] = $date[0];
                 }
                 if (array_key_exists('1', $date) && $date[1]) {
                     $result['goodsimg'] = $date[1];
                 }
                 if (array_key_exists('3', $date) && $date[3]) {
                     $result['goodsprice'] = $date[3];
                 }
                 if (array_key_exists('4', $date) && $date[4]) {
                     $result['ean'] = $date[4];
                 }
                 if (array_key_exists('5', $date) && $date[5]) {
                     $result['jan'] = $date[5];
                 }
                 if (array_key_exists('6', $date) && $date[6]) {
                     $result['yunfei'] = $date['6'];
                 }
                 if (array_key_exists('7', $date) && $date[7]) {
                     $result['storename'] = $date['7'];
                 }
                 if (array_key_exists('8', $date) && $date[8]) {
                     $result['storeurl'] = $date['8'];
                 }
             }
             if ($search) {
                 $this->data['search'] = $search;
             } else {
                 $this->data['search'] = '';
             }
             // 商品编号 $result['num_iid']
             if (isset($result['num_iid']) && $result['num_iid']) {
                 $this->data['num_iid'] = $result['num_iid'];
             } else {
                 $this->data['num_iid'] = '';
             }
             // 商品名字 $result['goodsname']
             if (isset($result['goodsname']) && $result['goodsname']) {
                 $this->data['heading_title'] = $result['goodsname'];
             } else {
                 $this->data['heading_title'] = '';
             }
             // 商品主图 $result['goodsimg']
             if (isset($result['goodsimg']) && $result['goodsimg']) {
                 $this->data['goodsimg'] = $result['goodsimg'];
             } else {
                 $this->data['goodsimg'] = '';
             }
             // 商品价格 $result['price']
             if (isset($result['goodsprice'])) {
                 $this->data['price'] = $result['goodsprice'];
             } else {
                 $this->data['price'] = '';
             }
             // 颜色分类 $result['ean']
             if (isset($result['ean']) && $result['ean']) {
                 $this->data['ean'] = $result['ean'];
             } else {
                 $this->data['ean'] = '';
             }
             // 尺码大小 $result['jan']
             if (isset($result['jan']) && $result['jan']) {
                 $this->data['jan'] = $result['jan'];
             } else {
                 $this->data['jan'] = '';
             }
             // 店铺名称
             if (isset($result['storename']) && $result['storename']) {
                 $this->data['storename'] = $result['storename'];
             } else {
                 $this->data['storename'] = '';
             }
             // 店铺地址
             if (isset($result['storeurl']) && $result['storeurl']) {
                 $this->data['storeurl'] = $result['storeurl'];
             } else {
                 $this->data['storeurl'] = '';
             }
             // 国内运费
             if (isset($result['yunfei'])) {
                 $this->data['isbn'] = $result['yunfei'];
             } else {
                 $this->data['isbn'] = '';
             }
             if ($flag) {
                 $this->data['prifex'] = 'AL';
                 $this->data['property'] = array();
                 if ($this->data['jan']) {
                     $this->data['property']['尺码'] = $this->data['jan'];
                 }
                 if ($this->data['ean']) {
                     $this->data['property']['颜色分类'] = $this->data['ean'];
                 }
                 echo json_encode($this->data);
             } else {
                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                     $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
                 } else {
                     $this->template = 'default/template/product/zzg_snatch_info.tpl';
                 }
                 $this->response->setOutput($this->render());
             }
         } else {
             if (false !== strpos($search, 'dangdang.com')) {
                 $result = array();
                 $html = $this->gethtmlcontent($search);
                 $html = mb_convert_encoding($html, 'UTF-8', 'gbk');
                 // 商品编号
                 if (preg_match('#dangdang.com/(.*).html#isU', $search, $matches)) {
                     // var_dump($matches);
                     if (!empty($matches)) {
                         $result['num_iid'] = $matches[1];
                     }
                 }
                 // 商品名称
                 if (preg_match('#<h1>(.*)<span#iU', $html, $matches)) {
                     if (!empty($matches)) {
                         $result['goodsname'] = strip_tags($matches[1]);
                     }
                 }
                 // 商品价格
                 if (preg_match('#<span id=[\\"|\']promo_price[\\"|\']>(.*)</span>#isU', $html, $matches)) {
                     // var_dump ( $matches );
                     if (!empty($matches)) {
                         $result['goodsprice'] = $matches[1];
                         $result['goodsprice'] = trim($result['goodsprice'], '&yen;');
                     }
                 } elseif (preg_match('#<span id=[\\"|\']salePriceTag[\\"|\']>(.*)</span>#isU', $html, $matches)) {
                     if (!empty($matches)) {
                         $result['goodsprice'] = $matches[1];
                     }
                 }
                 // 商品主图
                 if (preg_match('#wsrc=[\\"|\'](.*)[\\"|\']#isU', $html, $matches)) {
                     // var_dump($matches);
                     if (!empty($matches)) {
                         $result['goodsimg'] = $matches[1];
                     }
                 }
                 // 商品颜色
                 if (preg_match('#<ul class=[\\"|\']color[\\"|\']>(.*)</ul>#isU', $html, $matches)) {
                     if (preg_match_all('#title=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                         if (!empty($matches)) {
                             $result['ean'] = $matches[1];
                         }
                     }
                 }
                 // 商品尺寸规格
                 if (preg_match('#<ul class=[\\"|\']size[\\"|\']>(.*)</ul>#isU', $html, $matches)) {
                     if (preg_match_all('#<a[^>]+>(.*)</a>#isU', $matches[1], $matches)) {
                         if (!empty($matches)) {
                             $result['jan'] = $matches[1];
                             unset($result['jan'][array_search("尺码对照表", $result['jan'])]);
                         }
                     }
                 }
                 // $result['yunfei'] = 0.00;
                 $result['storename'] = "当当网";
                 $result['storeurl'] = "http://www.dangdang.com/";
                 if ($search) {
                     $this->data['search'] = $search;
                 } else {
                     $this->data['search'] = '';
                 }
                 // 商品编号 $result['num_iid']
                 if (isset($result['num_iid']) && $result['num_iid']) {
                     $this->data['num_iid'] = $result['num_iid'];
                 } else {
                     $this->data['num_iid'] = '';
                 }
                 // 商品名字 $result['goodsname']
                 if (isset($result['goodsname']) && $result['goodsname']) {
                     $this->data['heading_title'] = $result['goodsname'];
                 } else {
                     $this->data['heading_title'] = '';
                 }
                 // 商品主图 $result['goodsimg']
                 if (isset($result['goodsimg']) && $result['goodsimg']) {
                     $this->data['goodsimg'] = $result['goodsimg'];
                 } else {
                     $this->data['goodsimg'] = '';
                 }
                 // 商品价格 $result['price']
                 if (isset($result['goodsprice'])) {
                     $this->data['price'] = $result['goodsprice'];
                 } else {
                     $this->data['price'] = '';
                 }
                 // 颜色分类 $result['ean']
                 if (isset($result['ean']) && $result['ean']) {
                     $this->data['ean'] = $result['ean'];
                 } else {
                     $this->data['ean'] = '';
                 }
                 // 尺码大小 $result['jan']
                 if (isset($result['jan']) && $result['jan']) {
                     $this->data['jan'] = $result['jan'];
                 } else {
                     $this->data['jan'] = '';
                 }
                 // 店铺名称
                 if (isset($result['storename']) && $result['storename']) {
                     $this->data['storename'] = $result['storename'];
                 } else {
                     $this->data['storename'] = '';
                 }
                 // 店铺地址
                 if (isset($result['storeurl']) && $result['storeurl']) {
                     $this->data['storeurl'] = $result['storeurl'];
                 } else {
                     $this->data['storeurl'] = '';
                 }
                 // 国内运费
                 if (isset($result['yunfei'])) {
                     $this->data['isbn'] = $result['yunfei'];
                 } else {
                     $this->data['isbn'] = 0.0;
                 }
                 if ($flag) {
                     $this->data['prifex'] = 'DD';
                     $this->data['property'] = array();
                     if ($this->data['jan']) {
                         $this->data['property']['尺码'] = $this->data['jan'];
                     }
                     if ($this->data['ean']) {
                         $this->data['property']['颜色分类'] = $this->data['ean'];
                     }
                     echo json_encode($this->data);
                 } else {
                     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                         $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
                     } else {
                         $this->template = 'default/template/product/zzg_snatch_info.tpl';
                     }
                     $this->response->setOutput($this->render());
                 }
             } else {
                 if (false !== strpos($search, 'amazon.cn')) {
                     $result = array();
                     $html = $this->gethtmlcontent($search);
                     // 商品名
                     if (preg_match('#a-size-large\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#parseasinTitle\\">(.*)<\\/h1>#isU', $html, $matches)) {
                         $matches[0] = strip_tags($matches[1]);
                         if (!empty($matches[1])) {
                             $date[0] = strip_tags($matches[1]);
                         }
                     }
                     // 图片地址
                     if (preg_match('#<div id=[\\"|\']kib-ma-container-0[\\"|\'][^>]+>(.*)</div>#isU', $html, $matches)) {
                         if (preg_match('#src=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                             if (!empty($matches)) {
                                 $result['goodsimg'] = $matches[1];
                             }
                         }
                     } else {
                         if (preg_match('#<tr id=[\\"|\']prodImageContainer[\\"|\']>(.*)</tr>#isU', $html, $matches)) {
                             if (preg_match('#src=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                 if (!empty($matches)) {
                                     $result['goodsimg'] = $matches[1];
                                 }
                             }
                         } else {
                             if (preg_match('#<div class=[\\"|\']main-image-inner-wrapper[\\"|\']>(.*)</div>#isU', $html, $matches)) {
                                 if (preg_match('#src=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                     if (!empty($matches)) {
                                         $result['goodsimg'] = $matches[1];
                                     }
                                 }
                             } else {
                                 if (preg_match('#<div id=[\\"|\']imgTagWrapperId[\\"|\'] class=[\\"|\']imgTagWrapper[\\"|\']>(.*)</div>#isU', $html, $matches)) {
                                     if (preg_match('#data-a-dynamic-image=[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                         if (preg_match('#http(.*)jpg#isU', $matches[1], $matches)) {
                                             if (!empty($matches[1])) {
                                                 $result['goodsimg'] = 'http' . $matches[1] . 'jpg';
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     // 商品价格
                     if (preg_match('#id=\\"priceblock_ourprice\\"[^>]*>(.*)<\\/span>#isU', $html, $matches) || preg_match('#priceLarge\\"[^>]*>(.*)<\\/b>#isU', $html, $matches) || preg_match('#id=\\"listPriceValue\\"[^>]*>(.*)<\\/span>#isU', $html, $matches) || preg_match('#a-size-medium a-color-price offer-price a-text-normal\\"[^>]*>(.*)<\\/span>#isU', $html, $matches) || preg_match('#id=\\"priceblock_saleprice\\"[^>]*>(.*)<\\/span>#isU', $html, $matches)) {
                         if (!empty($matches[1])) {
                             $matches[1] = str_replace('¥', '', $matches[1]);
                             $matches[1] = is_array($matches[1] = explode('-', $matches[1])) ? trim(end($matches[1]), ' ') : $matches[1];
                             $date[3] = $matches[1];
                         }
                     }
                     if (preg_match('#priceLarge kitsunePrice\\"[^>]*>(.*)<\\/b>#isU', $html, $matches)) {
                         $matches[1] = str_replace('¥', '', $matches[1]);
                         $matches[1] = is_array($matches[1] = explode('-', $matches[1])) ? trim(end($matches[1]), ' ') : $matches[1];
                         $date[3] = $matches[1];
                     }
                     // 商品颜色
                     if (preg_match_all('#<li id=\\"color_name_[0-9]*\\"[^>]*>(.*)<\\/li>#isU', $html, $matches) || preg_match_all('#<div id=\\"variation_color_name*\\"[^>]*>(.*)<\\/div>#isU', $html, $matches)) {
                         foreach ($matches[1] as $v) {
                             if (preg_match('#<img[^>]*alt=\\"(.*)\\"[^>]*>#isU', $v, $matches) || preg_match('#selection\\">(.*)<\\/span>#isU', $html, $matches)) {
                                 if (!empty($matches[1])) {
                                     $date[4][] = $matches[1];
                                 }
                             }
                         }
                     }
                     // 商品规格
                     if (preg_match_all('#<div class=[\\"|\']swatchInnerText[\\"|\'][^>]+>(.*)</div>#isU', $html, $matches) || preg_match('#native_dropdown_selected_size_name\\"[^>]*>(.*)<\\/select>#isU', $html, $matches) && preg_match_all('#<option[^>]*>(.*)<\\/option>#isU', $matches[1], $matches) || preg_match_all('#<li id=\\"size_name_[0-9]*\\"[^>]*>(.*)<\\/li>#isU', $html, $matches) || preg_match('#a-spacing-top-micro swatches swatchesSquare\\">(.*)<\\/ul>#isU', $html, $matches) && preg_match_all('#<li[^>]*>(.*)<\\/li>#isU', $matches[1], $matches)) {
                         if (!is_array($matches[1])) {
                             $date[5] = $matches[1];
                         } else {
                             if (array_search("选择", $matches[1], true) !== null) {
                                 unset($matches[1][array_search("选择", $matches[1])]);
                             }
                             foreach ($matches[1] as $v) {
                                 if (preg_match('#text\\">(.*)<\\/div>#isU', $v, $matches)) {
                                     if (!empty($matches[1])) {
                                         $matches[1] = strip_tags($v);
                                         $date[5][] = $matches[1];
                                     }
                                 } else {
                                     if (!empty($v)) {
                                         $matches[1] = strip_tags($v);
                                         $date[5][] = $matches[1];
                                     }
                                 }
                             }
                         }
                     }
                     // 商品运费
                     if (preg_match('#ddmMerchantMessage\\">(.*)<\\/span>#isU', $html, $matches) || preg_match('#a-size-base a-color-base\\">(.*)<\\/span>#isU', $html, $matches)) {
                         $matches[1] = strip_tags($matches[1]);
                         if (is_numeric($matches[1])) {
                             if (!empty($matches[1])) {
                                 $date[6] = $matches[1];
                             }
                         }
                     }
                     // var_dump ( $date );
                     if (array_key_exists('0', $date) && $date[0]) {
                         $result['goodsname'] = $date[0];
                     }
                     if (array_key_exists('3', $date) && $date[3]) {
                         $result['goodsprice'] = $date[3];
                     }
                     if (array_key_exists('4', $date) && $date[4]) {
                         $result['ean'] = $date[4];
                     }
                     if (array_key_exists('5', $date) && $date[5]) {
                         // unset( $date[5][array_search (" ", $date [5] )] );
                         // var_dump ( $date [5] );
                         $result['jan'] = array_filter($date[5]);
                         // var_dump ( $date [5] );
                     }
                     if (array_key_exists('6', $date) && $date[6]) {
                         $result['yunfei'] = $date['6'];
                     }
                     $result['storename'] = "亚马逊";
                     $result['storeurl'] = "http://www.amazon.cn/";
                     if ($search) {
                         $this->data['search'] = $search;
                     } else {
                         $this->data['search'] = '';
                     }
                     // 商品编号 $result['num_iid']
                     if (isset($result['num_iid']) && $result['num_iid']) {
                         $this->data['num_iid'] = $result['num_iid'];
                     } else {
                         $this->data['num_iid'] = '';
                     }
                     // 商品名字 $result['goodsname']
                     if (isset($result['goodsname']) && $result['goodsname']) {
                         $this->data['heading_title'] = $result['goodsname'];
                     } else {
                         $this->data['heading_title'] = '';
                     }
                     // 商品主图 $result['goodsimg']
                     if (isset($result['goodsimg']) && $result['goodsimg']) {
                         $this->data['goodsimg'] = $result['goodsimg'];
                     } else {
                         $this->data['goodsimg'] = '';
                     }
                     // 商品价格 $result['price']
                     if (isset($result['goodsprice'])) {
                         $this->data['price'] = $result['goodsprice'];
                     } else {
                         $this->data['price'] = '';
                     }
                     // 颜色分类 $result['ean']
                     if (isset($result['ean']) && $result['ean']) {
                         $this->data['ean'] = $result['ean'];
                     } else {
                         $this->data['ean'] = '';
                     }
                     // 尺码大小 $result['jan']
                     if (isset($result['jan']) && $result['jan']) {
                         $this->data['jan'] = $result['jan'];
                     } else {
                         $this->data['jan'] = '';
                     }
                     // 店铺名称
                     if (isset($result['storename']) && $result['storename']) {
                         $this->data['storename'] = $result['storename'];
                     } else {
                         $this->data['storename'] = '';
                     }
                     // 店铺地址
                     if (isset($result['storeurl']) && $result['storeurl']) {
                         $this->data['storeurl'] = $result['storeurl'];
                     } else {
                         $this->data['storeurl'] = '';
                     }
                     // 国内运费
                     if (isset($result['yunfei'])) {
                         $this->data['isbn'] = $result['yunfei'];
                     } else {
                         $this->data['isbn'] = 0.0;
                     }
                     if ($flag) {
                         $this->data['prifex'] = 'AM';
                         $this->data['property'] = array();
                         if ($this->data['jan']) {
                             $this->data['property']['尺码'] = $this->data['jan'];
                         }
                         if ($this->data['ean']) {
                             $this->data['property']['颜色分类'] = $this->data['ean'];
                         }
                         echo json_encode($this->data);
                     } else {
                         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                             $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
                         } else {
                             $this->template = 'default/template/product/zzg_snatch_info.tpl';
                         }
                         $this->response->setOutput($this->render());
                     }
                 } else {
                     if (false !== strpos($search, 'jd.com')) {
                         $result = array();
                         $html = $this->gethtmlcontent($search);
                         $html = mb_convert_encoding($html, 'UTF-8', 'gb2312');
                         // 商品编号
                         if (preg_match('#jd.com/(.*).html#isU', $search, $matches)) {
                             // var_dump($matches);
                             if (!empty($matches)) {
                                 $result['num_iid'] = $matches[1];
                             }
                         }
                         // 商品名称
                         if (preg_match('#<div id="name">(.*)</div>#isU', $html, $matches)) {
                             if (preg_match('#<h1>(.*)</h1>#isU', $matches[1], $matches)) {
                                 if (!empty($matches)) {
                                     $result['goodsname'] = strip_tags($matches[1]);
                                 }
                             }
                         }
                         // 商品价格
                         if (isset($result['num_iid']) && $result['num_iid']) {
                             $price_url = 'http://p.3.cn/prices/get?skuid=J_' . $result['num_iid'];
                             $price_html = $this->gethtmlcontent($price_url);
                             $p_price = explode(',', $price_html);
                             if (isset($p_price[1])) {
                                 $price = explode(':', $p_price[1]);
                                 $price = trim($price[1], '"');
                             } else {
                                 $price = '';
                             }
                             $result['goodsprice'] = trim($price, '"');
                         }
                         // 商品主图
                         if (preg_match('#jqimg=[\\"|\'](.*)[\\"|\']#isU', $html, $matches)) {
                             if (!empty($matches)) {
                                 $result['goodsimg'] = $matches[1];
                             }
                         } elseif (preg_match('#<img width=[\\"|\']350[\\"|\'] height=[\\"|\']350[\\"|\']  data-img=[\\"|\']1[\\"|\'] src=[\\"|\'](.*)[\\"|\'] alt=[\\"|\'](.*)[\\"|\']>#isU', $html, $matches)) {
                             if (!empty($matches)) {
                                 $result['goodsimg'] = $matches[1];
                             }
                         }
                         // 商品颜色
                         if (preg_match('#<li id=[\\"|\']choose-color[\\"|\'] class=[\\"|\']choose-color-shouji[\\"|\']>(.*)</li>#isU', $html, $matches)) {
                             if (preg_match_all('#<i>(.*)</i>#isU', $matches[1], $matches)) {
                                 if (!empty($matches)) {
                                     $result['ean'] = $matches[1];
                                 }
                             }
                         }
                         // 商品尺寸规格
                         if (preg_match('#<li id=[\\"|\']choose-version[\\"|\']>(.*)</li>#isU', $html, $matches)) {
                             if (preg_match_all('#<a[^>]+>(.*)</a>#isU', $matches[1], $matches)) {
                                 if (!empty($matches)) {
                                     $result['jan'] = $matches[1];
                                 }
                             }
                         }
                         $result['yunfei'] = 0.0;
                         $result['storename'] = "京东商城";
                         $result['storeurl'] = "http://www.jd.com/";
                         if ($search) {
                             if (!strstr($search, 'http') || !strstr($search, 'HTTP')) {
                                 $this->data['search'] = "http://" . $search;
                             } else {
                                 $this->data['search'] = $search;
                             }
                         } else {
                             $this->data['search'] = '';
                         }
                         // 商品编号 $result['num_iid']
                         if (isset($result['num_iid']) && $result['num_iid']) {
                             $this->data['num_iid'] = $result['num_iid'];
                         } else {
                             $this->data['num_iid'] = '';
                         }
                         // 商品名字 $result['goodsname']
                         if (isset($result['goodsname']) && $result['goodsname']) {
                             $this->data['heading_title'] = $result['goodsname'];
                         } else {
                             $this->data['heading_title'] = '';
                         }
                         // 商品主图 $result['goodsimg']
                         if (isset($result['goodsimg']) && $result['goodsimg']) {
                             $this->data['goodsimg'] = $result['goodsimg'];
                         } else {
                             $this->data['goodsimg'] = '';
                         }
                         // 商品价格 $result['price']
                         if (isset($result['goodsprice'])) {
                             $this->data['price'] = $result['goodsprice'];
                         } else {
                             $this->data['price'] = '';
                         }
                         // 颜色分类 $result['ean']
                         if (isset($result['ean']) && $result['ean']) {
                             $this->data['ean'] = $result['ean'];
                         } else {
                             $this->data['ean'] = '';
                         }
                         // 尺码大小 $result['jan']
                         if (isset($result['jan']) && $result['jan']) {
                             $this->data['jan'] = $result['jan'];
                         } else {
                             $this->data['jan'] = '';
                         }
                         // 店铺名称
                         if (isset($result['storename']) && $result['storename']) {
                             $this->data['storename'] = $result['storename'];
                         } else {
                             $this->data['storename'] = '';
                         }
                         // 店铺地址
                         if (isset($result['storeurl']) && $result['storeurl']) {
                             $this->data['storeurl'] = $result['storeurl'];
                         } else {
                             $this->data['storeurl'] = '';
                         }
                         // 国内运费
                         if (isset($result['yunfei'])) {
                             $this->data['isbn'] = $result['yunfei'];
                         } else {
                             $this->data['isbn'] = '';
                         }
                         if ($flag) {
                             $this->data['prifex'] = 'JD';
                             $this->data['property'] = array();
                             if ($this->data['jan']) {
                                 $this->data['property']['尺码'] = $this->data['jan'];
                             }
                             if ($this->data['ean']) {
                                 $this->data['property']['颜色分类'] = $this->data['ean'];
                             }
                             echo json_encode($this->data);
                         } else {
                             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                                 $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
                             } else {
                                 $this->template = 'default/template/product/zzg_snatch_info.tpl';
                             }
                             $this->response->setOutput($this->render());
                         }
                     } else {
                         if (false !== strpos($search, 'mogujie.com')) {
                             $result = array();
                             $html = $this->gethtmlcontent($search);
                             // 商品名称
                             if (preg_match('#<h1 class="goods-title">(.*)</h1>#isU', $html, $matches)) {
                                 if (!empty($matches)) {
                                     $result['goodsname'] = strip_tags($matches[1]);
                                 }
                             }
                             // 商品价格
                             if (preg_match('#<span id=[\\"|\']J_NowPrice[\\"|\'] class=[\\"|\']price-n[\\"|\']>(.*)</span>#isU', $html, $matches)) {
                                 if (!empty($matches)) {
                                     $result['goodsprice'] = $matches[1];
                                 }
                             }
                             // 商品主图
                             if (preg_match('#<img id=[\\"|\']J_BigImg[\\"|\'] src=[\\"|\'](.*)[\\"|\'][^>]+>#isU', $html, $matches)) {
                                 $result['goodsimg'] = $matches[1];
                             }
                             // 商品颜色和尺寸规格
                             if (preg_match('#var detailInfo = {(.*)};#isU', $html, $matches)) {
                                 if (preg_match_all('#[\\"|\']style[\\"|\']:[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                     if (!empty($matches)) {
                                         $result['ean'] = $matches[1];
                                     }
                                 }
                             }
                             if (isset($result['ean']) && $result['ean']) {
                                 $result['ean'] = array_flip(array_flip($result['ean']));
                                 foreach ($result['ean'] as &$ean) {
                                     $ean = preg_replace("#\\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $ean);
                                 }
                             }
                             if (preg_match('#var detailInfo = {(.*)};#isU', $html, $matches)) {
                                 if (preg_match_all('#[\\"|\']size[\\"|\']:[\\"|\'](.*)[\\"|\']#isU', $matches[1], $matches)) {
                                     if (!empty($matches)) {
                                         $result['jan'] = $matches[1];
                                     }
                                 }
                             }
                             if (isset($result['jan']) && $result['jan']) {
                                 $result['jan'] = array_flip(array_flip($result['jan']));
                                 foreach ($result['jan'] as &$jan) {
                                     $jan = preg_replace("#\\\\u([0-9a-f]{4})#ie", "iconv('UCS-2BE', 'UTF-8', pack('H4', '\\1'))", $jan);
                                 }
                             }
                             $result['yunfei'] = 0.0;
                             //店铺名称
                             if (preg_match('#<span class=[\\"|\']name-wrap clearfix[\\"|\'](.*)</span>#isU', $html, $matches)) {
                                 if (preg_match('#<a[^>]+>(.*)</a>#isU', $matches[1], $matches)) {
                                     $result['storename'] = $matches[1];
                                 }
                                 if (preg_match('#href=[\\"|\'](.*)[\\"|\']#isU', $matches[0], $matches)) {
                                     $result['storeurl'] = $matches[1];
                                 }
                             }
                             if ($search) {
                                 $this->data['search'] = $search;
                             } else {
                                 $this->data['search'] = '';
                             }
                             // 商品编号 $result['num_iid']
                             if (isset($result['num_iid']) && $result['num_iid']) {
                                 $this->data['num_iid'] = $result['num_iid'];
                             } else {
                                 $this->data['num_iid'] = '';
                             }
                             // 商品名字 $result['goodsname']
                             if (isset($result['goodsname']) && $result['goodsname']) {
                                 $this->data['heading_title'] = $result['goodsname'];
                             } else {
                                 $this->data['heading_title'] = '';
                             }
                             // 商品主图 $result['goodsimg']
                             if (isset($result['goodsimg']) && $result['goodsimg']) {
                                 $this->data['goodsimg'] = $result['goodsimg'];
                             } else {
                                 $this->data['goodsimg'] = '';
                             }
                             // 商品价格 $result['price']
                             if (isset($result['goodsprice'])) {
                                 $this->data['price'] = $result['goodsprice'];
                             } else {
                                 $this->data['price'] = '';
                             }
                             // 颜色分类 $result['ean']
                             if (isset($result['ean']) && $result['ean']) {
                                 $this->data['ean'] = $result['ean'];
                             } else {
                                 $this->data['ean'] = '';
                             }
                             // 尺码大小 $result['jan']
                             if (isset($result['jan']) && $result['jan']) {
                                 $this->data['jan'] = $result['jan'];
                             } else {
                                 $this->data['jan'] = '';
                             }
                             // 店铺名称
                             if (isset($result['storename']) && $result['storename']) {
                                 $this->data['storename'] = $result['storename'];
                             } else {
                                 $this->data['storename'] = '';
                             }
                             // 店铺地址
                             if (isset($result['storeurl']) && $result['storeurl']) {
                                 $this->data['storeurl'] = $result['storeurl'];
                             } else {
                                 $this->data['storeurl'] = '';
                             }
                             // 国内运费
                             if (isset($result['yunfei'])) {
                                 $this->data['isbn'] = $result['yunfei'];
                             } else {
                                 $this->data['isbn'] = '';
                             }
                             if ($flag) {
                                 $this->data['prifex'] = 'MGJ';
                                 $this->data['property'] = array();
                                 if ($this->data['jan']) {
                                     $this->data['property']['尺码'] = $this->data['jan'];
                                 }
                                 if ($this->data['ean']) {
                                     $this->data['property']['颜色分类'] = $this->data['ean'];
                                 }
                                 echo json_encode($this->data);
                             } else {
                                 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                                     $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
                                 } else {
                                     $this->template = 'default/template/product/zzg_snatch_info.tpl';
                                 }
                                 $this->response->setOutput($this->render());
                             }
                         } else {
                             if (false !== strpos($search, 'meilishuo.com')) {
                                 $result = array();
                                 $html = $this->gethtmlcontent($search);
                                 //商品名称
                                 if (preg_match('#<h3 class="s_tle">(.*)</h3>#isU', $html, $matches)) {
                                     if (!empty($matches)) {
                                         $result['goodsname'] = strip_tags($matches[1]);
                                     }
                                 } else {
                                     if (preg_match('#<h3 class="item-title">(.*)</h3>#isU', $html, $matches)) {
                                         if (!empty($matches)) {
                                             $result['goodsname'] = strip_tags($matches[1]);
                                         }
                                     }
                                 }
                                 // 商品价格
                                 if (preg_match('#<ul class="sku_meta">(.*)</ul>#isU', $html, $matches)) {
                                     //var_dump($matches);
                                     if (preg_match('#<span class="price">(.*)</span>#isU', $matches[1], $matches)) {
                                         if (!empty($matches)) {
                                             $result['goodsprice'] = $matches[1];
                                             $result['goodsprice'] = trim($result['goodsprice'], '¥');
                                         }
                                     }
                                 }
                                 if (!isset($result['goodsprice'])) {
                                     if (preg_match('#<i id="price-now"[^>]+>(.*)</i>#isU', $html, $matches)) {
                                         if (!empty($matches)) {
                                             $result['goodsprice'] = $matches[1];
                                             $result['goodsprice'] = trim($result['goodsprice'], '¥');
                                         }
                                     }
                                 }
                                 // 商品主图
                                 if (preg_match('#<img class="j_big_show twitter_pic"[^>]+>#isU', $html, $matches)) {
                                     if (preg_match('#src="(.*)"#isU', $matches[0], $matches)) {
                                         if (!empty($matches)) {
                                             $result['goodsimg'] = $matches[1];
                                         }
                                     }
                                 } else {
                                     if (preg_match('#<img class="j-big-pic twitter_pic"[^>]+>#isU', $html, $matches)) {
                                         if (preg_match('#src="(.*)"#isU', $matches[0], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['goodsimg'] = $matches[1];
                                             }
                                         }
                                     }
                                 }
                                 // 商品颜色和尺寸规格
                                 if (preg_match('#<ul id="colorList">(.*)</ul>#isU', $html, $matches)) {
                                     if (preg_match_all('#title="(.*)"#isU', $matches[1], $matches)) {
                                         if (!empty($matches)) {
                                             $result['ean'] = $matches[1];
                                         }
                                     }
                                 } else {
                                     if (preg_match('#<ul id="colorList" class="item-colorlist ">(.*)</ul>#isU', $html, $matches)) {
                                         if (preg_match_all('#<a [^>]+>(.*)</a>#isU', $matches[1], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['ean'] = $matches[1];
                                             }
                                         }
                                     }
                                 }
                                 if (preg_match('#<ul id="sizeList">(.*)</ul>#isU', $html, $matches)) {
                                     if (preg_match_all('#title="(.*)"#isU', $matches[1], $matches)) {
                                         if (!empty($matches)) {
                                             $result['jan'] = $matches[1];
                                         }
                                     }
                                 }
                                 $result['yunfei'] = 0.0;
                                 //店铺名称
                                 if (preg_match('#<div class=[\\"|\']shop-wrap[\\"|\']>(.*)</div>#isU', $html, $matches)) {
                                     if (preg_match('#<a[^>]+>(.*)</a>#isU', $matches[1], $matches)) {
                                         $result['storename'] = $matches[1];
                                     }
                                     if (preg_match('#href=[\\"|\'](.*)[\\"|\']#isU', $matches[0], $matches)) {
                                         $result['storeurl'] = $matches[1];
                                     }
                                 }
                                 if ($search) {
                                     $this->data['search'] = $search;
                                 } else {
                                     $this->data['search'] = '';
                                 }
                                 // 商品编号 $result['num_iid']
                                 if (isset($result['num_iid']) && $result['num_iid']) {
                                     $this->data['num_iid'] = $result['num_iid'];
                                 } else {
                                     $this->data['num_iid'] = '';
                                 }
                                 // 商品名字 $result['goodsname']
                                 if (isset($result['goodsname']) && $result['goodsname']) {
                                     $this->data['heading_title'] = $result['goodsname'];
                                 } else {
                                     $this->data['heading_title'] = '';
                                 }
                                 // 商品主图 $result['goodsimg']
                                 if (isset($result['goodsimg']) && $result['goodsimg']) {
                                     $this->data['goodsimg'] = $result['goodsimg'];
                                 } else {
                                     $this->data['goodsimg'] = '';
                                 }
                                 // 商品价格 $result['price']
                                 if (isset($result['goodsprice'])) {
                                     $this->data['price'] = $result['goodsprice'];
                                 } else {
                                     $this->data['price'] = '';
                                 }
                                 // 颜色分类 $result['ean']
                                 if (isset($result['ean']) && $result['ean']) {
                                     $this->data['ean'] = $result['ean'];
                                 } else {
                                     $this->data['ean'] = '';
                                 }
                                 // 尺码大小 $result['jan']
                                 if (isset($result['jan']) && $result['jan']) {
                                     $this->data['jan'] = $result['jan'];
                                 } else {
                                     $this->data['jan'] = '';
                                 }
                                 // 店铺名称
                                 if (isset($result['storename']) && $result['storename']) {
                                     $this->data['storename'] = $result['storename'];
                                 } else {
                                     $this->data['storename'] = '';
                                 }
                                 // 店铺地址
                                 if (isset($result['storeurl']) && $result['storeurl']) {
                                     $this->data['storeurl'] = "http://www.meilishuo.com" . $result['storeurl'];
                                 } else {
                                     $this->data['storeurl'] = '';
                                 }
                                 // 国内运费
                                 if (isset($result['yunfei'])) {
                                     $this->data['isbn'] = $result['yunfei'];
                                 } else {
                                     $this->data['isbn'] = '';
                                 }
                                 if ($flag) {
                                     $this->data['prifex'] = 'MGJ';
                                     $this->data['property'] = array();
                                     if ($this->data['jan']) {
                                         $this->data['property']['尺码'] = $this->data['jan'];
                                     }
                                     if ($this->data['ean']) {
                                         $this->data['property']['颜色分类'] = $this->data['ean'];
                                     }
                                     echo json_encode($this->data);
                                 } else {
                                     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                                         $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
                                     } else {
                                         $this->template = 'default/template/product/zzg_snatch_info.tpl';
                                     }
                                     $this->response->setOutput($this->render());
                                 }
                             } else {
                                 if (false !== strpos($search, 'vip.com')) {
                                     $result = array();
                                     $html = $this->gethtmlcontent($search);
                                     // 商品编号
                                     if (preg_match('#<dl class="other clearfix">(.*)</dl>#isU', $html, $matches)) {
                                         if (preg_match('#<dd class="other_box">(.*)</dd>#isU', $matches[1], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['num_iid'] = $matches[1];
                                             }
                                         }
                                     }
                                     //商品名称
                                     if (preg_match('#<p class="pib_title_detail">(.*)</p>#isU', $html, $matches)) {
                                         if (!empty($matches)) {
                                             $result['goodsname'] = strip_tags($matches[1]);
                                         }
                                     }
                                     // 商品价格
                                     if (preg_match('#<span class="pbox_price">(.*)</span>#isU', $html, $matches)) {
                                         if (preg_match('#<em>(.*)</em>#isU', $matches[1], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['goodsprice'] = $matches[1];
                                                 $result['goodsprice'] = trim($result['goodsprice'], '¥');
                                             }
                                         }
                                     }
                                     // 商品主图
                                     if (preg_match('#<div class=[\\"|\']show_midpic [\\"|\']>(.*)</div>#isU', $html, $matches)) {
                                         if (preg_match('#src="(.*)"#isU', $matches[0], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['goodsimg'] = $matches[1];
                                             }
                                         }
                                     }
                                     // 商品颜色和尺寸规格
                                     if (preg_match('#<dd class="color_list"(.*)</dd>#isU', $html, $matches)) {
                                         if (preg_match_all('#alt="(.*)"#isU', $matches[1], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['ean'] = $matches[1];
                                             }
                                         }
                                     }
                                     if (preg_match('#<dd class="size_list">(.*)</dd>#isU', $html, $matches)) {
                                         if (preg_match_all('#<span class="size_list_item_name">(.*)</span>#isU', $matches[1], $matches)) {
                                             if (!empty($matches)) {
                                                 $result['jan'] = $matches[1];
                                             }
                                         }
                                     }
                                     $result['yunfei'] = 0.0;
                                     //店铺名称
                                     $result['storename'] = "唯品会";
                                     $result['storeurl'] = "http://www.vip.com/";
                                     if ($search) {
                                         $this->data['search'] = $search;
                                     } else {
                                         $this->data['search'] = '';
                                     }
                                     // 商品编号 $result['num_iid']
                                     if (isset($result['num_iid']) && $result['num_iid']) {
                                         $this->data['num_iid'] = $result['num_iid'];
                                     } else {
                                         $this->data['num_iid'] = '';
                                     }
                                     // 商品名字 $result['goodsname']
                                     if (isset($result['goodsname']) && $result['goodsname']) {
                                         $this->data['heading_title'] = $result['goodsname'];
                                     } else {
                                         $this->data['heading_title'] = '';
                                     }
                                     // 商品主图 $result['goodsimg']
                                     if (isset($result['goodsimg']) && $result['goodsimg']) {
                                         $this->data['goodsimg'] = $result['goodsimg'];
                                     } else {
                                         $this->data['goodsimg'] = '';
                                     }
                                     // 商品价格 $result['price']
                                     if (isset($result['goodsprice'])) {
                                         $this->data['price'] = $result['goodsprice'];
                                     } else {
                                         $this->data['price'] = '';
                                     }
                                     // 颜色分类 $result['ean']
                                     if (isset($result['ean']) && $result['ean']) {
                                         $this->data['ean'] = $result['ean'];
                                     } else {
                                         $this->data['ean'] = '';
                                     }
                                     // 尺码大小 $result['jan']
                                     if (isset($result['jan']) && $result['jan']) {
                                         $this->data['jan'] = $result['jan'];
                                     } else {
                                         $this->data['jan'] = '';
                                     }
                                     // 店铺名称
                                     if (isset($result['storename']) && $result['storename']) {
                                         $this->data['storename'] = $result['storename'];
                                     } else {
                                         $this->data['storename'] = '';
                                     }
                                     // 店铺地址
                                     if (isset($result['storeurl']) && $result['storeurl']) {
                                         $this->data['storeurl'] = $result['storeurl'];
                                     } else {
                                         $this->data['storeurl'] = '';
                                     }
                                     // 国内运费
                                     if (isset($result['yunfei'])) {
                                         $this->data['isbn'] = $result['yunfei'];
                                     } else {
                                         $this->data['isbn'] = '';
                                     }
                                     if ($flag) {
                                         $this->data['prifex'] = 'MGJ';
                                         $this->data['property'] = array();
                                         if ($this->data['jan']) {
                                             $this->data['property']['尺码'] = $this->data['jan'];
                                         }
                                         if ($this->data['ean']) {
                                             $this->data['property']['颜色分类'] = $this->data['ean'];
                                         }
                                         echo json_encode($this->data);
                                     } else {
                                         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl')) {
                                             $this->template = $this->config->get('config_template') . '/template/product/zzg_snatch_info.tpl';
                                         } else {
                                             $this->template = 'default/template/product/zzg_snatch_info.tpl';
                                         }
                                         $this->response->setOutput($this->render());
                                     }
                                 } else {
                                     if (false !== strpos($search, 'jumei.com') || false !== strpos($search, 'jumeiglobal.com')) {
                                         $result = array();
                                         $html = $this->gethtmlcontent($search);
                                         //商品名称
                                         if (preg_match('#<div class="newdeal_breadcrumbs_wrap_b">(.*)</div>#isU', $html, $matches)) {
                                             if (!empty($matches)) {
                                                 $result['goodsname'] = strip_tags($matches[1]);
                                             }
                                         } else {
                                             if (preg_match('#<div class="location">(.*)</div>#isU', $html, $matches)) {
                                                 if (preg_match('#<span>(.*)</span>#isU', $matches[0], $matches)) {
                                                     if (!empty($matches)) {
                                                         $result['goodsname'] = $matches[1];
                                                     }
                                                 }
                                             } else {
                                                 if (preg_match('#<h1 class="pop_detail_tit">(.*)</h1>#isU', $html, $matches)) {
                                                     if (!empty($matches)) {
                                                         $result['goodsname'] = $matches[1];
                                                     }
                                                 } else {
                                                     if (preg_match('#<h1>(.*)</h1>#isU', $html, $matches)) {
                                                         if (!empty($matches)) {
                                                             $result['goodsname'] = $matches[1];
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         //var_dump($result['goodsname']);
                                         // 商品价格
                                         if (preg_match('#<input type="hidden" id="discounted_price" value=[\\"|\'](.*)[\\"|\']>#isU', $html, $matches)) {
                                             if (!empty($matches)) {
                                                 $result['goodsprice'] = $matches[1];
                                             }
                                         } else {
                                             if (preg_match('#<span id="mall_price">(.*)</span>#isU', $html, $matches)) {
                                                 if (!empty($matches)) {
                                                     $result['goodsprice'] = $matches[1];
                                                 }
                                             } else {
                                                 if (preg_match('#<strong class="red_price">(.*)</strong>#isU', $html, $matches)) {
                                                     if (preg_match('#</span>(.*)</strong>#isU', $matches[0], $matches)) {
                                                         if (!empty($matches)) {
                                                             $result['goodsprice'] = $matches[1];
                                                         }
                                                     }
                                                 } else {
                                                     if (preg_match('#<span class="price_now ">(.*)</span>#isU', $html, $matches)) {
                                                         if (preg_match('#</em>(.*)</span>#isU', $matches[0], $matches)) {
                                                             if (!empty($matches)) {
                                                                 $result['goodsprice'] = $matches[1];
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         //var_dump($result['goodsprice']);
                                         // 商品主图
                                         if (preg_match('#<td rowspan=[\\"|\']7[\\"|\'] style=[\\"|\']padding-right:0;[\\"|\']>(.*)</td>#isU', $html, $matches)) {
                                             if (preg_match('#src="(.*)"#isU', $matches[0], $matches)) {
                                                 if (!empty($matches)) {
                                                     $result['goodsimg'] = $matches[1];
                                                 }
                                             }
                                         } else {
                                             if (preg_match('#<td  rowspan=[\\"|\']7[\\"|\'] align=[\\"|\']right[\\"|\'] valign=[\\"|\']bottom[\\"|\']>(.*)</td>#isU', $html, $matches)) {
                                                 if (preg_match('#src="(.*)"#isU', $matches[0], $matches)) {
                                                     if (!empty($matches)) {
                                                         $result['goodsimg'] = $matches[1];
                                                     }
                                                 }
                                             } else {
                                                 if (preg_match('#</table>(.*)</div>#isU', $html, $matches)) {
                                                     if (preg_match('#src="(.*)"#isU', $matches[0], $matches)) {
                                                         if (!empty($matches)) {
                                                             $result['goodsimg'] = $matches[1];
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if (preg_match('#<ul class="J_size_wrap">(.*)</ul>#isU', $html, $matches)) {
                                             if (preg_match_all('#<span>(.*)</span>#isU', $matches[1], $matches)) {
                                                 if (!empty($matches)) {
                                                     $result['jan'] = $matches[1];
                                                 }
                                             }
                                         }
                                         //var_dump($result['jan']);
                                         $result['yunfei'] = 0.0;
                                         //店铺名称
                                         $result['storename'] = "聚美优品";
                                         $result['storeurl'] = "http://www.jumei.com/";
                                         if ($search) {
                                             $this->data['search'] = $search;
                                         } else {
                                             $this->data['search'] = '';
                                         }
                                         // 商品编号 $result['num_iid']
                                         if (isset($result['num_iid']) && $result['num_iid']) {
                                             $this->data['num_iid'] = $result['num_iid'];
                                         } else {
                                             $this->data['num_iid'] = '';
                                         }
                                         // 商品名字 $result['goodsname']
                                         if (isset($result['goodsname']) && $result['goodsname']) {
                                             $this->data['heading_title'] = $result['goodsname'];
                                         } else {
                                             $this->data['heading_title'] = '';
                                         }
                                         // 商品主图 $result['goodsimg']
                                         if (isset($result['goodsimg']) && $result['goodsimg']) {
                                             $this->data['goodsimg'] = $result['goodsimg'];
                                         } else {
                                             $this->data['goodsimg'] = '';
                                         }
                                         // 商品价格 $result['price']
                                         if (isset($result['goodsprice'])) {
                                             $this->data['price'] = $result['goodsprice'];
                                         } else {
                                             $this->data['price'] = '';
                                         }
                                         // 颜色分类 $result['ean']
                                         if (isset($result['ean']) && $result['ean']) {
                                             $this->data['ean'] = $result['ean'];
                                         } else {
                                             $this->data['ean'] = '';
                                         }
                                         // 尺码大小 $result['jan']
                                         if (isset($result['jan']) && $result['jan']) {
                                             $this->data['jan'] = $result['jan'];
                                         } else {
                                             $this->data['jan'] = '';
                                         }
                                         // 店铺名称
                                         if (isset($result['storename']) && $result['storename']) {
                                             $this->data['storename'] = $result['storename'];
                                         } else {
                                             $this->data['storename'] = '';
                                         }
                                         // 店铺地址
                                         if (isset($result['storeurl']) && $result['storeurl']) {
                                             $this->data['storeurl'] = $result['storeurl'];
                                         } else {
                                             $this->data['storeurl'] = '';
                                         }
                                         // 国内运费
                                         if (isset($result['yunfei'])) {
                                             $this->data['isbn'] = $result['yunfei'];
                                         } else {
                                             $this->data['isbn'] = '';
                                         }
                                         if ($flag) {
                                             $this->data['prifex'] = 'JM';
                                             $this->data['property'] = array();
                                             if ($this->data['jan']) {
                                                 $this->data['property']['尺码'] = $this->data['jan'];
                                             }
                                             if ($this->data['ean']) {
                                                 $this->data['property']['颜色分类'] = $this->data['ean'];
                                             }
                                             echo json_encode($this->data);
                                         } else {
                                             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/zzg_zzg_snatch_info.tpl')) {
                                                 $this->template = $this->config->get('config_template') . '/template/product/zzg_zzg_snatch_info.tpl';
                                             } else {
                                                 $this->template = 'default/template/product/zzg_zzg_snatch_info.tpl';
                                             }
                                             $this->response->setOutput($this->render());
                                         }
                                     } else {
                                         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/snatch_noresults.tpl')) {
                                             $this->template = $this->config->get('config_template') . '/template/error/snatch_noresults.tpl';
                                         } else {
                                             $this->template = 'default/template/error/snatch_noresults.tpl';
                                         }
                                         $this->response->setOutput($this->render());
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }