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
f7fb455f
Commit
f7fb455f
authored
Jun 20, 2024
by
wuxiaoli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://rungit.jxdsy.cn:10000/sugar/stock_new
into dev
parents
357e52a1
4098f95a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
15 deletions
+88
-15
application/apicom/home/User.php
application/apicom/home/User.php
+7
-3
application/apicom/home/ZthySms.php
application/apicom/home/ZthySms.php
+69
-0
application/market/home/Trade.php
application/market/home/Trade.php
+2
-2
application/market/model/Position.php
application/market/model/Position.php
+10
-10
No files found.
application/apicom/home/User.php
View file @
f7fb455f
...
...
@@ -7,6 +7,8 @@ use think\Db;
use
util\Tree
;
use
think\request
;
use
app\apicom\model\JWT
;
use
app\apicom\home\ZthySms
;
class
User
extends
Common
{
...
...
@@ -117,7 +119,7 @@ class User extends Common
}
//临时关闭验证短信
true
!==
$check_code
&&
ajaxmsg
(
'验证码错误'
,
0
);
//
true !== $check_code && ajaxmsg('验证码错误',0);
$result
=
$this
->
validate
(
$data
,
'Member.create'
);
true
!==
$result
&&
ajaxmsg
(
$result
,
0
);
...
...
@@ -188,10 +190,12 @@ class User extends Common
ajaxmsg
(
'请间隔60秒再获取验证码!'
,
0
);
}
//
$res = send_sms($mobile, $template);
//
$res = send_sms($mobile, $template);
$content
=
\think\Config
::
get
(
'sms_template'
)[
'register'
];
$content
=
str_replace
(
array
(
"#var#"
),
array
(
$mobile
),
$content
);
$res
=
sendsms_mandao
(
$mobile
,
$content
,
$tp
);
// $res = sendsms_mandao($mobile,$content,$tp);
$zthysms
=
new
ZthySms
();
$res
=
$zthysms
->
sendSmsCode
(
$mobile
);
if
(
$res
){
ajaxmsg
(
'发送成功'
,
1
);
}
else
{
...
...
application/apicom/home/ZthySms.php
0 → 100644
View file @
f7fb455f
<?php
namespace
app\apicom\home
;
use
think\Config
;
use
think\Exception
;
use
think\Log
;
date_default_timezone_set
(
'PRC'
);
//设置时区
class
ZthySms
{
public
function
sendSmsCode
(
$mobile
=
''
)
{
try
{
$code
=
rand
(
10000
,
99999
);
$content
=
"您的验证码:"
.
$code
.
",您正进行身份验证,打死不告诉别人!"
;
//模板信息发送demo
$url
=
"https://api.mix2.zthysms.com/v2/sendSms"
;
$tKey
=
time
();
$password
=
md5
(
md5
(
'8053uAI7'
)
.
$tKey
);
$date
=
array
(
'username'
=>
'sdcx888hy'
,
//用户名
'password'
=>
$password
,
//密码
'tKey'
=>
$tKey
,
//tKey
'mobile'
=>
$mobile
,
//手机号码
'content'
=>
'【青石证券】'
.
$content
);
$ret
=
self
::
httpPost
(
$url
,
$date
);
$res
=
json_decode
(
$ret
,
true
);
if
(
res
[
'code'
]
!=
200
){
return
false
;
}
$code
=
$code
;
$arr
[
'code'
]
=
md5
(
$code
);
$arr
[
'time'
]
=
time
();
setRegSmsCache
(
$mobile
,
$arr
);
}
catch
(
Exception
$error
)
{
Log
::
record
(
'短信记录异常:'
.
$error
->
getMessage
(),
'error'
);
}
return
true
;
}
public
static
function
httpPost
(
$url
,
$date
)
{
// 模拟提交数据函数
$curl
=
curl_init
();
// 启动一个CURL会话
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
// 要访问的地址
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// 对认证证书来源的检查
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
// 从证书中检查SSL加密算法是否存在
curl_setopt
(
$curl
,
CURLOPT_USERAGENT
,
$_SERVER
[
'HTTP_USER_AGENT'
]);
// 模拟用户使用的浏览器
curl_setopt
(
$curl
,
CURLOPT_POST
,
true
);
// 发送一个常规的Post请求
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
json_encode
(
$date
));
// Post提交的数据包
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
30
);
// 设置超时限制防止死循环
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
false
);
// 显示返回的Header区域内容
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
// 获取的信息以文件流的形式返回
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
false
);
//开启header
curl_setopt
(
$curl
,
CURLOPT_HTTPHEADER
,
array
(
'Content-Type: application/json; charset=utf-8'
));
//类型为json
$result
=
curl_exec
(
$curl
);
// 执行操作
if
(
curl_errno
(
$curl
))
{
echo
'Error POST'
.
curl_error
(
$curl
);
}
curl_close
(
$curl
);
// 关键CURL会话
return
$result
;
// 返回数据
}
}
application/market/home/Trade.php
View file @
f7fb455f
...
...
@@ -166,9 +166,9 @@ class Trade extends Common
//提交交易费用信息
$Delivery
=
new
Delivery
;
$avail
=
(
$moneyinfo
[
'avail'
])
-
$effectMoney
;
Position
::
addPosition
(
$data
[
'code'
],
$data
[
'market'
],
$data
[
'count'
],
$data
[
'sub_id'
],
$broker
[
'lid'
],
$broker
[
'user'
],
$broker
[
'stockjobber'
]);
//print_r("佣金: ".$commission." 过户费: ".$transfer." 总计:".$effectMoney);Db::rollback();exit;
$del_res
=
$Delivery
->
add_m_delivery_order
(
$data
,
$data
[
'count'
],
$data
[
'price'
],
$data
[
'sub_id'
],
$broker
[
'lid'
],
$broker
[
'user'
],
$broker
[
'stockjobber'
],
$commission
,
$transfer
,
$Trust_no
,
$avail
,
$amount
,
$data
[
'model'
]);
// $pos_res = Position::addPosition($data['code'], $data['market'],$data['count'],$data['sub_id'],$broker['lid'],$broker['user'],$broker['stockjobber'],$data['price']);
//print_r("佣金: ".$commission." 过户费: ".$transfer." 总计:".$effectMoney);Db::rollback();exit;
//print_r($del_res);Db::rollback();exit;
if
(
!
$del_res
){
Db
::
rollback
();
...
...
application/market/model/Position.php
View file @
f7fb455f
...
...
@@ -418,7 +418,7 @@ class Position extends Model{
* $user 证券账户
* $soure 证券来源
*/
public
static
function
addPosition
(
$code
,
$market
,
$count
,
$sub_id
,
$lid
,
$user
,
$soure
)
public
static
function
addPosition
(
$code
,
$market
,
$count
,
$sub_id
,
$lid
,
$user
,
$soure
,
$price
)
{
if
(
!
$count
)
return
false
;
//$canbuy = self::getCanbuyCount($sub_id,$code);
...
...
@@ -436,13 +436,13 @@ class Position extends Model{
$data
[
0
][
'count'
]
=
$count
;
$data
[
0
][
'stock_count'
]
=
$position
[
'stock_count'
]
+
$count
;
$data
[
0
][
'canbuy_count'
]
=
$position
[
'canbuy_count'
]
+
$count
;
$data
[
0
][
'ck_price'
]
=
$new_price
;
//参考成本价;
$data
[
0
][
'buy_average_price'
]
=
$
new_price
;
//买入均价
$data
[
0
][
'ck_profit_price'
]
=
$new_price
;
//参考盈亏成本价
$data
[
0
][
'now_price'
]
=
$
stockinfo
[
"current_price"
]
;
//'当前价'
$data
[
0
][
'ck_price'
]
=
self
::
calculate
(
$sub_id
,
$code
,
'average'
)
;
//参考成本价;
$data
[
0
][
'buy_average_price'
]
=
$
data
[
0
][
'ck_price'
]
;
//买入均价
$data
[
0
][
'ck_profit_price'
]
=
''
;
//参考盈亏成本价
$data
[
0
][
'now_price'
]
=
$
price
;
//'当前价'
$data
[
0
][
'market_value'
]
=
$stockinfo
[
"current_price"
]
*
$count
;
//最新市值
$data
[
0
][
'ck_profit'
]
=
$
position
[
'ck_profit'
]
;
//参考浮动盈亏
$data
[
0
][
'profit_rate'
]
=
$
position
[
'profit_rate'
]
;
//盈亏比例
$data
[
0
][
'ck_profit'
]
=
$
count
>
0
?
bcmul
(
strval
(
$price
-
$data
[
0
][
'ck_price'
]),
strval
(
$count
),
2
)
:
0
;
//参考浮动盈亏
$data
[
0
][
'profit_rate'
]
=
$
count
>
0
&&
$price
>
0
?
bcdiv
(
strval
(
$data
[
0
][
'ck_profit'
]),
strval
(
$price
*
$count
*
100
),
2
)
:
0
;
//盈亏比例
$data
[
0
][
'buying'
]
=
0
;
//买入成功
$data
[
0
][
'selling'
]
=
0
;
//1、在途卖出
$data
[
0
][
'gudong_code'
]
=
""
;
//股东代码 无法模拟暂时空
...
...
@@ -475,9 +475,9 @@ class Position extends Model{
$result
=
bcdiv
(
strval
(
$amount
),
strval
(
$volume
),
3
);
break
;
case
'average'
:
$order
=
Db
::
name
(
'stock_delivery_order'
)
->
where
([
'sub_id'
=>
$sub_id
,
'gupiao_code'
=>
$code
,
'status'
=>
1
,
'business_name'
=>
'证券买入'
]);
$amount
=
$order
->
sum
(
'residual_quantity'
);
$volume
=
$order
->
sum
(
'volume'
);
// $order = Db::name('stock_delivery_order')->where(['sub_id' => $sub_id, 'gupiao_code' => $code,'status' => 0
,'business_name' => '证券买入']);
$amount
=
Db
::
name
(
'stock_delivery_order'
)
->
where
([
'sub_id'
=>
$sub_id
,
'gupiao_code'
=>
$code
,
'status'
=>
1
,
'business_name'
=>
'证券买入'
])
->
sum
(
'residual_quantity'
);
$volume
=
Db
::
name
(
'stock_delivery_order'
)
->
where
([
'sub_id'
=>
$sub_id
,
'gupiao_code'
=>
$code
,
'status'
=>
1
,
'business_name'
=>
'证券买入'
])
->
sum
(
'volume'
);
$result
=
bcdiv
(
strval
(
$amount
),
strval
(
$volume
),
3
);
break
;
default
:
...
...
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