wanggangtao 5 yıl önce
ebeveyn
işleme
830af36841

+ 61 - 0
lib/day_k.class.php

@@ -0,0 +1,61 @@
+<?php
+
+
+/**
+ * Class Day_k_base
+ * @author		王刚涛
+ * 日线数据
+ */
+class Day_k_base {
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getInfoById($id)
+    {
+        $Table_day_k_base = new Table_day_k_base();
+        return $Table_day_k_base->getInfoById($id);
+    }
+
+
+    static public function add($attrs,$date=0)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        if($date===0)
+        {
+            $date=strtotime(date('Ym'));
+        }
+        $Table_day_k_base = new Table_day_k_base($date);
+        return $Table_day_k_base->add($attrs);
+
+    }
+
+    static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
+    {
+        $Table_day_k_base = new Table_day_k_base();
+        return $Table_day_k_base->getList($filter, $count, $page, $pageSize);
+    }
+
+    /***
+     * @param $attrs
+     * @param int $date
+     * @return mixed
+     * @throws Exception
+     * 添加某一直股票的历史数据
+     */
+    static public function insert($attrs,$date=0)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        if($date===0)
+        {
+            $date=strtotime(date('Ymd'));
+        }
+        $Table_day_k_base = new Table_day_k_base($date);
+        $id = $Table_day_k_base->insert($attrs);
+        return $id;
+    }
+
+}
+?>

+ 61 - 0
lib/day_k_qfq.class.php

@@ -0,0 +1,61 @@
+<?php
+
+
+/**
+ * Class Day_k_base
+ * @author		王刚涛
+ * 日线数据
+ */
+class Day_k_base {
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getInfoById($id)
+    {
+        $Table_day_k_base = new Table_day_k_base();
+        return $Table_day_k_base->getInfoById($id);
+    }
+
+
+    static public function add($attrs,$date=0)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        if($date===0)
+        {
+            $date=strtotime(date('Ym'));
+        }
+        $Table_day_k_base = new Table_day_k_base($date);
+        return $Table_day_k_base->add($attrs);
+
+    }
+
+    static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
+    {
+        $Table_day_k_base = new Table_day_k_base();
+        return $Table_day_k_base->getList($filter, $count, $page, $pageSize);
+    }
+
+    /***
+     * @param $attrs
+     * @param int $date
+     * @return mixed
+     * @throws Exception
+     * 添加某一直股票的历史数据
+     */
+    static public function insert($attrs,$date=0)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        if($date===0)
+        {
+            $date=strtotime(date('Ymd'));
+        }
+        $Table_day_k_base = new Table_day_k_base($date);
+        $id = $Table_day_k_base->insert($attrs);
+        return $id;
+    }
+
+}
+?>

+ 61 - 0
lib/immediate_base.class.php

@@ -0,0 +1,61 @@
+<?php
+
+
+/**
+ * Class Day_k_base
+ * @author		王刚涛
+ * 日线数据
+ */
+class Immediate_base {
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getInfoById($id)
+    {
+        $Table_day_k_base = new Table_day_k_base();
+        return $Table_day_k_base->getInfoById($id);
+    }
+
+
+    static public function add($attrs,$date=0)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        if($date===0)
+        {
+            $date=strtotime(date('Ym'));
+        }
+        $Table_day_k_base = new Table_day_k_base($date);
+        return $Table_day_k_base->add($attrs);
+
+    }
+
+    static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
+    {
+        $Table_day_k_base = new Table_day_k_base();
+        return $Table_day_k_base->getList($filter, $count, $page, $pageSize);
+    }
+
+    /***
+     * @param $attrs
+     * @param int $date
+     * @return mixed
+     * @throws Exception
+     * 添加某一直股票的历史数据
+     */
+    static public function insert($attrs,$date=0)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        if($date===0)
+        {
+            $date=strtotime(date('Ymd'));
+        }
+        $Table_day_k_base = new Table_day_k_base($date);
+        $id = $Table_day_k_base->insert($attrs);
+        return $id;
+    }
+
+}
+?>

+ 58 - 0
lib/index.class.php

@@ -0,0 +1,58 @@
+<?php
+
+/***
+ * Class Index_sh50
+ *  * @author		王刚涛
+ * 日线数据
+ */
+
+class Index {
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getIndexList()
+    {
+        $Table_index = new Table_index();
+        return $Table_index->getIndexList();
+    }
+
+    /**
+     * @return mixed
+     * 各种指数入库
+     */
+    static public function get_index($code,$exchange)
+    {
+        $Table_index = new Table_index();
+        return $Table_index->get_index($code,$exchange);
+    }
+
+
+
+
+
+    static public function getInfoById($id)
+    {
+        $Table_index = new Table_index();
+        return $Table_index->getInfoById($id);
+    }
+    static public function insert($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index = new Table_index();
+        $id = $Table_index->insert($attrs);
+        return $id;
+    }
+
+    static public function add($attrs){
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index = new Table_index();
+        $id = $Table_index->add($attrs);
+        return $id;
+    }
+
+
+}
+?>

+ 56 - 0
lib/index_day_k.class.php

@@ -0,0 +1,56 @@
+<?php
+
+
+/**
+ * Class Day_k_base
+ * @author		王刚涛
+ * 日线数据
+ */
+class Index_day_k {
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getInfoById($id)
+    {
+        $Table_index_day_k = new Table_index_day_k();
+        return $Table_index_day_k->getInfoById($id);
+    }
+
+
+    static public function add($attrs){
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        $Table_index_day_k = new Table_index_day_k();
+        $id = $Table_index_day_k->add($attrs);
+        return $id;
+    }
+
+    static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
+    {
+        $Table_index_day_k = new Table_index_day_k();
+        return $Table_index_day_k->getList($filter, $count, $page, $pageSize);
+    }
+
+    /***
+     * @param $attrs
+     * @param int $date
+     * @return mixed
+     * @throws Exception
+     * 添加某一直股票的历史数据
+     */
+    static public function insert($attrs,$date=0)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 102);
+        if($date===0)
+        {
+            $date=strtotime(date('Ymd'));
+        }
+        $Table_index_day_k = new Table_index_day_k($date);
+        $id = $Table_index_day_k->insert($attrs);
+        return $id;
+    }
+
+}
+?>

+ 109 - 0
lib/inputSinaIndex.class.php

@@ -0,0 +1,109 @@
+<?php
+/**
+ * @author:王刚涛
+ * 用于获取当天各种指数
+ * http://hq.sinajs.cn/list=s_sz000002
+ */
+
+
+class InputSinaIndex
+{
+
+
+    /***
+     * @param $code
+     * @param $exchange
+     * @return mixed
+     * 获取股票信息
+     */
+    static public function get_day_k_index($code,$exchange)
+    {
+        $stockCode=$exchange.$code;
+        $url = "http://hq.sinajs.cn/list=".$stockCode;
+        $content3=self::curl_get_data($url);
+        $data['increase_ratio'] = floatval($content3[3]);//涨跌率
+        $data2=self::get_info_code($code);//调用另一个函数获取其他数据如开盘价等等
+        $data['increase_price']  = floatval($data2[3]-$data2[2]);//涨跌
+        // 涨跌价-当日股票最新价与前一日收盘价格(或前一日收盘指数)
+        $data['date'] = strtotime(date('Y-m-d',time()));//当天的0点时间戳
+        $data['code'] = $code;//开盘价
+        $data['name'] = $data2[0];//股票名称
+        $data['open_price'] = floatval($data2[1]);//开盘价
+        $data['close_price'] = floatval($data2[3]);//3点之后的当前价格就是收盘价
+        $data['hightest_price'] = floatval($data2[4]);//今日最高价
+        $data['lowest_price'] = floatval($data2[5]);//今日最低价
+        $data['amount'] =  (int)($data2[8]);//成交的股票数,以百为单位
+        $data['value'] = (int)($data2[9]);//成交金额以万为单位
+        return  Index_day_k::add($data);
+    }
+
+    /****
+     * @param $code
+     * @return string
+     * 判断股票的类型,属于创业板,科创板,主板,$code
+     */
+    static public function get_boniu_block($code)
+    {
+        if (strncmp($code, "30", 2) == 0) {
+            //创业板
+            $stockCode= "sz". $code;
+        } else if (strncmp($code, "68", 2) == 0) {
+            //科创板
+            $stockCode= "sh" .$code;
+        } else if (strncmp($code, "60", 2) == 0) {
+            //主板
+            $stockCode = "sh".$code;
+        } else if (strncmp($code, "00", 2) == 0) {
+            //中小板
+            $stockCode= "sh".$code;
+        }else if (strncmp($code, "39", 2) == 0) {
+            //中小板
+            $stockCode= "sz".$code;
+        }
+        return $stockCode;
+
+    }
+
+    /***
+     * @param $code
+     * @param $date
+     * 根据股票代码获取股票的实时信息
+     */
+    static public function get_info_code($code){
+
+        $stock_code= self::get_boniu_block($code);
+        $url = "http://hq.sinajs.cn/list=" . $stock_code;
+        $stockInfo=self::curl_get_data($url);//封装为函数,执行url获取结果并解析
+        return $stockInfo;
+    }
+
+
+    /****
+     * @param $url
+     * @return array|bool|string
+     * 对curl_setopt进行封装,消除代码冗余
+     */
+    static private function curl_get_data($url){
+        $curlHandle = curl_init();
+        curl_setopt($curlHandle, CURLOPT_URL, $url);
+        curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($curlHandle, CURLOPT_SSL_VERIFYHOST, false);
+        curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10);
+        $content = curl_exec($curlHandle);
+        curl_close($curlHandle);//防止中文乱码
+        $content2 = iconv("gbk", "utf-8", $content);//子串
+        $content3 = substr($content2, stripos($content2, "=\"") + 2); //获取 var hq_str_sz000002="万 科A,30.780,30.800,30.510,  ="之后部分
+        $content4 = substr($content3, 0, strripos($content3, "\";")); //获取     万 科A,30.94,0.14,0.45,584039,178827";         ";之前部分
+        $content5 = explode(",", $content4);//分割
+        return $content5;
+    }
+
+
+
+
+
+
+}
+
+?>

+ 1 - 0
lib/inputSinaSimple.class.php

@@ -55,6 +55,7 @@ class InputSinaSimple
             $codeIndex++;
         }
         $contentList = self::curl_get_data($url, $codeList);
+//        var_dump($contentList);
         foreach ($contentList as $key => $item) {
             $data['code'] = $item['code'];
             $data['name'] = trim($item[0]);

+ 39 - 0
lib/st_log.class.php

@@ -0,0 +1,39 @@
+<?php
+
+/***
+ * Class St_log
+ *  * @author		王刚涛
+ * 日线数据
+ */
+
+class St_log {
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getInfoById($id)
+    {
+        $Table_st_log = new Table_st_log();
+        return $Table_st_log->getInfoById($id);
+    }
+
+
+    static public function add($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 101);
+
+        $Table_st_log = new Table_st_log();
+        $id = $Table_st_log->add($attrs);
+
+        return $id;
+    }
+
+    static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
+    {
+        $Table_st_log = new Table_st_log();
+        return $Table_st_log->getList($filter, $count, $page, $pageSize);
+    }
+}
+?>

+ 15 - 1
lib/stock.class.php

@@ -8,12 +8,26 @@
 
 class Stock {
 
+
+    static public function getStockCodeList($id)
+    {
+        $Table_stock = new Table_stock();
+        return $Table_stock->getStockCodeList($id);
+    }
+
     static public function getInfoById($id)
     {
         $Table_stock = new Table_stock();
         return $Table_stock->getInfoById($id);
     }
 
+    static public function getInfoByCode($code)
+    {
+        $Table_stock = new Table_stock();
+        return $Table_stock->getInfoByCode($code);
+    }
+
+
     static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
     {
         $Table_stock = new Table_stock();
@@ -23,9 +37,9 @@ class Stock {
     static public function addOrUpdateByCode($attrs)
     {
         if (empty($attrs)) throw new Exception('参数不能为空', 101);
-
         $Table_stock = new Table_stock();
         $rs = $Table_stock->getInfoByCode($attrs['code']);
+
         if (empty($rs)) {
             $id = $Table_stock->add($attrs);
         } else {

+ 122 - 0
lib/table/table_day_k.class.php

@@ -0,0 +1,122 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 14:51
+ */
+
+class Table_day_k_base extends Table {
+
+    protected $base  = "";              //分表的后缀日期,在进行数据库操作的时候"Table_day_k_".$base
+    protected $table_name       = "day_k_";//表名,不带前缀,前缀在config中定义
+    protected $table_id         = "day_k_id";//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
+    protected $table_fullname    = "day_k_";//拼接好后表名  后面拼接日期  day_k_202011
+
+	//数据库结构
+	protected function struct(){
+		$attr = array();
+		$attr['id']                 = 'day_k_id';
+		$attr['date']               = 'day_k_date';
+		$attr['code']               = 'day_k_code';
+        $attr['name']               = 'day_k_name';
+        $attr['open_price']         = 'day_k_open_price';
+        $attr['close_price']        = 'day_k_close_price';
+        $attr['hightest_price']     = 'day_k_hightest_price';
+        $attr['lowest_price']       = 'day_k_lowest_price';
+        $attr['increase_price']     = 'day_k_increase_price';
+        $attr['increase_value']     = 'day_k_increase_value';
+        $attr['turnover']           = 'day_k_turnover';
+        $attr['amount']             = 'day_k_amount';
+        $attr['value']              = 'day_k_value';
+        $attr['open_price_qfq']     = 'day_k_open_price_qfq';
+        $attr['close_price_qfq']    = 'day_k_close_price_qfq';
+        $attr['hightest_price_qfq'] = 'day_k_hightest_price_qfq';
+        $attr['lowest_price_qfq']   = 'day_k_lowest_price_qfq';
+        $attr['m10']                = 'day_k_m10';
+        $attr['m20']                = 'day_k_m20';
+        $attr['m60']                = 'day_k_m60';
+        $attr['kdj']                = 'day_k_kdj';
+        $attr['macd']               = 'day_k_macd';
+        $attr['rsi']                = 'day_k_rsi';
+		return $attr;
+	}
+
+    /***
+     * Table_day_k_base constructor.
+     * 构造函数,动态获取表的后缀年月
+     * 王刚涛
+     */
+    public function __construct($date) {
+        parent::__construct();
+        $this->table_name .= $date;//表名不代前缀
+        $this->table_fullname .= $date;//表名代前缀
+        $this ->createBaseTable();
+    }
+
+    /****
+     *在构造函数中调用该函数,自动创建表
+     * 王刚涛
+     */
+     public function createBaseTable(){
+         global $mypdo;
+         $sql = " CREATE TABLE IF NOT EXISTS `". $this->table_fullname."` LIKE  boniu_day_k_base";
+         $mypdo->pdo->exec($sql);
+     }
+
+    /****
+     * @param $attr
+     * @return mixed
+     * 王刚涛
+     */
+    public function add($attr){
+        $param = array (
+             'day_k_date'    => array('number', strtotime($attr['date'])),
+             'day_k_code'    => array('number', $attr['code']),
+             'day_k_name'    => array('string', $attr['name']),
+            'day_k_open_price'    => array('number', $attr['open_price']),
+             'day_k_close_price'    => array('number', $attr['close_price']),
+            'day_k_hightest_price'    => array('number', $attr['hightest_price']),
+             'day_k_lowest_price'    => array('number', $attr['lowest_price']),
+             'day_k_amount'    => array('number', $attr['amount']),
+             'day_k_value'    => array('number', $attr['value']),
+            'day_k_close_price_qfq'    => array('number', $attr['close_price_qfq']),
+            'day_k_increase_price'    => array('number', $attr['increase_price']),
+            'day_k_increase_value'    => array('number', $attr['increase_value']),
+            'day_k_turnover'    => array('number', $attr['turnover']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+
+    /****
+     * @param $attr
+     * @return mixed
+     *
+     */
+    public function insert($attr){
+        $param = array (
+            'day_k_date'    => array('number', strtotime($attr['date'])),
+            'day_k_code'    => array('number', $attr['code']),
+            'day_k_name'    => array('string', $attr['name']),
+            'day_k_open_price'    => array('number', $attr['open_price']),
+            'day_k_hightest_price'    => array('number', $attr['hightest_price']),
+            'day_k_lowest_price'    => array('number', $attr['lowest_price']),
+            'day_k_value'    => array('number', $attr['value']),
+            'day_k_amount'    => array('number', $attr['amount']),
+            'day_k_close_price'    => array('number', $attr['close_price']),
+            'day_k_close_price_qfq'    => array('number', $attr['close_price_qfq']),
+            'day_k_increase_price'    => array('number', $attr['increase_price']),
+            'day_k_increase_value'    => array('number', $attr['increase_value']),
+            'day_k_turnover'    => array('number', $attr['turnover']),
+
+        );
+        $msg=$this->pdo->sqlinsert($this->table_fullname, $param);
+        return $msg;
+    }
+
+}
+?>

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

@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * 数据库表:管理员组
+ *
+ * @createtime	2018/03/01
+ * @author		空竹
+ * @copyright	芝麻开发(http://www.zhimawork.com)
+ */
+
+class Table_day_k_qfq extends Table {
+
+	protected $table_name       = 'day_k_qfq';//表名,不带前缀,前缀在config中定义
+    protected $table_id         = 'day_k_qfq_id';//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
+	//数据库结构
+	protected function struct(){
+        $attr['id']                 = 'day_k_qfq_id';
+        $attr['date']               = 'day_k_qfq_date';
+        $attr['code']               = 'day_k_qfq_code';
+        $attr['name']               = 'day_k_qfq_name';
+        $attr['open_price']         = 'day_k_qfq_open_price';
+        $attr['close_price']        = 'day_k_qfq_close_price';
+        $attr['hightest_price']     = 'day_k_qfq_hightest_price';
+        $attr['lowest_price']       = 'day_k_qfq_lowest_price';
+        $attr['turnover']           = 'day_k_qfq_turnover';
+        $attr['amount']             = 'day_k_qfq_amount';
+		return $attr;
+	}
+
+    public function add($attr){
+        $param = array (
+
+             'admingroup_name'    => array('string', $attr['name'])
+
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+}
+?>

+ 123 - 0
lib/table/table_immediate_base.class.php

@@ -0,0 +1,123 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 14:51
+ */
+
+class Table_immediate_base extends Table {
+
+    protected $base  = "";              //分表的后缀日期,在进行数据库操作的时候"Table_day_k_".$base
+    protected $table_name       = "immediate_";//表名,不带前缀,前缀在config中定义
+    protected $table_id         = "immediate_id";//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
+    protected $table_fullname    = "immediate_";//拼接好后表名  后面拼接日期  day_k_202011
+
+	//数据库结构
+	protected function struct(){
+		$attr = array();
+		$attr['id']                 = 'immediate_id';
+		$attr['date']               = 'immediate_date';
+		$attr['code']               = 'immediate_code';
+        $attr['name']               = 'immediate_name';
+        $attr['open_price']         = 'immediate_open_price';
+        $attr['close_price']        = 'immediate_close_price';
+        $attr['hightest_price']     = 'immediate_hightest_price';
+        $attr['lowest_price']       = 'immediate_lowest_price';
+        $attr['increase_price']     = 'immediate_increase_price';
+        $attr['increase_value']     = 'immediate_increase_value';
+        $attr['turnover']           = 'immediate_turnover';
+        $attr['amount']             = 'immediate_amount';
+        $attr['value']              = 'immediate_value';
+        $attr['tradable_amount']    = 'immediate_tradable_amount';
+        $attr['tradable_value']     = 'immediate_tradable_value';
+        $attr['total_amount']       = 'immediate_total_amount';
+        $attr['total_value']        = 'immediate_total_value';
+        $attr['profitable']         = 'immediate_profitable';
+        $attr['pb']                 = 'immediate_pb';
+        $attr['pe_static']          = 'immediate_pe_static';
+        $attr['pe_dynamic']         = 'immediate_pe_dynamic';
+        $attr['pe_ttm']             = 'immediate_pe_ttm';
+
+
+		return $attr;
+	}
+
+    /***
+     * Table_day_k_base constructor.
+     * 构造函数,动态获取表的后缀年月
+     * 王刚涛
+     */
+    public function __construct($date) {
+        parent::__construct();
+        $this->table_name .= $date;//表名不代前缀
+        $this->table_fullname .= $date;//表名代前缀
+        $this ->createBaseTable();
+    }
+
+    /****
+     *在构造函数中调用该函数,自动创建表
+     * 王刚涛
+     */
+     public function createBaseTable(){
+         global $mypdo;
+         $sql = " CREATE TABLE IF NOT EXISTS `". $this->table_fullname."` LIKE  boniu_day_k_base";
+         $mypdo->pdo->exec($sql);
+     }
+
+    /****
+     * @param $attr
+     * @return mixed
+     * 王刚涛
+     */
+    public function add($attr){
+        $param = array (
+             'day_k_date'    => array('number', strtotime($attr['date'])),
+             'day_k_code'    => array('number', $attr['code']),
+             'day_k_name'    => array('string', $attr['name']),
+            'day_k_open_price'    => array('number', $attr['open_price']),
+             'day_k_close_price'    => array('number', $attr['close_price']),
+            'day_k_hightest_price'    => array('number', $attr['hightest_price']),
+             'day_k_lowest_price'    => array('number', $attr['lowest_price']),
+             'day_k_amount'    => array('number', $attr['amount']),
+             'day_k_value'    => array('number', $attr['value']),
+            'day_k_close_price_qfq'    => array('number', $attr['close_price_qfq']),
+            'day_k_increase_price'    => array('number', $attr['increase_price']),
+            'day_k_increase_value'    => array('number', $attr['increase_value']),
+            'day_k_turnover'    => array('number', $attr['turnover']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+
+    /****
+     * @param $attr
+     * @return mixed
+     *
+     */
+    public function insert($attr){
+        $param = array (
+            'day_k_date'    => array('number', strtotime($attr['date'])),
+            'day_k_code'    => array('number', $attr['code']),
+            'day_k_name'    => array('string', $attr['name']),
+            'day_k_open_price'    => array('number', $attr['open_price']),
+            'day_k_hightest_price'    => array('number', $attr['hightest_price']),
+            'day_k_lowest_price'    => array('number', $attr['lowest_price']),
+            'day_k_value'    => array('number', $attr['value']),
+            'day_k_amount'    => array('number', $attr['amount']),
+            'day_k_close_price'    => array('number', $attr['close_price']),
+            'day_k_close_price_qfq'    => array('number', $attr['close_price_qfq']),
+            'day_k_increase_price'    => array('number', $attr['increase_price']),
+            'day_k_increase_value'    => array('number', $attr['increase_value']),
+            'day_k_turnover'    => array('number', $attr['turnover']),
+
+        );
+        $msg=$this->pdo->sqlinsert($this->table_fullname, $param);
+        return $msg;
+    }
+
+}
+?>

+ 65 - 0
lib/table/table_index.class.php

@@ -0,0 +1,65 @@
+<?php
+
+/**
+ * 数据库表:管理员组
+ *
+ * @createtime	2018/03/01
+ * @author		空竹
+ * @copyright	芝麻开发(http://www.zhimawork.com)
+ */
+
+class Table_index extends Table {
+
+	protected $table_name       = 'index';//表名,不带前缀,前缀在config中定义
+    protected $table_id         = 'index_id';//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
+	//数据库结构
+	protected function struct(){
+		$attr = array();
+		
+		$attr['id']           = 'index_id';
+		$attr['code']         = 'index_code';
+		$attr['name']         = 'index_name';
+		$attr['exchange']        = 'index_exchange';
+        $attr['sector']           = 'index_sector';
+		return $attr;
+	}
+
+
+    public function add($attr){
+        $param = array (
+            'index_date'    => array('number', $attr['date']),
+            'index_open_price'    => array('number', $attr['open_price']),
+            'index_close_price'    => array('number', $attr['close_price']),
+            'index_hightest_price'    => array('number', $attr['hightest_price']),
+            'index_lowest_price'    => array('number', $attr['lowest_price']),
+            'index_increase_value'    => array('number', $attr['increase_value']),
+            'index_increase_price'    => array('number', $attr['increase_price']),
+            'index_amount'    => array('number', $attr['amount']),
+            'index_value'    => array('number', $attr['value']),
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+    public function getIndexList(){
+
+        $where="where 1=1";
+        $sql = "select "."`*`". "from ". $this->table_fullname ." $where order by ".$this->table_id." 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;
+        }
+    }
+
+
+
+
+}
+?>

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

@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 14:51
+ */
+
+class Table_index_day_k extends Table {
+
+    protected $base  = "";              //分表的后缀日期,在进行数据库操作的时候"Table_day_k_".$base
+    protected $table_name       = "index_day_k";//表名,不带前缀,前缀在config中定义
+    protected $table_id         = "index_day_k_id";//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
+
+	//数据库结构
+	protected function struct(){
+		$attr = array();
+		$attr['id']                 = 'index_day_k_id';
+		$attr['date']               = 'index_day_k_date';
+		$attr['code']               = 'index_day_k_code';
+        $attr['name']               = 'index_day_k_name';
+        $attr['open_price']         = 'index_day_k_open_price';
+        $attr['close_price']        = 'index_day_k_close_price';
+        $attr['hightest_price']     = 'index_day_k_hightest_price';
+        $attr['lowest_price']       = 'index_day_k_lowest_price';
+        $attr['increase_price']     = 'index_day_k_increase_price';
+        $attr['increase_value']     = 'index_day_k_increase_value';
+        $attr['turnover']           = 'index_day_k_turnover';
+        $attr['amount']             = 'index_day_k_amount';
+        $attr['value']              = 'index_day_k_value';
+
+		return $attr;
+	}
+
+
+
+    public function add($attr){
+        $param = array (
+            'index_day_k_date'    => array('number', $attr['date']),
+            'index_day_k_code'    => array('string', $attr['code']),
+            'index_day_k_name'    => array('string', $attr['name']),
+            'index_day_k_open_price'    => array('number', $attr['open_price']),
+            'index_day_k_close_price'    => array('number', $attr['close_price']),
+            'index_day_k_hightest_price'    => array('number', $attr['hightest_price']),
+            'index_day_k_lowest_price'    => array('number', $attr['lowest_price']),
+            'index_day_k_increase_price'    => array('number', $attr['increase_price']),
+            'index_day_k_increase_ratio'    => array('number', $attr['increase_ratio']),
+            'index_day_k_amount'    => array('number', $attr['amount']),
+            'index_day_k_value'    => array('number', $attr['value']),        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+}
+?>

+ 38 - 0
lib/table/table_st_log.class.php

@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * 数据库表:管理员组
+ *
+ * @createtime	2018/03/01
+ * @author		空竹
+ * @copyright	芝麻开发(http://www.zhimawork.com)
+ */
+
+class Table_st_log extends Table {
+
+	protected $table_name       = 'st_log';//表名,不带前缀,前缀在config中定义
+    protected $table_id         = 'st_log_id';//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
+	//数据库结构
+	protected function struct(){
+		$attr = array();
+		$attr['id']                 = 'st_log_id';
+		$attr['date']               = 'st_log_date';
+		$attr['open_price']         = 'st_log_code';
+		$attr['close_price']        = 'st_log_pretype';
+        $attr['tradable_amount']    = 'st_log_ posttype';
+		return $attr;
+	}
+
+    public function add($attr){
+        $param = array (
+
+             'admingroup_name'    => array('string', $attr['name'])
+
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+}
+?>

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

@@ -34,10 +34,36 @@ class Table_stock extends Table {
             'stock_exchange'        => array('string', $attr['exchange']),
             'stock_sector'          => array('number', $attr['sector']),
         );
-
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }
 
+
+    /***
+     * @param array $filter
+     * @param int $count
+     * @param int $page
+     * @param int $pagesize
+     * @return array
+     * 获取代码列表
+     * 王刚涛
+     */
+    public function getStockCodeList(){
+
+        $where="where 1=1";
+        $sql = "select "."`stock_code`". "from ". $this->table_fullname ." $where order by ".$this->table_id." asc";
+        $rs  = $this->pdo->sqlQuery($sql);
+        $r  = array();
+        if($rs){
+            foreach($rs as $key => $val){
+                $r[$key] =$val["stock_code"];
+            }
+            return $r;
+        }else{
+            return $r;
+        }
+    }
+
+
     public function getInfoByCode($code){
 
         //查询语句必须用sql_check_input检查参数

+ 41 - 0
lib/table/table_xrxd_log.class.php

@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * 数据库表:管理员组
+ *
+ * @createtime	2018/03/01
+ * @author		空竹
+ * @copyright	芝麻开发(http://www.zhimawork.com)
+ */
+
+class Table_xrxd_log extends Table {
+
+	protected $table_name       = 'xrxd_log';//表名,不带前缀,前缀在config中定义
+    protected $table_id         = 'xrxd_log_id';//指定ID字段名称,必须
+    protected $table_status     = '';//指定状态字段名称,如果有
+    protected $table_order      = '';//指定排序字段名称,如果有
+	//数据库结构
+	protected function struct(){
+		$attr = array();
+		$attr['id']                 = 'xrxd_log_id';
+		$attr['date']               = 'xrxd_log_date';
+		$attr['code']         = 'xrxd_log_code';
+		$attr['type']        = 'xrxd_log_type';
+        $attr['multiple']    = 'xrxd_log_multiple';
+        $attr['subprice']        = 'xrxd_log_subprice';
+        $attr['oldprice']    = 'xrxd_log_oldprice';
+        $attr['newprice']        = 'xrxd_log_newprice';
+		return $attr;
+	}
+
+    public function add($attr){
+        $param = array (
+
+             'admingroup_name'    => array('string', $attr['name'])
+
+        );
+        return $this->pdo->sqlinsert($this->table_fullname, $param);
+    }
+
+}
+?>

+ 39 - 0
lib/xrxd_log.class.php

@@ -0,0 +1,39 @@
+<?php
+
+/***
+ * Class Xrxd_log
+ *  * @author		王刚涛
+ * 日线数据
+ */
+
+class Xrxd_log {
+
+    public function __construct()
+    {
+
+    }
+
+    static public function getInfoById($id)
+    {
+        $Table_xrxd_log = new Table_xrxd_log();
+        return $Table_xrxd_log->getInfoById($id);
+    }
+
+
+    static public function add($attrs)
+    {
+        if (empty($attrs)) throw new Exception('参数不能为空', 101);
+
+        $Table_xrxd_log = new Table_xrxd_log();
+        $id = $Table_xrxd_log->add($attrs);
+
+        return $id;
+    }
+
+    static public function getList($filter = array(), $count=0, $page=0, $pageSize=0)
+    {
+        $Table_xrxd_log = new Table_xrxd_log();
+        return $Table_xrxd_log->getList($filter, $count, $page, $pageSize);
+    }
+}
+?>

+ 15 - 0
task/task_get_day_k_index.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/12/1
+ * Time: 19:35
+ */
+require('../init.php');
+$indexList=Index::getIndexList();//获取指数代码
+foreach ($indexList as $key=>$value){
+    inputSinaIndex::get_day_k_index($value["code"],$value["exchange"]);
+}
+
+
+?>