Browse Source

修改bug

chenbo 4 years ago
parent
commit
82c8cae711
3 changed files with 6 additions and 3 deletions
  1. 2 2
      api/v1.0/index_recent_days.php
  2. 1 1
      lib/input_163.class.php
  3. 3 0
      setting.inc.php

+ 2 - 2
api/v1.0/index_recent_days.php

@@ -36,14 +36,14 @@ try {
     //循环找到最近天数的起始日期
     $count = 0;
     $recent_date = AddOrSubDate($start_date, -$traceback_days);
-    while (($count < $traceback_days) and ($recent_date >= 20140101)) {
+    do {
         $filter = array(
             'code' => array($code, '=s'),
             'date' => array($start_date, 'date_between', $recent_date),
         );
         $count = Index_day_k::getList($filter, 1);
         $recent_date = AddOrSubDate($recent_date, -1);
-    }
+    }while(($count < $traceback_days) and ($recent_date >= AddOrSubDate(GLOBAL_BEGIN_DATE, -1)));
 
     //获取列表
     $stock_info = Index_day_k::getListOrderByDate($filter, 0, 0, 0, $order);

+ 1 - 1
lib/input_163.class.php

@@ -93,7 +93,7 @@ class Input_163
         $indexList = Index::getAllList();
         $end_date = (int)date('Ymd', time());
         $end_year = (int)($end_date / 10000);
-        for($year = 2014; $year < $end_year; $year++) {
+        for($year = GLOBAL_BEGIN_YEAR; $year < $end_year; $year++) {
             foreach($indexList as $item) {
                 self::getPartIndexDayK($item['code'], $year.'0101', $year.'1231');
             }

+ 3 - 0
setting.inc.php

@@ -23,6 +23,9 @@ define("STOCK_SECTOR_HK", 30);              //香港联交所,不分板
 
 define("MAX_SINA_COUNT", 200);          //从新浪接口一次最大获取股票数
 
+define("GLOBAL_BEGIN_DATE", 20140101);
+define("GLOBAL_BEGIN_YEAR", 2014);
+
 //日期格式转换 2021-01-08 转换为数字 20210108
 function ConverseDate($originDate)
 {