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
0de786d6
Commit
0de786d6
authored
Jun 20, 2024
by
wuxiaoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复获取实时股票信息
parent
696012ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
69 deletions
+78
-69
application/common.php
application/common.php
+24
-11
application/function.php
application/function.php
+53
-58
application/market/model/Position.php
application/market/model/Position.php
+1
-0
No files found.
application/common.php
View file @
0de786d6
...
@@ -2047,21 +2047,34 @@ function curl($url){
...
@@ -2047,21 +2047,34 @@ function curl($url){
*/
*/
if
(
!
function_exists
(
'toMarket'
)){
if
(
!
function_exists
(
'toMarket'
)){
function
toMarket
(
$code
){
function
toMarket
(
$code
){
if
(
$code
==
'000001'
){
if
(
strlen
(
$code
)
===
5
){
//如果不符合上述简单规则,可能需要更复杂的逻辑或数据查询
return
'SZ'
;
return
"HK"
;
}
}
else
if
(
strlen
(
$code
)
===
6
){
//A股暂时假设6位代码
if
(
in_array
(
substr
(
$code
,
0
,
1
),
array
(
'6'
,
'9'
))){
if
(
$code
==
'000001'
){
return
'SH'
;
return
'SZ'
;
}
}
if
(
in_array
(
substr
(
$code
,
0
,
1
),
array
(
'0'
,
'2'
,
'3'
))){
if
(
in_array
(
substr
(
$code
,
0
,
1
),
array
(
'6'
,
'9'
))){
return
'SZ'
;
return
'SH'
;
}
}
if
(
in_array
(
substr
(
$code
,
0
,
1
),
array
(
'4'
,
'8'
))){
if
(
in_array
(
substr
(
$code
,
0
,
1
),
array
(
'0'
,
'2'
,
'3'
))){
return
'BJ'
;
return
'SZ'
;
}
if
(
in_array
(
substr
(
$code
,
0
,
1
),
array
(
'4'
,
'8'
))){
return
'BJ'
;
}
}
}
}
}
}
}
//腾讯数据解析
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
;
}
}
/******************************************************************************************/
/******************************************************************************************/
if
(
!
function_exists
(
'toPinyin'
))
{
if
(
!
function_exists
(
'toPinyin'
))
{
function
toPinyin
(
$zh
){
function
toPinyin
(
$zh
){
...
...
application/function.php
View file @
0de786d6
...
@@ -242,17 +242,10 @@ if (!function_exists('getEndDay')) {
...
@@ -242,17 +242,10 @@ if (!function_exists('getEndDay')) {
}
}
if
(
!
function_exists
(
'z_market'
))
{
if
(
!
function_exists
(
'z_market'
))
{
function
z_market
(
$code
,
$market
=
"
HK
"
)
function
z_market
(
$code
,
$market
=
""
)
{
{
$res
=
\think\Db
::
name
(
'admin_config'
)
->
where
(
array
(
'name'
=>
'market_data_in'
))
->
value
(
'value'
);
$res
=
\think\Db
::
name
(
'admin_config'
)
->
where
(
array
(
'name'
=>
'market_data_in'
))
->
value
(
'value'
);
//判断股票前缀
/*if(toMarket($code)){
$market = toMarket($code);
};*/
$code
=
strtolower
(
$market
)
.
$code
;
//判断股票是否
switch
(
$res
)
{
switch
(
$res
)
{
case
1
:
case
1
:
$res
=
qq_market
(
$code
);
$res
=
qq_market
(
$code
);
...
@@ -296,7 +289,6 @@ if (!function_exists('getEndDay')) {
...
@@ -296,7 +289,6 @@ if (!function_exists('getEndDay')) {
switch
(
$res
)
{
switch
(
$res
)
{
case
1
:
case
1
:
$res
=
explode
(
','
,
$code
);
$res
=
explode
(
','
,
$code
);
$count
=
count
(
$res
);
foreach
(
$res
as
$v
)
{
foreach
(
$res
as
$v
)
{
$d
.=
fenxi
(
$v
)
.
','
;
$d
.=
fenxi
(
$v
)
.
','
;
...
@@ -308,16 +300,9 @@ if (!function_exists('getEndDay')) {
...
@@ -308,16 +300,9 @@ if (!function_exists('getEndDay')) {
break
;
break
;
}
}
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
foreach
(
$tmd
as
$k
=>
$v
){
$k
=
$i
*
53
;
$data
[
$k
][
0
]
=
''
;
$data
[
$k
]
=
qq_to_api
(
$v
);
for
(
$n
=
1
;
$n
<=
53
;
$n
++
)
{
$num
=
$n
+
$k
;
$data
[
$i
][
$n
]
=
$tmd
[
$num
];
}
$data
[
$i
][
0
]
=
''
;
$data
[
$i
]
=
qq_to_api
(
$data
[
$i
]);
}
}
break
;
break
;
...
@@ -377,7 +362,6 @@ if (!function_exists('getEndDay')) {
...
@@ -377,7 +362,6 @@ if (!function_exists('getEndDay')) {
default
:
default
:
$res
=
explode
(
','
,
$code
);
$res
=
explode
(
','
,
$code
);
$count
=
count
(
$res
);
foreach
(
$res
as
$v
)
{
foreach
(
$res
as
$v
)
{
$d
.=
fenxi
(
$v
)
.
','
;
$d
.=
fenxi
(
$v
)
.
','
;
...
@@ -385,16 +369,9 @@ if (!function_exists('getEndDay')) {
...
@@ -385,16 +369,9 @@ if (!function_exists('getEndDay')) {
$tmd
=
qq_market_b
(
$d
);
$tmd
=
qq_market_b
(
$d
);
for
(
$i
=
0
;
$i
<
$count
;
$i
++
)
{
foreach
(
$tmd
as
$k
=>
$v
){
$k
=
$i
*
53
;
$data
[
$k
][
0
]
=
''
;
$data
[
$k
]
=
qq_to_api
(
$v
);
for
(
$n
=
1
;
$n
<=
53
;
$n
++
)
{
$num
=
$n
+
$k
;
$data
[
$i
][
$n
]
=
$tmd
[
$num
];
}
$data
[
$i
][
0
]
=
''
;
$data
[
$i
]
=
qq_to_api
(
$data
[
$i
]);
}
}
break
;
break
;
...
@@ -976,40 +953,48 @@ if (!function_exists('getEndDay')) {
...
@@ -976,40 +953,48 @@ if (!function_exists('getEndDay')) {
if
(
!
function_exists
(
''
))
{
if
(
!
function_exists
(
''
))
{
function
fenxi
(
$code
)
function
fenxi
(
$code
)
{
{
switch
(
substr
(
$code
,
0
,
1
))
{
case
'0'
:
$d
=
'sz'
.
$code
;
break
;
case
'3'
:
if
(
strlen
(
$code
)
===
5
){
//港股
$d
=
'sz'
.
$code
;
break
;
case
'1'
:
$d
=
'hk'
.
$code
;
$d
=
'sz'
.
$code
;
break
;
case
'2'
:
}
else
if
(
strlen
(
$code
)
===
6
){
//A股
$d
=
'sz'
.
$code
;
switch
(
substr
(
$code
,
0
,
1
))
{
break
;
case
'0'
:
$d
=
'sz'
.
$code
;
break
;
case
'6
'
:
case
'3
'
:
$d
=
'sh
'
.
$code
;
$d
=
'sz
'
.
$code
;
break
;
break
;
case
'5
'
:
case
'1
'
:
$d
=
'sh
'
.
$code
;
$d
=
'sz
'
.
$code
;
break
;
break
;
case
'9
'
:
case
'2
'
:
$d
=
'sh
'
.
$code
;
$d
=
'sz
'
.
$code
;
break
;
break
;
default
:
case
'6'
:
$d
=
$code
;
$d
=
'sh'
.
$code
;
break
;
break
;
case
'5'
:
$d
=
'sh'
.
$code
;
break
;
case
'9'
:
$d
=
'sh'
.
$code
;
break
;
default
:
$d
=
$code
;
break
;
}
}
}
return
$d
;
return
$d
;
}
}
}
}
...
@@ -1208,9 +1193,19 @@ if (!function_exists('getEndDay')) {
...
@@ -1208,9 +1193,19 @@ if (!function_exists('getEndDay')) {
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
$output
=
curl_exec
(
$ch
);
$output
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
curl_close
(
$ch
);
$t2
=
explode
(
'~'
,
mb_convert_encoding
(
$output
,
'utf-8'
,
'gbk'
));
$str
=
mb_convert_encoding
(
$output
,
'utf-8'
,
'gbk'
);
unset
(
$t2
[
0
]);
$str
=
str_replace
(
array
(
"
\r\n
"
,
"
\r
"
,
"
\n
"
),
""
,
$str
);
return
$t2
;
$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
;
}
}
}
}
...
...
application/market/model/Position.php
View file @
0de786d6
...
@@ -326,6 +326,7 @@ class Position extends Model{
...
@@ -326,6 +326,7 @@ class Position extends Model{
$data
[
0
][
'lid'
]
=
$lid
;
$data
[
0
][
'lid'
]
=
$lid
;
$data
[
0
][
'soruce'
]
=
$soure
;
$data
[
0
][
'soruce'
]
=
$soure
;
$data
[
0
][
'login_name'
]
=
$user
;
$data
[
0
][
'login_name'
]
=
$user
;
$data
[
0
][
'market'
]
=
toMarket
(
$stockinfo
[
"code"
]);
$data
[
0
][
'gupiao_code'
]
=
$stockinfo
[
"code"
];
$data
[
0
][
'gupiao_code'
]
=
$stockinfo
[
"code"
];
$data
[
0
][
'gupiao_name'
]
=
$stockinfo
[
"name"
];
$data
[
0
][
'gupiao_name'
]
=
$stockinfo
[
"name"
];
$data
[
0
][
'count'
]
=
$count
;
$data
[
0
][
'count'
]
=
$count
;
...
...
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