Kaynağa Gözat

add import_car administration & car detail info index for mobile

lionared 7 yıl önce
ebeveyn
işleme
e4b7d26d38

+ 47 - 0
admin/control/car_import.php

@@ -0,0 +1,47 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: lionared
+ * Date: 2018/3/15
+ * Time: 上午11:18
+ */
+
+defined('InShopNC') or exit('Access Invalid!');
+require_once(BASE_ROOT_PATH . '/helper/car/importer.php');
+
+class car_importControl extends SystemControl {
+
+    public function __construct(){
+        parent::__construct();
+    }
+
+    public function indexOp()
+    {
+        if(isset($_POST['import'])) {
+            $file = $_FILES['csv_cars'];
+            $file_type = substr(strstr($file['name'], '.'), 1);
+
+            //上传文件存在判断
+            if(empty($file['name'])){
+                showMessage('请选择要上传csv的文件!','','html','error');
+            }
+
+            // 检查文件格式
+            if ($file_type != 'csv') {
+                showMessage('文件格式不对,请重新上传!','','html','error');
+                exit;
+            }
+
+            $delimiter = trim($_POST['delimiter']);
+
+            $importer = new car\importer($delimiter);
+            //暂时屏蔽车型数据导入
+            //$importer->run($file['tmp_name']);
+
+            showMessage('操作完成,暂未开放' , urlAdmin('car_import', 'index'));
+            return;
+        }
+
+        Tpl::showpage('car_import.index');
+    }
+}

+ 1 - 0
admin/include/menu.php

@@ -85,6 +85,7 @@ $arr = array(
 					array('args'=>'spec,spec,goods',						'text'=>$lang['nc_spec_manage']),
 					array('args'=>'list,goods_album,goods',					'text'=>$lang['nc_album_manage']),
                     array('args'=>'index,goods_plus,goods',					'text'=>'附加条款'),
+                    array('args'=>'index,car_import,goods',					'text'=>'车型导入'),
 				)
 			),
 			3 => array(

+ 32 - 0
admin/templates/default/car_import.index.php

@@ -0,0 +1,32 @@
+<?php defined('InShopNC') or exit('Access Invalid!');?>
+<div class="page">
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>从CSV导入</h3>
+        </div>
+    </div>
+    <div class="fixed-empty"></div>
+    <div>
+        <div>提醒:请仔细阅读以下各注意事项:</div>
+        <div>
+            <ul>
+                <li>非抓取的数据不要导入,以免污染车型数据库</li>
+            </ul>
+        </div>
+    </div>
+
+    <table class="table tb-type2">
+        <thead>
+        <tr class="thead">
+            <th>
+                <form method="post" action="index.php?act=car_import&op=index" enctype="multipart/form-data" id="stores_form">
+                    <label for="文件选择">请选择要导入的csv文件:</label><input name="csv_cars" type="file" />
+                    <label>分隔符:</label><input name="delimiter" size="70" type="text" placeholder="mac系统导出的csv以';'分割字段,windows系统导出的csv以','分割字段">
+                    <input type="submit" value="导入csv" name="import" />
+                </form>
+            </th>
+        </tr>
+        </thead>
+    </table>
+
+</div>

+ 1 - 1
admin/templates/default/store_import.php

@@ -43,7 +43,7 @@
       <thead>
         <tr class="thead">
           <th>
-  			<form method="post" action="index.php?act=store&op=store_import_csv" enctype="multipart/form-data" id="stores_form">
+  			<form method="post" action="index.php?act=store&op=store_import_csv_x" enctype="multipart/form-data" id="stores_form">
      		<label for="文件选择">请选择要导入的csv文件:</label><input name="csv_stores" type="file" />
                 <label>分隔符:</label><input name="delimiter" size="70" type="text" placeholder="mac系统导出的csv以';'分割字段,windows系统导出的csv以','分割字段">
     		<input type="submit" value="导入csv" name="import" />

+ 48 - 11
helper/car_helper.php

@@ -51,16 +51,16 @@ class car_helper
         return self::$stInstance;
     }
 
-    public function detail_url($car_id)
+    public function index_url($car_id)
     {
         $car_id = intval($car_id);
         if($car_id <= 0) return '';
 
-        $file_name = "{$car_id}.html";
+        $file_name = "{$car_id}_index.html";
         $file_path = BASE_UPLOAD_PATH. DS. "car". DS. $file_name;
         if(!file_exists($file_path))
         {
-            if($this->generate_html_file($car_id,$file_path) == false) {
+            if($this->write_file($file_path, $this->index_file_content($car_id)) == false){
                 return '';
             }
         }
@@ -71,21 +71,58 @@ class car_helper
         return $url;
     }
 
-    private function generate_html_file($car_id,$file_path)
+    public function detail_url($car_id)
     {
-        ob_start();
-        Tpl::output('tpl', new tpl_display($car_id));
-        Tpl::showpage("car/car_info");
-        $html_content = ob_get_contents();
-        ob_clean();
+        $car_id = intval($car_id);
+        if($car_id <= 0) return '';
+
+        $file_name = "{$car_id}_detail.html";
+        $file_path = BASE_UPLOAD_PATH. DS. "car". DS. $file_name;
+        if(!file_exists($file_path))
+        {
+            if($this->write_file($file_path, $this->detail_file_content($car_id)) == false) {
+                return '';
+            }
+        }
+
+        $version = $this->mCarsVersion[$car_id];
+        $url = UPLOAD_SITE_URL. DS. "car". DS. "{$file_name}?{$version}";
 
+        return $url;
+    }
+
+    private function write_file($file_path, $content)
+    {
         $write_success = false;
+
         $file = fopen($file_path,'w');
         if($file) {
-            $write_success = fwrite($file, $html_content);
+            $write_success = fwrite($file, $content);
             fclose($file);
         }
-
         return $write_success;
     }
+
+    private function index_file_content($car_id)
+    {
+        $mod_car = Model('car');
+        $car_info = $mod_car->base_info([ 'car_id'=>$car_id ]);
+        ob_start();
+        Tpl::output('car_info', $car_info);
+        Tpl::output('detail_url', $this->detail_url($car_id));
+        Tpl::showpage("car/car_details");
+        $content = ob_get_contents();
+        ob_clean();
+        return $content;
+    }
+
+    private function detail_file_content($car_id)
+    {
+        ob_start();
+        Tpl::output('tpl', new tpl_display($car_id));
+        Tpl::showpage("car/car_info");
+        $content = ob_get_contents();
+        ob_clean();
+        return $content;
+    }
 }

+ 3 - 1
helper/model/goods_common.php

@@ -95,8 +95,10 @@ class common_sumary extends common_base
                 }
             }
         }
+        $car_helper = car_helper::instance();
         $ret['goods_plus'] = unserialize($this->common_info['goods_plus']);
-        $ret['car_detail_url'] = car_helper::instance()->detail_url($ret['car_id']);
+        $ret['car_index_url']   = $car_helper->index_url($ret['car_id']);
+        //$ret['car_detail_url']  = $car_helper->detail_url($ret['car_id']);
         $ret['car_store_ids'] = unserialize($this->common_info['store_list']);
         $ret['car_store_total'] = count($ret['car_store_ids']);
 

+ 5 - 7
mobile/templates/default/car/car_details.php

@@ -1,6 +1,4 @@
-<?php
-    $car_info = $output['tpl'];
-?><!DOCTYPE html>
+<!DOCTYPE html>
 <html lang="en">
 
 <head>
@@ -11,7 +9,7 @@
     <meta name="screen-orientation" content="portrait">
     <meta name="x5-fullscreen" content="true">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
-    <title><?php echo $car_info['car_name']?></title>
+    <title><?php echo $output['car_info']['car_name']?></title>
     <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/car/css/reset.css?<?php echo bonus_version(); ?>"/>
     <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/car/css/style.css?<?php echo bonus_version(); ?>"/>
 </head>
@@ -33,14 +31,14 @@
                 <ul class="configuration-list">
                     <li class="configuration-item">
                         <p class="fl">厂商</p>
-                        <p class="fr">东风标致</p>
+                        <p class="fr"><?php echo $output['car_info']['manufacturer']?></p>
                     </li>
                     <li class="configuration-item">
                         <p class="fl">级别</p>
-                        <p class="fr">小型车</p>
+                        <p class="fr"><?php echo $output['car_info']['car_level_str']?></p>
                     </li>
                 </ul>
-                <div class="see-all-configuration">查看全部配置</div>
+                <div class="see-all-configuration"><a href="<?php echo $output['detail_url']?>">查看全部配置</a></div>
             </div>
 
             <div class="matters-content hide">

+ 1 - 0
shop/control/store_joinin.php

@@ -309,6 +309,7 @@ class store_joininControl extends BaseHomeControl {
         $param = array();
         $param['seller_name'] = $_POST['seller_name'];
         $param['store_name'] = $_POST['store_name'];
+        $param['store_type'] = intval($_POST['store_type']);
         $param['store_class_ids'] = serialize($store_class_ids);
         $param['store_class_names'] = serialize($store_class_names);
         $param['joinin_year'] = intval($_POST['joinin_year']);

+ 16 - 0
shop/templates/default/home/store_joinin_apply.step3.php

@@ -27,6 +27,16 @@
             <p class="emphasis">店铺名称注册后不可修改,请认真填写。</p></td>
         </tr>
         <tr>
+            <th class="w150"><i>*</i>店铺类型:</th>
+            <td><select name="store_type" class="w200"/>
+                <option>请选择店铺类型...</option>
+                <option value="1">汽车销售店铺、4S店</option>
+                <option value="2">融资租赁公司</option>
+            </select>
+                <span></span>
+                <p class="emphasis"></p></td>
+        </tr>
+        <tr>
             <th><i>*</i>店铺等级:</th>
             <td><select name="sg_id" id="sg_id">
                 <option value="0">请选择</option>
@@ -142,6 +152,9 @@ $(document).ready(function(){
                 maxlength: 50,
                 remote : '<?php echo urlShop('store_joinin', 'checkname');?>'
             },
+            store_type: {
+                required: true
+            },
             sg_id: {
                 required: true
             },
@@ -163,6 +176,9 @@ $(document).ready(function(){
                 maxlength: jQuery.validator.format("最多{0}个字"),
                 remote : '店铺名称已存在'
             },
+            store_type: {
+                required: '请选择店铺类型'
+            },
             sg_id: {
                 required: '请选择店铺等级'
             },