Commit 11dfa27c authored by twj's avatar twj

Merge branch 'dev' of http://rungit.jxdsy.cn:10000/sugar/stock_new into dev

parents b63bea80 c93f3ccd
......@@ -2087,4 +2087,126 @@ if(!function_exists('get_between')) {
$substr = substr($input, strlen($start) + strpos($input, $start), (strlen($input) - strpos($input, $end)) * (-1));
return $substr;
}
//腾讯数据解析
if(!function_exists('jsonQuotation')) {
function jsonQuotation($item) {
$item[0] = isset($item[0])?substr(str_replace('v_','', $item[0]), 0, 2):'';//交易所代号
$item[80] = isset($item[30]) ? strtotime($item[30]) : time();
return $item;
}
}
/*
* 通过API接口获取全部股票列表
*/
if(!function_exists('apiStockList')) {
function apiStockList(){
$url = "http://".LOCAL_STOCK_HOST.":".LOCAL_STOCK_PORT."/api/market/getStockList";
$result = curls($url);
$data = json_decode($result, true);
$json = isset($data['data']) ? $data['data'] : [];
return $json;
}
}
/*
* 获取新浪热门行业
*/
if(!function_exists('getSinahy')) {
function getSinahy(){
$output = curl('https://vip.stock.finance.sina.com.cn/q/view/newSinaHy.php');
if($output){
$findme = '{"';
$pos = strpos($output, $findme) + 2;
$output = substr($output, $pos, -2);
$t2 = explode('","', mb_convert_encoding($output, 'utf-8', 'gbk'));
$res = array();
foreach ($t2 as $k => $v) {
$res[$k] = explode(',', substr(explode(':', $v)[1], 1));
}
return $res ?: false;
}else{
return false;
}
}
}
//新浪股票热门行业分类排行
if(!function_exists('getSinaNodeclass')) {
function getSinaNodeclass($node,$page=1,$num=50){
$url = 'https://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page='.$page.'&num='.$num.'&sort=symbol&asc=1&node='.$node;
$json = curl($url);
$data = json_decode($json, true);
return $data ?: false;
}
}
/*
* 远程访问
*/
if (!function_exists('curls')) {
function curls($url, $data=[]) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Access-Token:' . LOCAL_TRADING_TOKEN,
'Client-Host:' . RedisUtil::getClientHost(),
));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
}
/*
* 通过API接口获取行情
*/
if(!function_exists('getApiStock')) {
/**
* @param $code
* @param string $model
* @return array|mixed
*/
function getApiStock($code, $model='stock'){
//$recData['data'] = ThirdMarket($code,$model);
/**********************腾讯证券网********************/
$recData['data'] = TencentMarkets($code);
//$recData['data'] = east_market($code,$model);
switch ($model) {
case 'stock' ://单个股票
$stockData = isset($recData['data']) ? $recData['data'][0] : [];
break;
case 'stocks' ://多个股票
$stockData = isset($recData['data']) ? $recData['data'] : [];
break;
default :
$stockData = isset($recData['data']) ? $recData['data'][0] : [];
break;
}
return $stockData;
}
}
//腾讯数据获取
if(!function_exists('TencentMarkets')) {
function TencentMarkets($code){
$url = 'https://qt.gtimg.cn/q=' . $code;
//print_r($url);exit;
$output = curl($url);
$str = mb_convert_encoding($output, 'utf-8', 'gbk');
$str = str_replace(array("\r\n", "\r", "\n"), "", $str);
$t2 = explode('";', $str);
$json = [];
foreach ($t2 as $key => $val) {
$array = explode("~", $val);
if(isset($array[2])&&isset($array[3])&&isset($array[4])){
$json[] = jsonQuotation(explode("~", $val));
}else{
continue;
}
}
return $json;
}
}
}
\ No newline at end of file
<?php
// +----------------------------------------------------------------------
// | 常量定义表
// +----------------------------------------------------------------------
// 定义上传目录
define('DS', DIRECTORY_SEPARATOR);
define('UPLOAD_DIR', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'public/uploads');
define('WS_SERVER_IP', (isset($this->request->server()['REMOTE_ADDR']) ? $this->request->server()['REMOTE_ADDR'] : ''));
/**
* 系统常量
* -- TOKEN_EXPIRE_TIME 用户登陆超时时间
* -- SEARCH_CACHE_EXPIRE_TIME 搜索缓存过期时间
* -- LOCAL_STOCK_TIMES 每隔几秒获取一次
* -- LOCAL_STOCK_COUNT 每次获取股票个数
* -- LOCAL_TRADING_TOKEN 行情数据请求TOKEN
* -- LOCAL_STOCK_HOST 行情数据请求地址
* -- LOCAL_STOCK_PORT 行情数据端口
* -- TRUST_ACTIVE_TIME 自动撤单时间,默认10分钟
* -- TRUST_MODEL_TIME............交易模式(T+1:1 ;T+0:0)
*/
define('TOKEN_EXPIRE_TIME', 60*60*24);//600 ------60*60*24=1天
define('SEARCH_CACHE_EXPIRE_TIME', 60*60*24);//1天
define('LOCAL_STOCK_TIMES', 3);//单位:秒
define('LOCAL_STOCK_COUNT', 800);
define('LOCAL_TRADING_TOKEN', 'cRQEEFzjDXASltkjvprHiBOSiNZNtRXP');
define('LOCAL_STOCK_HOST', 'stock.fcv3.1776174838209647.cn-hangzhou.fc.devsapp.net');
define('LOCAL_STOCK_PORT', 80);
define('TRUST_ACTIVE_TIME', 10*60);//默认10分钟
define('TRUST_MODEL_TIME', 1);// T+1:1 ; T+0:0
/**
* 定义Redis服务器常量
* -- REDIS_SERVER_IP 服务器IP地址
* -- REDIS_SERVER_PASSWORD 密码
*/
define('REDIS_SERVER_IP', '127.0.0.1');
define('REDIS_SERVER_PORT', 6379);
/**
* 根据type 获取资金明细的交易类型
*/
define('MONET_TYPE_NAME', [
'1'=>'充值成功',
'2'=>'提现冻结',
'3'=>'提现成功',
'4'=>'提现失败',
'5'=>'撤销提现',
'6'=>'提现退回',
'7'=>'追加保证金',
'8'=>'冻结保证金',
'9'=>'返还保证金',
'10'=>'邀请人推广返佣',
'11'=>'代理商佣金入账',
'12'=>'代理商分成入账',
'13'=>'提取佣金',
'14'=>'提取分成',
'15'=>'终止配资',
'16'=>'配资管理费',
'17'=>'递延费',
'18'=>'后台转账',
'19'=>'管理员操作',
'20'=>'配资结算',
'21'=>'配资审核不通过',
'22'=>'配资审核通过',
'23'=>'申请配资续期',
'24'=>'扩大配资审核通过',
'25'=>'扩大配资审核未通过',
'26'=>'追加保证金审核通过',
'27'=>'追加保证金审核未通过',
'28'=>'配资续期审核通过',
'29'=>'配资续期审核未通过',
'30'=>'配资提前终止审核通过',
'31'=>'配资提前终止审核未通过',
'32'=>'按月配资手续费自动扣款',
'33'=>'冻结金额',
'34'=>'扣除金额',
'80'=>'自动续期系统扣款',
'85'=>'提取盈利'
]);
define('RECORD_TYPE_NAME',[
'1'=>'购买股票扣款',
'2'=>'卖出股票回款',
'3'=>'购买股票扣款',
'4'=>'卖出股票回款',
'5'=>'卖出成功解除冻结',
'6'=>'买入成功解除冻结',
'7'=>'扣费用',
'8'=>'买入撤单解除冻结',
'9'=>'卖出撤单解除冻结',
'10'=>'追加保证金',
'11'=>'扩大配资',
'12'=>'提取盈利',
'13'=>'股票分红',
'14'=>'股票除权',
'15'=>'代扣股票利息税',
]);
This diff is collapsed.
......@@ -47,7 +47,7 @@ class AccountInfo extends ThinkModel
*/
public static function getAccountInfo($id)
{
$data_list = cache('stock_account_info');
$data_list = cache('stock_account_info'.$id);
if (!$data_list) {
$where['id'] =$id;
$lid = Db::name('stock_account')->where($where)->column('lid');
......@@ -59,7 +59,7 @@ class AccountInfo extends ThinkModel
if(!is_null($data_list)){
// 非开发模式,缓存数据
if (config('develop_mode') == 0) {
cache('stock_account_info', $data_list);
cache('stock_account_info'.$id, $data_list);
}
}
}
......
......@@ -398,6 +398,7 @@ class Borrow extends ThinkModel
$start=date('Y-m-d',$dataInfo['verify_time']);
$data['borrow_duration']=$data['borrow_duration']-1;
$end_time=getEndDay($start, $data['borrow_duration'],festival());
break;
default:
if(getEndDay2('now', festival())===1&&time()<mktime(14,45)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment