wanggangtao пре 5 година
родитељ
комит
a875533d72

+ 2 - 2
api/v1.0/demo/index_recent_days.html

@@ -76,12 +76,12 @@
 
             <p>
                 <span>code:</span>
-                <input type="text" class="input-text"  name="code" value="600004"/>
+                <input type="text" class="input-text"  name="code" value="399300" />
             </p>
 
             <p>
                 <span>start_date:</span>
-                <input type="text" class="input-text"  name="start_date" value="2020/11/01"/>
+                <input type="text" class="input-text"  name="start_date" value=20201101 />
             </p>
 
             <p>

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
api/v1.0/index_recent_days.php


Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
api/v1.0/stock_list.php


+ 19 - 0
lib/index_day_k.class.php

@@ -13,6 +13,25 @@ class Index_day_k {
 
     }
 
+    /***
+     * @param $code
+     * @param $start_date
+     * @param $traceback_days
+     * @param $order
+     * @return mixed
+     * wanggangtao
+     * 指数最近n天的数据
+     */
+    static public function index_recent_days($code,$start_date,$traceback_days,$order)
+    {
+        $Table_index_day_k = new Table_index_day_k();
+        return $Table_index_day_k->index_recent_days($code,$start_date,$traceback_days,$order);
+    }
+
+
+
+
+
     static public function getInfoById($id)
     {
         $Table_index_day_k = new Table_index_day_k();

+ 32 - 0
lib/table/table_index_day_k.class.php

@@ -32,6 +32,38 @@ class Table_index_day_k extends Table {
 		return $attr;
 	}
 
+
+
+    public function index_recent_days($code,$start_date,$traceback_days,$order)
+    {
+        //查询语句必须用sql_check_input检查参数
+        $stock_code = $this->pdo->sql_check_input(array('string', $code));//类型是字符串,那一定要在条件中将数据使用引号引用起来,否则不使用索引
+        $sql = "select * from ". $this->table_fullname ." where 1=1 ";
+        $where =" and index_day_k_code=".$stock_code." and index_day_k_date <=".$start_date  ;
+        $sql.=$where;
+        $orderInfo=" ORDER BY index_day_k_date desc";
+        $sql.=$orderInfo;
+        $limit=" limit ".$traceback_days;
+        $sql.=$limit;
+        if($order==1){
+            $sql=   " SELECT a.* FROM "."($sql) a ORDER BY a.index_day_k_date desc ";
+
+        }else{
+            $sql=   " SELECT a.* FROM "."($sql) a ORDER BY a.index_day_k_date asc";
+        }
+        $rs = $this->pdo->sqlQuery($sql);
+        $r  = array();
+        if($rs){
+            foreach($rs as $key => $val){
+
+                $r[$key] = $this->dataToAttr($val);
+            }
+            return $r;
+        }else{
+            return $r;
+        }
+    }
+
     /***
      * @param $code
      * @param $date

+ 4 - 1
lib/table/table_stock.class.php

@@ -66,7 +66,10 @@ class Table_stock extends Table {
 
     public function getStockList($filter = array(), $count = 0, $page = 0, $pagesize = 0){
 
-        $where = $this->filterToWhere($filter);
+        $where=" ";
+        if(!empty($filter["sector"])){
+            $where = $this->filterToWhere($filter);
+        }
         if($count == 0){//列表
             $sql = "select * from ". $this->table_fullname ." $where order by ".$this->table_id." desc";