瀏覽代碼

修改bug

chenbo 4 年之前
父節點
當前提交
fa74a461d1
共有 4 個文件被更改,包括 25 次插入56 次删除
  1. 7 1
      api/v1.0/index_any_day.php
  2. 18 2
      api/v1.0/index_current_day.php
  3. 0 11
      lib/index_day_k.class.php
  4. 0 42
      lib/table/table_index_day_k.class.php

+ 7 - 1
api/v1.0/index_any_day.php

@@ -23,7 +23,13 @@ try {
     }
     else
     {
-        $stock_info=Index_day_k::get_current_day_index($code,$date);
+        //获取列表
+        $filter = array(
+            'code' => array($code, '=s'),
+            'date' => array($date, '=n'),
+        );
+        $rs = Index_day_k::getList($filter, 0, 0, 0, 0);
+        $stock_info = $rs[0];
         if(!empty($stock_info))
         {
             $params=array();

+ 18 - 2
api/v1.0/index_current_day.php

@@ -9,14 +9,30 @@
 
 try {
     $code = isset($_GET['code'])?safeCheck($_GET['code'],0):'0';
-    $date = isset($_GET['date'])?safeCheck($_GET['date'],1):'0';
 
     if(empty($code))
     {
         echo action_msg("code参数不能为空",101);
         return;
     }
-    $stock_info=Index_day_k::get_current_day_index($code,$date);
+
+    //循环找到最近天数的起始日期
+    $count = 0;
+    $current_date = (int)date('Ymd', time());
+    $recent_date = AddOrSubDate($current_date, -1);
+    do {
+        $filter = array(
+            'code' => array($code, '=s'),
+            'date' => array($current_date, 'date_between', $recent_date),
+        );
+        $count = Index_day_k::getList($filter, 1);
+        $recent_date = AddOrSubDate($recent_date, -1);
+    }while(($count < 1) and ($recent_date >= AddOrSubDate(GLOBAL_BEGIN_DATE, -1)));
+
+    //获取列表
+    $rs = Index_day_k::getListOrderByDate($filter, 0, 0, 0, $order);
+    $stock_info = $rs[0];
+
     if(!empty($stock_info))
     {
         $params=array();

+ 0 - 11
lib/index_day_k.class.php

@@ -85,17 +85,6 @@ class Index_day_k {
     }
 
 
-    /***
-     * @param $code
-     * @param $date
-     * @return array
-     * 获取某天的指数数据和当天的指数数据
-     */
-    static public function get_current_day_index($code,$date)
-    {
-        $Table_index_day_k = new Table_index_day_k();
-        return $Table_index_day_k->get_current_day_index($code,$date);
-    }
 
 
 

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

@@ -55,48 +55,6 @@ class Table_index_day_k extends Table {
     //-------------------------------
 
 
-
-    /***
-     * @param $code
-     * @param $date
-     * @return array
-     * wanggangtao
-     * 获取某天的指数代码
-     */
-    public function get_current_day_index($code,$date)
-    {
-        //查询语句必须用sql_check_input检查参数
-        $stock_code = $this->pdo->sql_check_input(array('string', $code));//类型是字符串,那一定要在条件中将数据使用引号引用起来,否则不使用索引
-        $sql = "select * from ". $this->table_fullname ;
-
-        $where=" where 1=1 ";
-        $where.=" and index_day_k_code=".$stock_code ;
-
-        if($date==0){//获取的是当天的数据,最近一天的交易日的数据
-            $date = date("Ymd",time());
-            $where.=" and index_day_k_date <= ".$date;
-
-        }else{//获取某一天的数据,不是交易日则返回空
-            $date = $this->pdo->sql_check_input(array('number', $date));
-            $where.=" and index_day_k_date =".$date;
-        }
-        $sql.=$where;
-        $order=" order by index_day_k_date desc limit 1 ";
-        $sql.=$order;
-
-        $rs = $this->pdo->sqlQuery($sql);
-        $r  = array();
-        if($rs){
-            foreach($rs as $key => $val){
-
-                $r[$key] = $this->dataToAttr($val);
-            }
-            return $r[0];
-        }else{
-            return $r;
-        }
-    }
-
     /****
      * @param $start_date
      * @param $end_date