Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
stock_new
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sugar
stock_new
Commits
11dfa27c
Commit
11dfa27c
authored
Jun 19, 2024
by
twj
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://rungit.jxdsy.cn:10000/sugar/stock_new
into dev
parents
b63bea80
c93f3ccd
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
498 additions
and
2 deletions
+498
-2
application/common.php
application/common.php
+122
-0
application/define.php
application/define.php
+96
-0
application/market/home/Trade.php
application/market/home/Trade.php
+0
-0
application/market/model/StockPosition.php
application/market/model/StockPosition.php
+277
-0
application/stock/model/AccountInfo.php
application/stock/model/AccountInfo.php
+2
-2
application/stock/model/Borrow.php
application/stock/model/Borrow.php
+1
-0
No files found.
application/common.php
View file @
11dfa27c
...
...
@@ -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
application/define.php
0 → 100644
View file @
11dfa27c
<?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'
=>
'代扣股票利息税'
,
]);
application/market/home/Trade.php
View file @
11dfa27c
No preview for this file type
application/market/model/StockPosition.php
0 → 100644
View file @
11dfa27c
This diff is collapsed.
Click to expand it.
application/stock/model/AccountInfo.php
View file @
11dfa27c
...
...
@@ -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
);
}
}
}
...
...
application/stock/model/Borrow.php
View file @
11dfa27c
...
...
@@ -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
)){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment