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
2c909e78
Commit
2c909e78
authored
Jun 19, 2024
by
董先生
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://rungit.jxdsy.cn:10000/sugar/stock_new
into dev
parents
7cf756d1
3314982f
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
535 additions
and
341 deletions
+535
-341
application/common.php
application/common.php
+30
-118
application/function.php
application/function.php
+8
-1
application/market/home/Index.php
application/market/home/Index.php
+1
-1
application/market/home/Trade.php
application/market/home/Trade.php
+1
-1
application/market/model/Trust.php
application/market/model/Trust.php
+182
-5
application/market/validate/Trade.php
application/market/validate/Trade.php
+34
-0
application/member/model/Member.php
application/member/model/Member.php
+165
-143
application/money/admin/Esopplan.php
application/money/admin/Esopplan.php
+87
-69
application/money/model/EsopPlan.php
application/money/model/EsopPlan.php
+1
-1
application/stock/model/StockList.php
application/stock/model/StockList.php
+26
-2
No files found.
application/common.php
View file @
2c909e78
...
...
@@ -2087,126 +2087,38 @@ 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
(
'commission'
))
{
function
commission
(
$money
,
$scale
,
$min
){
$commission
=
round
((
$money
*
$scale
)
/
10000
,
2
);
//佣金
$commission
=
$commission
<
$min
?
$min
:
$commission
;
return
$commission
;
}
/*
* 远程访问
*/
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
;
}
}
/*
* 计算印花税
*/
if
(
!
function_exists
(
'stamps'
))
{
function
stamps
(
$money
){
$stamps
=
round
(
$money
*
config
(
'stamp_duty'
)
/
1000
,
2
);
return
$stamps
??
0
;
}
/*
* 通过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
;
}
/*
* 计算过户费
*/
if
(
!
function_exists
(
'transfer'
))
{
function
transfer
(
$money
){
if
(
!
config
(
'transfer_fee'
)
||
config
(
'transfer_fee'
)
==
0
){
//当该值未设置或值为0时表示关闭,则返回0
return
0
;
}
elseif
(
config
(
'transfer_fee'
)
>
1
){
//当值大于1时表示具体数值,则返回该数值
return
config
(
'transfer_fee'
);
}
else
{
$transfer
=
round
((
$money
/
1000
)
*
config
(
'transfer_fee'
),
2
)
??
0
;
}
return
$transfer
;
}
}
application/function.php
View file @
2c909e78
...
...
@@ -242,10 +242,17 @@ if (!function_exists('getEndDay')) {
}
if
(
!
function_exists
(
'z_market'
))
{
function
z_market
(
$code
)
function
z_market
(
$code
,
$market
=
"HK"
)
{
$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
)
{
case
1
:
$res
=
qq_market
(
$code
);
...
...
application/market/home/Index.php
View file @
2c909e78
...
...
@@ -87,7 +87,7 @@ class Index extends Common
if
(
$code
===
null
)
{
return
json
([
'data'
=>
null
,
'status'
=>
0
,
'message'
=>
'缺少参数code,操作失败'
]);
}
$data
=
z_market
(
strtolower
(
$market
)
.
$code
);
$data
=
z_market
(
$code
,
$market
);
if
(
!
$data
)
{
return
json
([
'data'
=>
$data
,
'status'
=>
0
,
'message'
=>
'操作失败'
]);
}
...
...
application/market/home/Trade.php
View file @
2c909e78
This diff is collapsed.
Click to expand it.
application/market/model/Trust.php
View file @
2c909e78
...
...
@@ -15,6 +15,7 @@ class Trust extends Model{
protected
$table
=
'__STOCK_TRUST__'
;
// 自动写入时间戳
protected
$autoWriteTimestamp
=
true
;
/*
* 存储委托记录
* $data 持仓数据
...
...
@@ -224,11 +225,11 @@ class Trust extends Model{
* 返回子账号当日委托
* $sub_id 子账号
*/
public
function
get_trust_day
(
$sub_id
){
$time
=
strtotime
(
date
(
'y-m-d'
,
time
()));
$res
=
Db
::
name
(
'stock_trust'
)
->
where
([
'sub_id'
=>
$sub_id
,
'trust_date'
=>
$time
])
->
select
();
return
$res
;
}
public
function
get_trust_day
(
$sub_id
){
$time
=
strtotime
(
date
(
'y-m-d'
,
time
()));
$res
=
Db
::
name
(
'stock_trust'
)
->
where
([
'sub_id'
=>
$sub_id
,
'trust_date'
=>
$time
])
->
select
();
return
$res
;
}
/*
* 返回子账号委托
* $sub_id 子账号
...
...
@@ -291,4 +292,180 @@ class Trust extends Model{
return
$result
;
}
// 买入时检查
public
function
executeData
(
$data
,
$trustModel
)
{
//检测是否为禁买股票
$res
=
self
::
checkStatus
(
$data
[
'code'
]);
if
(
$res
)
return
[
'status'
=>
0
,
'message'
=>
'该股票禁止交易'
];
//判断购买数量书否正确
if
((
$data
[
'count'
]
%
100
)
!=
0
)
return
[
'status'
=>
0
,
'message'
=>
'交易数量必须是100的整数倍'
];
$bs_res
=
Db
::
name
(
'stock_borrow'
)
->
where
(
array
(
'stock_subaccount_id'
=>
$data
[
'subid'
]))
->
find
();
if
(
empty
(
$bs_res
))
{
return
[
'status'
=>
0
,
'message'
=>
'没有对应的配资'
];
}
if
(
$bs_res
[
'end_time'
]
<=
time
()){
return
[
'status'
=>
0
,
'message'
=>
'该账户已逾期,请先续期'
];
}
if
(
$trustModel
==
'buy'
){
return
self
::
trustBuy
(
$data
,
$bs_res
);
}
if
(
$trustModel
==
'sell'
){
return
self
::
trustSell
(
$data
);
}
}
public
function
trustBuy
(
$data
,
$bs_res
)
{
//查询股票最新行情
$Qdata
=
z_market
(
$data
[
'code'
],
$data
[
'market'
]);
$price
=
$data
[
'price'
]
<=
0
?
$Qdata
[
'Price'
]
:
$data
[
'price'
];
//判断股票价格是否符号购买条件
if
(
config
(
'stock_buy_price'
)
>
0
)
{
if
(
$price
<
config
(
'stock_buy_price'
))
{
return
[
'status'
=>
0
,
'message'
=>
'系统设定低于'
.
config
(
'stock_buy_price'
)
.
'元一股的股票不能购买'
];
}
}
//检查卖量是否正常
$trade_money
=
self
::
checkTranMoney
(
$Qdata
,
$data
[
'count'
],
$price
);
if
(
$trade_money
<=
0
)
return
[
'status'
=>
0
,
'message'
=>
'卖量不足或网络错误'
];
//判断卖量和股票限额
$res
=
self
::
checkPositionSum
(
$Qdata
,
$data
[
'sub_id'
],
$data
[
'code'
],
$trade_money
);
if
(
isset
(
$res
[
'status'
]))
{
return
[
'status'
=>
0
,
'message'
=>
'该股票超过了单支股票最大购买限额'
];
}
//检查子账户余额
$moneymodel
=
new
SubAccountMoney
();
$moneyinfo
=
$moneymodel
->
get_account_money
(
$data
[
'sub_id'
]);
if
(
$moneyinfo
[
'avail'
]
<
$trade_money
){
return
[
'status'
=>
0
,
'message'
=>
'购买资金不足'
];
}
// 免息配资结束当天不能买入
if
(
$bs_res
[
'type'
]
==
5
)
{
if
(
$bs_res
[
'end_time'
]
<
time
()
+
23
*
3600
)
{
return
[
'status'
=>
0
,
'message'
=>
'免息配资结束当天不能买入'
];
}
}
// 设置试用配资第二天不能再买入
if
(
$bs_res
[
'type'
]
==
4
)
{
if
(
$bs_res
[
'end_time'
]
<
time
()
+
23
*
3600
)
{
return
[
'status'
=>
0
,
'message'
=>
'试用配资结束当天不能买入'
];
}
}
$risk
=
new
StockSubAccountRisk
;
$risk_res
=
$risk
->
get_risk
(
$data
[
'sub_id'
]);
if
(
$risk_res
[
'prohibit_open'
]
==
0
){
return
[
'status'
=>
0
,
'message'
=>
'您被禁止开新仓,请联系管理员咨询原因'
];
}
$retData
[
'trade_money'
]
=
$trade_money
;
$retData
[
'moneyinfo'
]
=
$moneyinfo
;
$retData
[
'price'
]
=
$price
;
return
$retData
;
}
//卖出时检查
public
function
trustSell
(
$data
)
{
//查询股票最新行情
$Qdata
=
z_market
(
$data
[
'code'
],
$data
[
'market'
]);
$price
=
$data
[
'price'
]
<=
0
?
$Qdata
[
'Price'
]
:
$data
[
'price'
];
if
(
config
(
'site_trade_sell'
)
==
0
)
{
return
array
(
'status'
=>
0
,
'message'
=>
'系统设置不允许卖出股票'
);
}
//检测股票可卖数量
$poscount
=
Position
::
get_canbuy_count
(
$data
[
'sub_id'
],
$data
[
'code'
]);
if
(
$poscount
<
$data
[
'count'
])
{
return
[
'status'
=>
0
,
'message'
=>
'可卖股票不足'
];
}
//当股票跌停时买一至买五价格为空
if
(
intval
(
$Qdata
[
"Bp1"
])
<=
0
||
intval
(
$Qdata
[
'Bv1'
]
*
100
)
<
$data
[
'count'
]){
return
[
'status'
=>
0
,
'message'
=>
'当前买盘不足,无法即时成交!'
];
}
//检查子账户余额
$moneymodel
=
new
SubAccountMoney
();
$moneyinfo
=
$moneymodel
->
get_account_money
(
$data
[
'sub_id'
]);
$trade_money
=
0
;
if
(
$data
[
'price'
]
>
0
&&
$data
[
'model'
]
==
1
){
//model = 1 是委托状态
$trade_money
=
intval
(
$data
[
'count'
])
*
intval
(
$data
[
'price'
]);
}
else
{
$price
=
$Qdata
[
'Price'
];
//如果没有委托价格使用下面的公式
$trade_money
=
intval
(
$data
[
'count'
])
*
intval
(
$price
);
}
$retData
[
'trade_money'
]
=
$trade_money
;
$retData
[
'moneyinfo'
]
=
$moneyinfo
;
$retData
[
'price'
]
=
$price
;
return
$retData
;
}
/*查询禁买股票列表*/
public
function
checkStatus
(
$code
)
{
$res
=
Db
::
name
(
'stock_list'
)
->
where
([
'code'
=>
$code
,
'status'
=>
0
])
->
find
();
return
$res
;
}
/*
* 验证卖量是否正常
*/
public
function
checkTranMoney
(
$Qdata
,
$count
,
$price
)
{
$trade_money
=
0
;
if
(
!
(
empty
(
$price
)))
{
$trade_money
=
$count
*
$price
;
}
else
{
$price
=
0
;
$v_arr
[
1
]
=
$Qdata
[
'Sv1'
]
*
100
;
$v_arr
[
2
]
=
$Qdata
[
'Sv2'
]
*
100
;
$v_arr
[
3
]
=
$Qdata
[
'Sv3'
]
*
100
;
$v_arr
[
4
]
=
$Qdata
[
'Sv4'
]
*
100
;
$v_arr
[
5
]
=
$Qdata
[
'Sv5'
]
*
100
;
$p_arr
[
1
]
=
$Qdata
[
'Sp1'
];
$p_arr
[
2
]
=
$Qdata
[
'Sp2'
];
$p_arr
[
3
]
=
$Qdata
[
'Sp3'
];
$p_arr
[
4
]
=
$Qdata
[
'Sp4'
];
$p_arr
[
5
]
=
$Qdata
[
'Sp5'
];
$tmd
=
0
;
foreach
(
$v_arr
as
$key
=>
$v
){
$tmd
=
$tmd
+
$v
;
if
(
$count
<=
$tmd
){
$sum_money
=
0
;
$sum_count
=
$count
;
for
(
$i
=
1
;
$i
<
$key
;
$i
++
){
$sum_money
+=
$v_arr
[
$i
]
*
$p_arr
[
$i
];
$sum_count
-=
$v_arr
[
$i
];
}
$trade_money
=
$sum_money
+
(
$sum_count
*
$p_arr
[
$key
]);
$price
=
round
(
$trade_money
/
$count
,
2
);
$trade_money
=
$count
*
$price
;
break
;
}
}
}
return
$trade_money
??
0
;
}
/*
* 返回子账号单只股票持仓数量
* $subid 子账号 $code 股票代码
*/
public
function
checkPositionSum
(
$Qdata
,
$subid
,
$code
,
$trade_money
)
{
$res
=
Db
::
name
(
'stock_list'
)
->
where
([
'code'
=>
$code
,
'status'
=>
1
])
->
find
();
//判断是否超过该只股票限额
$pos
=
Db
::
name
(
'stock_position'
)
->
where
([
'sub_id'
=>
$subid
,
'gupiao_code'
=>
$code
,
'buying'
=>
0
])
->
sum
(
'stock_count'
);
if
(
isset
(
$res
[
'quota'
])
&&
(
$res
[
'quota'
]
<
((
$pos
*
$Qdata
[
'Price'
])
+
$trade_money
)))
{
return
[
'status'
=>
0
,
'message'
=>
'该股票超过了单支股票最大购买限额'
];
}
return
;
}
}
\ No newline at end of file
application/market/validate/Trade.php
0 → 100644
View file @
2c909e78
<?php
namespace
app\apicom\validate
;
use
think\Validate
;
class
Trade
extends
Validate
{
protected
$rule
=
[
'id'
=>
'require|number'
,
'code'
=>
'require|number|length:6'
,
'market'
=>
'require|in:SH,SZ,BJ'
,
'count'
=>
'require|number|gt:0'
,
'price'
=>
'require'
,
];
protected
$message
=
[
'id.require'
=>
'参数格式错误'
,
'code.require'
=>
'参数格式错误'
,
'code.number'
=>
'参数格式错误'
,
'code.length'
=>
'参数格式错误'
,
'count.require'
=>
'请填写委托股数'
,
'count.number'
=>
'委托股数格式错误'
,
'count.gt'
=>
'委托股数格式错误'
,
'market.require'
=>
'参数格式错误'
,
'market.in'
=>
'参数格式错误'
,
];
protected
$scene
=
[
'trade'
=>
[
'id'
,
'code'
,
'market'
,
'count'
,
'price'
],
];
}
application/member/model/Member.php
View file @
2c909e78
This diff is collapsed.
Click to expand it.
application/money/admin/Esopplan.php
View file @
2c909e78
...
...
@@ -5,8 +5,10 @@ namespace app\money\admin;
use
app\admin\controller\Admin
;
use
app\common\builder\ZBuilder
;
use
app\money\model\EsopPlan
as
EsopPlanModel
;
use
app\member\model\Member
as
MemberModel
;
use
app\stock\model\StockList
as
StockListModel
;
use
think\Db
;
use
think\Hook
;
use
think\Hook
;
use
think\Cache
;
/**
...
...
@@ -21,108 +23,124 @@ class Esopplan extends Admin
*/
public
function
index
()
{
cookie
(
'__forward__'
,
$_SERVER
[
'REQUEST_URI'
]);
cookie
(
'__forward__'
,
$_SERVER
[
'REQUEST_URI'
]);
// 获取查询条件
$map
=
$this
->
getMap
();
$order
=
$this
->
getOrder
();
$order
=
$this
->
getOrder
();
empty
(
$order
)
&&
$order
=
'id desc'
;
// 数据列表
$data_list
=
EsopPlanModel
::
getAll
(
$map
,
$order
);
// 分页数据
// 分页数据
$page
=
$data_list
->
render
();
if
(
empty
(
$_SERVER
[
"QUERY_STRING"
])){
$excel_url
=
substr
(
http
()
.
$_SERVER
[
"SERVER_NAME"
]
.
$_SERVER
[
"REQUEST_URI"
],
0
,
-
5
)
.
"_export"
;
}
else
{
$excel_url
=
substr
(
http
()
.
$_SERVER
[
"SERVER_NAME"
]
.
$_SERVER
[
"PHP_SELF"
],
0
,
-
5
)
.
"_export?"
.
$_SERVER
[
"QUERY_STRING"
];
if
(
empty
(
$_SERVER
[
"QUERY_STRING"
]))
{
$excel_url
=
substr
(
http
()
.
$_SERVER
[
"SERVER_NAME"
]
.
$_SERVER
[
"REQUEST_URI"
],
0
,
-
5
)
.
"_export"
;
}
else
{
$excel_url
=
substr
(
http
()
.
$_SERVER
[
"SERVER_NAME"
]
.
$_SERVER
[
"PHP_SELF"
],
0
,
-
5
)
.
"_export?"
.
$_SERVER
[
"QUERY_STRING"
];
}
$btn_excel
=
[
'title'
=>
'导出EXCEL表'
,
'icon'
=>
'fa fa-fw fa-download'
,
'href'
=>
url
(
$excel_url
,
''
,
''
)
'href'
=>
url
(
$excel_url
,
''
,
''
)
];
return
ZBuilder
::
make
(
'table'
)
->
setSearch
([
'mid'
=>
'用户ID'
,
'member.name'
=>
'姓名'
,
'member.mobile'
=>
'手机号'
])
// 设置搜索框
return
ZBuilder
::
make
(
'table'
)
->
setSearch
([
'mid'
=>
'用户ID'
,
'member.name'
=>
'姓名'
,
'member.mobile'
=>
'手机号'
])
// 设置搜索框
->
addColumns
([
// 批量添加数据列
[
'id'
,
'ID'
],
[
'mobile'
,
'手机号'
],
[
'name'
,
'姓名'
],
[
'title'
,
'股票'
],
[
'title'
,
'股票'
],
[
'account'
,
'可用期权'
],
[
'plan_account'
,
'期权总值'
],
[
'remain_account'
,
'待释放'
],
[
'release_account'
,
'已释放'
],
[
'duration'
,
'总释放天数'
],
[
'duration'
,
'总释放天数'
],
[
'days'
,
'已释放天数'
],
[
'release_time'
,
'开始释放时间'
],
[
'release_time'
,
'开始释放时间'
],
[
'create_time'
,
'创建时间'
],
[
'status'
,
'状态'
,
'switch'
],
])
->
hideCheckbox
()
->
setTableName
(
'plan'
)
->
addTopButton
(
'custem'
,
$btn_excel
)
->
addRightButtons
([
'edit'
])
// 批量添加右侧按钮
->
setTableName
(
'esop_plan'
)
->
addTopButton
(
'custem'
,
$btn_excel
)
->
addTopButtons
(
'add'
)
->
addRightButton
(
'edit'
)
->
addRightButton
(
'delete'
)
->
addOrder
(
'id,create_time,release_time'
)
->
setRowList
(
$data_list
)
->
setRowList
(
$data_list
)
->
fetch
();
// 渲染模板
}
public
function
index_export
(){
// 获取查询条件
$map
=
$this
->
getMap
();
$order
=
$this
->
getOrder
();
empty
(
$order
)
&&
$order
=
'id desc'
;
// 数据列表
$xlsData
=
EsopPlanModel
::
getAll
(
$map
,
$order
);
$title
=
"期权计划列表"
;
$arrHeader
=
array
(
'ID'
,
'手机号'
,
'姓名'
,
'股票'
,
'可用期权'
,
'期权总值'
,
'待释放'
,
'已释放'
,
'总释放天数'
,
'已释放天数'
,
'开始释放时间'
,
'创建时间'
,
'状态'
);
$fields
=
array
(
'id'
,
'mobile'
,
'name'
,
'title'
,
'account'
,
'plan_account'
,
'remain_account'
,
'release_account'
,
'duration'
,
'days'
,
'release_time'
,
'create_time'
,
'status'
);
export
(
$arrHeader
,
$fields
,
$xlsData
,
$title
);
}
public
function
quickEdit
(
$record
=
[])
/**
* 新增
* @return mixed
*/
public
function
add
()
{
$id
=
input
(
'post.pk'
,
''
);
$field
=
input
(
'post.name'
,
''
);
$value
=
input
(
'post.value'
,
''
);
$table
=
input
(
'post.table'
,
''
);
$type
=
input
(
'post.type'
,
''
);
if
(
in_array
(
$field
,
array
(
'account'
,
'plan_account'
,
'remain_account'
,
'release_account'
))
){
$value
*=
100
;
// 保存数据
if
(
$this
->
request
->
isPost
())
{
$data
=
$this
->
request
->
post
();
$data
[
'create_time'
]
=
time
();
$data
[
'plan_account'
]
=
$data
[
'plan_account'
]
*
100
;
//业务逻辑处理
$result_up
=
Db
::
name
(
"esop_plan"
)
->
insert
(
$data
);
if
(
$result_up
===
1
)
{
$this
->
success
(
'添加成功'
,
'index'
);
}
else
{
$this
->
error
(
$result_up
);
}
}
$mid
=
EsopPlanModel
::
where
(
'id'
,
$id
)
->
value
(
'mid'
);
$old_value
=
EsopPlanModel
::
where
(
'id'
,
$id
)
->
value
(
$field
);
$mobile
=
Db
(
'member'
)
->
where
(
'id'
,
$mid
)
->
value
(
'mobile'
);
$details
=
$mobile
.
' 字段('
.
$field
.
'),原值:('
.
$old_value
.
')新值:('
.
$value
.
')'
;
// 使用ZBuilder快速创建表单
return
ZBuilder
::
make
(
'form'
)
->
setPageTitle
(
'新增'
)
// 设置页面标题
->
addFormItems
([
// 批量添加表单项
[
'select:5'
,
'mid'
,
'请选择用户'
,
''
,
MemberModel
::
getMemberList
(),
''
,
url
(
'get_mid'
),
'mid'
],
[
'select:5'
,
'stock_id'
,
'请选择股票'
,
''
,
StockListModel
::
getStockList
(),
''
,
url
(
'get_stock_id'
),
'stock_id'
],
[
'number'
,
'plan_account'
,
'期权总值'
,
'期权总的价值(港元)'
,
'0'
],
[
'number'
,
'duration'
,
'总释放天数'
,
'总释放天数'
,
'1000'
],
[
'datetime'
,
'release_time'
,
'开始时间'
,
'从哪天开始释放期权'
,
''
,
'YYYY-MM-DD HH:mm:ss'
],
])
->
fetch
();
}
switch
(
$type
)
{
// 日期时间需要转为时间戳
case
'release_time'
:
$value
=
strtotime
(
$value
);
break
;
// 开关
case
'switch'
:
$value
=
$value
==
'true'
?
1
:
0
;
break
;
// 根据所有用户ID
public
function
get_mid
(
$mid
)
{
$arr
=
[];
$where
[
'status'
]
=
1
;
$where
[
'id'
]
=
$mid
;
$data_list
=
Db
::
name
(
'member'
)
->
where
(
$where
)
->
find
();
if
(
!
is_null
(
$data_list
))
{
$arr
[
'code'
]
=
'1'
;
//判断状态
$arr
[
'msg'
]
=
'请求成功'
;
//回传信息
$result
[
$data_list
[
'id'
]]
=
$data_list
[
'id'
];
$arr
[
'list'
]
=
format_linkage
(
$result
);
//将一维数组转成联动需要的数据格式
}
else
{
$arr
[
'code'
]
=
'0'
;
//判断状态
$arr
[
'msg'
]
=
'数据请求失败'
;
//回传信息
$arr
[
'list'
]
=
[];
//将一维数组转成联动需要的数据格式
}
$pk
=
Db
(
'esop_plan'
)
->
getPk
();
$result
=
Db
(
'esop_plan'
)
->
where
(
$pk
,
$id
)
->
setField
(
$field
,
$value
);
if
(
false
!==
$result
)
{
Cache
::
clear
();
// 记录行为日志
if
(
!
empty
(
$member_mobile
))
{
call_user_func_array
(
'action_log'
,
[
'esop_plan_edit'
,
'esop_plan'
,
$id
,
UID
,
$details
]);
}
$this
->
success
(
'操作成功'
);
return
json
(
$arr
);
}
// 根据所有股票ID
public
function
get_stock_id
(
$stock_id
)
{
$arr
=
[];
$where
[
'status'
]
=
1
;
$where
[
'id'
]
=
$stock_id
;
$data_list
=
Db
::
name
(
'stock_list'
)
->
where
(
$where
)
->
find
();
if
(
!
is_null
(
$data_list
))
{
$arr
[
'code'
]
=
'1'
;
//判断状态
$arr
[
'msg'
]
=
'请求成功'
;
//回传信息
$result
[
$data_list
[
'id'
]]
=
$data_list
[
'id'
];
$arr
[
'list'
]
=
format_linkage
(
$result
);
//将一维数组转成联动需要的数据格式
}
else
{
$this
->
error
(
'操作失败'
);
$arr
[
'code'
]
=
'0'
;
//判断状态
$arr
[
'msg'
]
=
'数据请求失败'
;
//回传信息
$arr
[
'list'
]
=
[];
//将一维数组转成联动需要的数据格式
}
return
json
(
$arr
);
}
}
\ No newline at end of file
}
application/money/model/EsopPlan.php
View file @
2c909e78
...
...
@@ -16,7 +16,7 @@
{
$data_list
=
self
::
view
(
'esop_plan p'
,
true
)
->
view
(
'member'
,
'mobile, name, id_card'
,
'member.id=p.mid'
,
'left'
)
->
view
(
'stock
'
,
'title'
,
'stock
.id=p.stock_id'
,
'left'
)
->
view
(
'stock
_list'
,
'title'
,
'stock_list
.id=p.stock_id'
,
'left'
)
->
where
(
$map
)
->
order
(
$order
)
->
paginate
()
...
...
application/stock/model/StockList.php
View file @
2c909e78
...
...
@@ -8,11 +8,35 @@
// +----------------------------------------------------------------------
// | @author menghui
namespace
app\stock\model
;
use
think\model
;
use
think\Db
;
class
StockList
extends
Model
{
class
StockList
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'__STOCK_LIST__'
;
// 自动写入时间戳
protected
$autoWriteTimestamp
=
true
;
}
\ No newline at end of file
/**
* 获取股票列表(下拉选择时使用)
* @param
* @author 路人甲乙
* @return mixed
*/
public
static
function
getStockList
()
{
$list
=
[];
$where
[
'status'
]
=
1
;
$data_list
=
Db
::
name
(
'stock_list'
)
->
where
(
$where
)
->
column
(
true
,
'id'
);
if
(
!
is_null
(
$data_list
))
{
foreach
(
$data_list
as
$v
)
{
$list
[
$v
[
'id'
]]
=
$v
[
'title'
];
}
}
else
{
$list
=
[];
}
return
$list
;
}
}
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