Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
328f11e3
Commit
328f11e3
authored
Nov 07, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量添加币种配置
parent
1ccfcbf9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
2 deletions
+135
-2
CoinController.php
backend/controllers/CoinController.php
+62
-0
package.php
backend/views/coin/package.php
+65
-2
Coin.php
common/models/psources/Coin.php
+8
-0
No files found.
backend/controllers/CoinController.php
View file @
328f11e3
...
...
@@ -359,4 +359,66 @@ class CoinController extends BaseController
return
[
'coin'
=>
-
1
,
'msg'
=>
'币种不存在'
];
}
}
public
function
actionPackageCopy
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
Response
::
FORMAT_JSON
;
$get
=
Yii
::
$app
->
request
->
get
();
$platform_id
=
$get
[
'platform_id'
]
??
''
;
$coin_ids
=
$get
[
'coin_ids'
]
??
''
;
foreach
([
'platform_id'
=>
'钱包'
,
'coin_ids'
=>
'币种'
]
as
$key
=>
$value
)
{
if
(
empty
(
$$key
))
{
return
[
'code'
=>
-
1
,
'msg'
=>
$value
.
'不能为空'
];
}
}
$user_platform_id
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
if
(
$user_platform_id
==
Yii
::
$app
->
params
[
'admin'
])
{
$coin_id_items
=
explode
(
','
,
$coin_ids
);
foreach
(
$coin_id_items
as
$id
)
{
$coin
=
Coin
::
getOneById
(
$id
);
if
(
$coin
){
$platform_ids
=
explode
(
','
,
$coin
->
platform_id
);
$platform_ids
=
implode
(
','
,
array_unique
(
array_merge
(
$platform_ids
,
[
$platform_id
])));
$coin
->
platform_id
=
$platform_ids
;
$coin
->
save
();
}
}
return
[
'code'
=>
0
,
'msg'
=>
'复制成功'
];
}
return
[
'code'
=>
-
1
,
'msg'
=>
'没有权限修改'
];
}
}
public
function
actionPackageBatchDel
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
/* Yii::$app->response->format = Response::FORMAT_JSON;
$get = Yii::$app->request->get();
$platform_id = $get['platform_id'] ?? '';
$coin_ids = $get['coin_ids'] ?? '';
foreach (['platform_id' => '钱包', 'coin_ids' => '币种'] as $key => $value) {
if (empty($$key)) {
return ['code' => -1, 'msg' => $value . '不能为空'];
}
}
$user_platform_id = Yii::$app->user->identity->platform_id;
if ($user_platform_id == Yii::$app->params['admin']) {
$coin_id_items = explode(',',$coin_ids);
foreach($coin_id_items as $id) {
$coin = Coin::getOneById($id);
if($coin){
$platform_ids = explode(',',$coin->platform_id);
$platform_ids = implode(',', array_unique(array_merge($platform_ids, [$platform_id])));
$coin->platform_id = $platform_ids;
$coin->save();
}
}
return ['code' => 0, 'msg' => '复制成功'];
}
return ['code' => -1, 'msg' => '没有权限修改'];*/
}
}
}
backend/views/coin/package.php
View file @
328f11e3
...
...
@@ -12,6 +12,9 @@
.layui-form-label
{
width
:
100px
;
}
.myselect
.layui-input
{
height
:
25px
;
}
</style>
<div
class=
"layui-row"
>
<form
class=
"layui-form"
lay-filter=
"form2"
>
...
...
@@ -87,8 +90,18 @@
</script>
<script
type=
"text/html"
id=
"toolBarTop"
>
<
div
class
=
"layui-btn-container"
>
<
button
class
=
"layui-btn layui-btn-sm"
lay
-
event
=
"recommend_add"
>
添加
<
/button
>
<
button
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"recommend_add"
>
添加
<
/button
>
<
button
class
=
"layui-btn layui-btn-xs layui-btn-danger"
lay
-
event
=
"batch_del"
>
批量删除
<
/button
>
<
div
class
=
"layui-inline"
style
=
"padding-left:100px"
>
<
button
class
=
"layui-btn layui-btn-xs layui-btn-normal"
lay
-
event
=
"copy"
>
复制到
<
/button
>
<
div
class
=
"layui-input-inline myselect"
>
<
select
class
=
"layui-select"
name
=
"copy_platform_id"
id
=
"copy_platform_id"
>
<
option
value
=
""
>
选择一个钱包
<
/option
>
<?php
foreach
(
$platforms
as
$key
=>
$value
)
:
?>
<
option
value
=
"
<?=
$value
[
'id'
]
?>
"
>
<?=
$value
[
'name'
]
?>
<
/option
>
<?php
endforeach
;
?>
<
/select
>
<
/div
>
<
/div
>
</script>
...
...
@@ -103,6 +116,10 @@ table.render({
url
:
'/admin/coin/package'
,
cols
:
[[
{
type
:
'checkbox'
,
fixed
:
'left'
},
{
field
:
'id'
,
title
:
'ID'
},
...
...
@@ -176,6 +193,52 @@ table.on('toolbar(table1)', function(obj) {
$
(
"#_form"
).
css
(
'display'
,
'none'
);
}
});
}
else
if
(
event
==
'copy'
){
var
checkStatus
=
table
.
checkStatus
(
'table1'
)
,
data
=
checkStatus
.
data
;
var
coin_ids
=
""
;
$
.
each
(
data
,
function
(
index
,
value
){
if
(
coin_ids
){
coin_ids
+=
","
+
value
.
id
;
}
else
{
coin_ids
=
value
.
id
;
}
});
var
platform_id
=
$
(
"select[name='copy_platform_id']"
).
val
();
$
.
get
(
'/admin/coin/package-copy'
,
{
coin_ids
:
coin_ids
,
platform_id
:
platform_id
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
}
else
if
(
event
==
'batch_del'
){
var
checkStatus
=
table
.
checkStatus
(
'table1'
)
,
data
=
checkStatus
.
data
;
var
coin_ids
=
""
;
$
.
each
(
data
,
function
(
index
,
value
){
if
(
coin_ids
){
coin_ids
+=
","
+
value
.
id
;
}
else
{
coin_ids
=
value
.
id
;
}
});
var
platform_id
=
$
(
"select[name='platform_id']"
).
val
();
$
.
get
(
'/admin/coin/package-batch-del'
,
{
coin_ids
:
coin_ids
,
platform_id
:
platform_id
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
}
});
...
...
common/models/psources/Coin.php
View file @
328f11e3
...
...
@@ -252,4 +252,12 @@ class Coin extends BaseActiveRecord
}
return
$data
?
$data
:
[];
}
/**
* 获取币种
*/
public
static
function
getOneById
(
$id
)
{
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
}
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