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
9533edcf
Commit
9533edcf
authored
Jun 20, 2024
by
twj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ESOPAPP接口
parent
24917866
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
239 additions
and
159 deletions
+239
-159
application/apicom/common.php
application/apicom/common.php
+99
-85
application/apicom/home/Esop.php
application/apicom/home/Esop.php
+29
-0
application/money/admin/Esopplan.php
application/money/admin/Esopplan.php
+2
-0
application/money/admin/Esopplanrecord.php
application/money/admin/Esopplanrecord.php
+10
-6
application/money/model/EsopPlan.php
application/money/model/EsopPlan.php
+54
-39
application/money/model/EsopPlanRecord.php
application/money/model/EsopPlanRecord.php
+45
-29
No files found.
application/apicom/common.php
View file @
9533edcf
This diff is collapsed.
Click to expand it.
application/apicom/home/Esop.php
0 → 100644
View file @
9533edcf
<?php
namespace
app\apicom\home
;
use
app\money\model\EsopPlan
as
EsopPlanModel
;
use
app\money\model\EsopPlanRecord
as
EsopPlanRecordModel
;
use
think\db
;
use
think\Request
;
class
Esop
extends
Common
{
/**
* 期权计划
* @return [type] [description]
*/
public
function
getEsopPlanList
(){
if
(
!
MID
)
ajaxmsg
(
'登陆后才能进行查询'
,
0
);
// 获取查询条件
$map
=
$this
->
getMap
();
$map
[
'mid'
]
=
MID
;
$order
=
'id desc'
;
$page
=
intval
(
$this
->
request
->
param
(
"page"
));
$page
=
$page
?
$page
:
1
;
$offset
=
$page
;
// 数据列表
$data_list
=
EsopPlanModel
::
getEsopPlanList
(
$map
,
"*"
,
$order
,
$offset
);
ajaxmsg
(
'数据列表'
,
1
,
$data_list
);
}
}
\ No newline at end of file
application/money/admin/Esopplan.php
View file @
9533edcf
...
...
@@ -82,6 +82,8 @@ class Esopplan extends Admin
$data
=
$this
->
request
->
post
();
$data
[
'create_time'
]
=
time
();
$data
[
'plan_account'
]
=
$data
[
'plan_account'
]
*
100
;
$data
[
'remain_account'
]
=
$data
[
'plan_account'
]
*
100
;
$data
[
'create_ip'
]
=
get_client_ip
(
1
);
//业务逻辑处理
$result_up
=
Db
::
name
(
"esop_plan"
)
->
insert
(
$data
);
if
(
$result_up
===
1
)
{
...
...
application/money/admin/Esopplanrecord.php
View file @
9533edcf
...
...
@@ -8,6 +8,7 @@ use app\money\model\EsopPlan as EsopPlanModel;
use
app\money\model\EsopPlanRecord
as
EsopPlanRecordModel
;
use
app\member\model\Member
as
MemberModel
;
use
app\stock\model\StockList
as
StockListModel
;
use
Exception
;
use
think\Db
;
use
think\Hook
;
use
think\Cache
;
...
...
@@ -66,6 +67,7 @@ class EsopplanRecord extends Admin
->
setRowList
(
$data_list
)
->
fetch
();
// 渲染模板
}
/**
* 自动任务,根据设定的期权计划执行释放期权
*/
...
...
@@ -76,11 +78,13 @@ class EsopplanRecord extends Admin
$where
[
'status'
]
=
1
;
//开始释放期权日期不大于当前日期
$where
[
'release_time'
]
=
[
'<='
,
date
(
"Y-m-d"
)];
//已释放天数小于总天数,已释放期权小于期权总值,待行权值大于0
$esop_plan_list
=
EsopPlanModel
::
where
(
$where
)
->
where
(
"remain_account>0 and release_account<plan_account and days<duration"
)
->
select
();
//待行权值大于0
$where
[
'remain_account'
]
=
[
'>'
,
0
];
//已释放天数小于总天数,已释放期权小于期权总值
$esop_plan_list
=
EsopPlanModel
::
where
(
$where
)
->
where
(
"release_account<plan_account and days<duration"
)
->
select
();
foreach
(
$esop_plan_list
as
$k
=>
$v
)
{
//更加明细记录判断执行的当天是否已释放过
$esop_plan_record_today
=
EsopPlanRecordModel
::
where
(
"FROM_UNIXTIME(createtime,'%Y-%m-%d')=curdate()"
)
$esop_plan_record_today
=
EsopPlanRecordModel
::
where
(
"FROM_UNIXTIME(create
_
time,'%Y-%m-%d')=curdate()"
)
->
where
([
'type'
=>
1
,
'esop_plan_id'
=>
$v
[
'id'
]])
->
find
();
if
(
!
$esop_plan_record_today
)
{
//计算释放期权金额
...
...
@@ -90,15 +94,15 @@ class EsopplanRecord extends Admin
$affect
=
$v
[
'plan_account'
]
%
$v
[
'duration'
];
}
//释放期权,更新期权表
$updateData
[]
=
[
$updateData
=
[
'account'
=>
$v
[
'account'
]
+
$affect
,
'days'
=>
$v
[
'days'
]
+
1
,
'remain_account'
=>
$v
[
'plan_account'
]
-
$affect
,
'release_account'
=>
$v
[
'release_account'
]
+
$affect
];
EsopPlanModel
::
where
([
'id'
=>
$v
[
'id'
]])
->
update
(
$updateData
);
EsopPlanModel
::
where
([
'id'
=>
$v
[
'id'
]])
->
update
(
$updateData
);
//写入明细表
$arr
[]
=
[
$arr
=
[
'mid'
=>
$v
[
'mid'
],
'stock_id'
=>
$v
[
'stock_id'
],
'esop_plan_id'
=>
$v
[
'id'
],
...
...
application/money/model/EsopPlan.php
View file @
9533edcf
<?php
namespace
app\money\model
;
use
think\helper\Hash
;
use
app\money\model\Role
as
RoleModel
;
use
think\model
;
use
think\Db
;
class
EsopPlan
extends
Model
namespace
app\money\model
;
use
think\helper\Hash
;
use
app\money\model\Role
as
RoleModel
;
use
think\model
;
use
think\Db
;
class
EsopPlan
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'__ESOP_PLAN__'
;
public
static
function
getAll
(
$map
=
[],
$order
=
''
)
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'__ESOP__PLAN__'
;
public
static
function
getAll
(
$map
=
[],
$order
=
''
)
{
$data_list
=
self
::
view
(
'esop_plan p'
,
true
)
->
view
(
'member'
,
'mobile, name, id_card'
,
'member.id=p.mid'
,
'left'
)
->
view
(
'stock_list'
,
'title'
,
'stock_list.id=p.stock_id'
,
'left'
)
->
where
(
$map
)
->
order
(
$order
)
->
paginate
()
->
each
(
function
(
$item
,
$key
){
$item
->
account
=
money_convert
(
$item
->
account
);
$item
->
plan_account
=
money_convert
(
$item
->
plan_account
);
$item
->
remain_account
=
money_convert
(
$item
->
remain_account
);
$item
->
release_account
=
money_convert
(
$item
->
release_account
);
});
return
$data_list
;
}
/*
* 释放时自动更新期权计划信息
*
*/
public
static
function
plan_up
(
$id
,
$mmoney
){
return
self
::
where
([
"id"
=>
$id
])
->
update
(
$mmoney
);
}
$data_list
=
self
::
view
(
'esop_plan p'
,
true
)
->
view
(
'member'
,
'mobile, name, id_card'
,
'member.id=p.mid'
,
'left'
)
->
view
(
'stock_list'
,
'title'
,
'stock_list.id=p.stock_id'
,
'left'
)
->
where
(
$map
)
->
order
(
$order
)
->
paginate
()
->
each
(
function
(
$item
,
$key
)
{
$item
->
account
=
money_convert
(
$item
->
account
);
$item
->
plan_account
=
money_convert
(
$item
->
plan_account
);
$item
->
remain_account
=
money_convert
(
$item
->
remain_account
);
$item
->
release_account
=
money_convert
(
$item
->
release_account
);
});
return
$data_list
;
}
/**
*获取期权计划列表
* @author 2024-06-20
*/
public
static
function
getEsopPlanList
(
$where
=
[],
$field
=
'*'
,
$order
=
'id asc'
,
$offset
,
$pagesize
=
15
)
{
$esop_plan_list
=
self
::
view
(
'esop_plan ep'
,
true
)
->
view
(
"stock_list sl"
,
'title,code'
,
'stock_list.id=ep.stock_id'
,
'left'
)
->
field
([
"CONCAT(ROUND(release_account / plan_account * 100, 2), ' % ')"
=>
'accuracy'
])
->
field
([
"FROM_UNIXTIME(create_time,'%Y-%m-%d %T')"
=>
'create_time'
])
->
where
(
$where
)
->
field
(
$field
)
->
order
(
$order
)
->
page
(
$offset
,
$pagesize
)
->
select
()
->
each
(
function
(
$item
,
$key
)
{
$item
->
account
=
money_convert
(
$item
->
account
);
$item
->
plan_account
=
money_convert
(
$item
->
plan_account
);
$item
->
remain_account
=
money_convert
(
$item
->
remain_account
);
$item
->
release_account
=
money_convert
(
$item
->
release_account
);
});;
return
$esop_plan_list
;
}
?>
}
application/money/model/EsopPlanRecord.php
View file @
9533edcf
<?php
namespace
app\money\model
;
use
think\helper\Hash
;
use
app\money\model\Role
as
RoleModel
;
use
think\model
;
use
think\Db
;
class
EsopPlanRecord
extends
Model
namespace
app\money\model
;
use
think\helper\Hash
;
use
app\money\model\Role
as
RoleModel
;
use
think\model
;
use
think\Db
;
class
EsopPlanRecord
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'__ESOP_PLAN_RECORD__'
;
public
static
function
getAll
(
$map
=
[],
$order
=
''
)
{
$data_list
=
self
::
view
(
'esop_plan_record pr'
,
true
)
->
view
(
'member'
,
'mobile, name, id_card'
,
'member.id=pr.mid'
,
'left'
)
->
view
(
'stock_list'
,
'title'
,
'stock_list.id=pr.stock_id'
,
'left'
)
->
where
(
$map
)
->
order
(
$order
)
->
paginate
()
->
each
(
function
(
$item
,
$key
)
{
$item
->
affect
=
money_convert
(
$item
->
affect
);
$item
->
surplus
=
money_convert
(
$item
->
surplus
);
});
return
$data_list
;
}
/**
*获取期权明细记录列表
* @author 2024-06-20
*/
public
static
function
getEsopPlanRecordList
(
$where
=
[],
$field
=
'*'
,
$order
=
'id asc'
)
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'__ESOP__PLAN__Record__'
;
public
static
function
getAll
(
$map
=
[],
$order
=
''
)
{
$data_list
=
self
::
view
(
'esop_plan_record pr'
,
true
)
->
view
(
'member'
,
'mobile, name, id_card'
,
'member.id=pr.mid'
,
'left'
)
->
view
(
'stock_list'
,
'title'
,
'stock_list.id=pr.stock_id'
,
'left'
)
->
where
(
$map
)
->
order
(
$order
)
->
paginate
()
->
each
(
function
(
$item
,
$key
){
$item
->
affect
=
money_convert
(
$item
->
affect
);
$item
->
surplus
=
money_convert
(
$item
->
surplus
);
});
return
$data_list
;
}
$esop_plan_list
=
self
::
view
(
'esop_plan_record epr'
,
true
)
->
view
(
"stock_list sl"
,
'title,code'
,
'stock_list.id=ep.stock_id'
,
'left'
)
->
view
(
"esop_plan ep"
,
'title,code'
,
'stock_list.id=ep.stock_id'
,
'left'
)
->
where
(
$where
)
->
field
(
$field
)
->
order
(
$order
)
->
paginate
();
return
$esop_plan_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