瀏覽代碼

修改尾款分期中是否一次性付清尾款字段名称

lionared 7 年之前
父節點
當前提交
d67455ee8e

+ 123 - 30
data/model/car.model.php

@@ -8,40 +8,41 @@ class carModel extends Model
 {
     private $_car_id;
 
-    public function car_id()
+    public function __construct()
     {
-        return $this->_car_id;
+        parent::__construct('car_base');
     }
 
-    public function addCar($base_info)
+    public function car_id()
     {
-        if(empty($base_info)) return 0;
-
-        if(isset($base_info['car_name'])) {
-            $car_name = $base_info['car_name'];
-
-            if($this->hasCar_name($car_name)) return 0;
-
-            $insert = $this->table('car')->insert($base_info);
-            $this->_car_id = intval($insert);
-            return $this->_car_id;
-        }
+        return $this->_car_id;
     }
 
-    public function addBodyInfo($car_id, $body_info)
+    public function car_info(array $where)
     {
-        if(empty($body_info)) return 0;
+        if(isset($where['car_id'])) {
+            $this->_car_id = intval($where['car_id']);
+            $base_info = $this->base_info($where);
+            if(!empty($base_info)) {
+                $car_info = array_merge(
+                    $this->base_info($where),$this->air_info($where),$this->body_info($where),$this->brake_info($where),
+                    $this->engine_info($where),$this->gearbox_info($where),$this->glass_info($where),$this->guard_info($where),
+                    $this->inside_info($where),$this->light_info($where),$this->media_info($where),$this->motor_info($where),
+                    $this->oper_info($where),$this->seat_info($where),$this->secure_info($where),$this->underpan_info($where)
+                );
+                return $car_info;
+            } else {
+                return [];
+            }
 
-        if(!$this->hasCar_id($car_id)) return 0;
-
-        $data = array_merge(['car_id'=>$car_id], $body_info);
-        $insert = $this->table('car_body')->insert($data);
-        return $insert;
+        } else {
+            return [];
+        }
     }
 
-    public function hasCar_id($car_id)
+    public function hasCar_name($car_name)
     {
-        $result = $this->getby_car_id($car_id);
+        $result = $this->table('car_base')->getby_car_name($car_name);
         if(!empty($result)) {
             return true;
         }
@@ -50,14 +51,106 @@ class carModel extends Model
         }
     }
 
-    public function hasCar_name($car_name)
+    public function air_info(array $where)
     {
-        $result = $this->getby_car_name($car_name);
-        if(!empty($result)) {
-            return true;
-        }
-        else {
-            return false;
+        return $this->table('car_air')->where($where)->find();
+    }
+
+    public function base_info(array $where)
+    {
+        return $this->table('car_base')->where($where)->find();
+    }
+
+    public function body_info(array $where)
+    {
+        return $this->table('car_body')->where($where)->find();
+    }
+
+    public function brake_info(array $where)
+    {
+        return $this->table('car_brake')->where($where)->find();
+    }
+
+    public function engine_info(array $where)
+    {
+        return $this->table('car_engine')->where($where)->find();
+    }
+
+    public function gearbox_info(array $where)
+    {
+        return $this->table('car_gearbox')->where($where)->find();
+    }
+
+    public function glass_info(array $where)
+    {
+        return $this->table('car_glass')->where($where)->find();
+    }
+
+    public function guard_info(array $where)
+    {
+        return $this->table('car_guard')->where($where)->find();
+    }
+
+    public function inside_info(array $where)
+    {
+        return $this->table('car_inside')->where($where)->find();
+    }
+
+    public function light_info(array $where)
+    {
+        return $this->table('car_light')->where($where)->find();
+    }
+
+    public function media_info(array $where)
+    {
+        return $this->table('car_media')->where($where)->find();
+    }
+
+    public function motor_info(array $where)
+    {
+        return $this->table('car_motor')->where($where)->find();
+    }
+
+    public function oper_info(array $where)
+    {
+        return $this->table('car_oper')->where($where)->find();
+    }
+
+    public function seat_info(array $where)
+    {
+        return $this->table('car_seat')->where($where)->find();
+    }
+
+    public function secure_info(array $where)
+    {
+        return $this->table('car_secure')->where($where)->find();
+    }
+
+    public function underpan_info(array $where)
+    {
+        return $this->table('car_underpan')->where($where)->find();
+    }
+
+    private function addCar(array $base_info, array $body_info, array $air_info, array $brake_info,
+                            array $engine_info, array $gearbox_info, array $glass_info, array $guard_info, array $inside_info,
+                            array $light_info, array $media_info, array $motor_info, array $oper_info, array $seat_info,
+                            array $secure_info, array $underpan_info)
+    {
+        if(empty($base_info)) return 0;
+
+        if(isset($base_info['car_name'])) {
+            $car_name = $base_info['car_name'];
+
+            if($this->hasCar_name($car_name)) return 0;
+
+            $insert = $this->table('car_base')->insert($base_info);
+            if($insert) {
+                $this->_car_id = intval($insert);
+                $body_info['car_id'] = $this->_car_id;
+                $insert_body = $this->table('car_body')->insert($body_info);
+            }
+
+            return $this->_car_id;
         }
     }
 }

+ 59 - 0
helper/model/car_helper.php

@@ -0,0 +1,59 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: lionared
+ * Date: 2018/3/5
+ * Time: 下午8:23
+ */
+
+class car_helper
+{
+    private $_car_id;
+    private $mInfo;
+
+    public function __construct($info)
+    {
+        if(is_array($info) && isset($info['car_id'])) {
+            $this->_car_id = intval($info['car_id']);
+            $this->mInfo = $info;
+        } else {
+            $this->_car_id = intval($info);
+            $this->mInfo = Model('car')->car_info(['car_id'=>$this->_car_id]);
+        }
+    }
+
+    public function fetch_detail_url()
+    {
+        $ver = 1;
+        $file_name = $this->_car_id.".$ver.html";
+        $file_path = BASE_UPLOAD_PATH. DS. "car". DS. $file_name;
+        $url = UPLOAD_SITE_URL. DS. "car". DS. $file_name;
+
+        if(is_file($file_path)) {
+            return $url;
+        }
+
+        $this->generate_html_file($file_path);
+
+        return $url;
+    }
+
+    private function generate_html_file($file_path)
+    {
+        $write_success = false;
+        $tpl_file = "car". DS. "car_info_wap";
+
+        ob_start();
+        Tpl::output('car_helper', $this->mInfo);
+        Tpl::showpage($tpl_file);
+        $html_content = ob_get_contents();
+        ob_clean();
+        $file = fopen($file_path,'w');
+        if($file) {
+            $write_success = fwrite($file, $html_content);
+            fclose($file);
+        }
+
+        return $write_success;
+    }
+}

+ 4 - 0
helper/model/goods_common.php

@@ -10,6 +10,7 @@
 
 require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/user_session/fcode.php');
+require_once (BASE_ROOT_PATH . '/helper/model/car_helper.php');
 
 
 abstract class common_base
@@ -96,6 +97,9 @@ class common_sumary extends common_base
         }
         $ret['goods_plus'] = unserialize($this->common_info['goods_plus']);
 
+        $car_helper = new car_helper($ret['car_id']);
+        $ret['car_detail_url'] = $car_helper->fetch_detail_url();
+
         return $ret;
     }
 }

+ 0 - 9
mobile/car/index.html

@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-</head>
-<body>
-
-</body>
-</html>

+ 61 - 0
mobile/templates/default/car/car_info_wap.php

@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=750,user-scalable=no,target-densitydpi=device-dpi">
+    <meta name="layoutmode" content="standard">
+    <meta name="imagemode" content="force">
+    <meta name="screen-orientation" content="portrait">
+    <meta name="x5-fullscreen" content="true">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title><?php echo $output['car_helper']['car_name']?></title>
+    <link rel="stylesheet" href="css/reset.css">
+    <link rel="stylesheet" href="css/style.css">
+</head>
+
+<body>
+<div class="container">
+    <div class="configuration-content">
+        <div>
+            <div class="group-title">
+                <span class="left-title-info">基本参数</span>
+                <div class="right-title-info">
+            <span class="mr37">
+              <i class="yes-icon mr10"></i>标配</span>
+                    <span class="mr42">
+              <i class="oval-icon mr10"></i>选配</span>
+                    <span>- 无</span>
+                </div>
+            </div>
+            <ul class="pdLR30">
+                <li class="configuration-item">
+                    <span class="left-config-item">最高速度(km/h)</span>
+                    <span class="right-config-item"><?php echo $output['car_helper']['speed']?></span>
+                </li>
+            </ul>
+        </div>
+        <div>
+            <div class="group-title">
+                <span class="left-title-info">车身配置</span>
+                <div class="right-title-info">
+            <span class="mr37">
+              <i class="yes-icon mr10"></i>标配</span>
+                    <span class="mr42">
+              <i class="oval-icon mr10"></i>选配</span>
+                    <span>- 无</span>
+                </div>
+            </div>
+            <ul class="pdLR30">
+                <li class="configuration-item">
+                    <span class="left-config-item">最高速度(km/h)</span>
+                    <span class="right-config-item"><?php echo $output['car_helper']['speed']?></span>
+                </li>
+            </ul>
+        </div>
+    </div>
+
+
+</div>
+</body>
+</html>

+ 9 - 0
test/TestCar.php

@@ -200,4 +200,13 @@ class TestCar extends PHPUnit_Framework_TestCase
         $result = $mod_car->execute("select brand from lrlz_car_base GROUP BY brand");
         var_dump($result);
     }
+
+    public function testCarBaseInfo()
+    {
+        $mod_car = Model('car');
+        $where = ['car_id' => 5767 ];
+        //$result = $mod_car->table('car_base')->where($where)->find();
+        $result = $mod_car->base_info($where);
+        var_dump($result);
+    }
 }