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
35a7af46
Commit
35a7af46
authored
Jun 20, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空投类型
parent
7c8ae3b7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
296 additions
and
0 deletions
+296
-0
InvestmentController.php
backend/controllers/InvestmentController.php
+107
-0
type-add.php
backend/views/investment/type-add.php
+21
-0
type-update.php
backend/views/investment/type-update.php
+21
-0
type.php
backend/views/investment/type.php
+27
-0
index.js
backend/web/js/investment-type/index.js
+83
-0
InvestmentType.php
common/models/pwallet/InvestmentType.php
+37
-0
No files found.
backend/controllers/InvestmentController.php
0 → 100644
View file @
35a7af46
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-13
* Time: 下午3:22
*/
namespace
backend\controllers
;
use
Yii
;
use
common\models\pwallet\InvestmentType
;
class
InvestmentController
extends
BaseController
{
public
function
actionIndex
()
{
return
$this
->
render
(
'index'
);
}
public
function
actionAddOne
()
{
$this
->
layout
=
false
;
return
$this
->
render
(
'form_add_one'
);
}
public
function
actionType
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
return
InvestmentType
::
getList
(
1
,
999
,
[]);
}
return
$this
->
render
(
'type'
);
}
public
function
actionTypeAdd
()
{
$this
->
layout
=
false
;
if
(
Yii
::
$app
->
request
->
isGet
)
{
return
$this
->
render
(
'type-add'
);
}
elseif
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$name
=
Yii
::
$app
->
request
->
post
(
'name'
,
''
);
if
(
$name
)
{
if
(
!
InvestmentType
::
isExists
(
$name
))
{
$model
=
new
InvestmentType
();
$model
->
name
=
$name
;
$model
->
create_at
=
date
(
'Y-m-d H:i:s'
);
$model
->
save
();
}
else
{
return
[
'code'
=>
2
,
'msg'
=>
'类型已经存在'
];
}
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'名称不能为空'
];
}
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
public
function
actionTypeDelete
(
$id
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$model
=
InvestmentType
::
findOne
([
'id'
=>
$id
]);
if
(
$model
)
{
try
{
$model
->
delete
();
}
catch
(
\Exception
|
\Throwable
$e
)
{
return
[
'code'
=>
$e
->
getCode
(),
'msg'
=>
$e
->
getMessage
()];
}
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'类型不存在'
];
}
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
public
function
actionTypeUpdate
()
{
if
(
Yii
::
$app
->
request
->
isGet
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
0
);
$model
=
InvestmentType
::
findOne
([
'id'
=>
$id
]);
if
(
$model
)
{
$this
->
layout
=
false
;
return
$this
->
render
(
'type-update'
,
[
'model'
=>
$model
]);
}
else
{
Yii
::
$app
->
response
->
format
=
'json'
;
return
[
'code'
=>
1
,
'msg'
=>
'类型不存在'
];
}
}
elseif
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
post
(
'id'
,
0
);
$name
=
Yii
::
$app
->
request
->
post
(
'name'
,
0
);
$model
=
InvestmentType
::
findOne
([
'id'
=>
$id
]);
if
(
$model
)
{
$model
->
name
=
$name
;
$model
->
save
();
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'类型不存在'
];
}
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
}
\ No newline at end of file
backend/views/investment/type-add.php
0 → 100644
View file @
35a7af46
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-20
* Time: 下午3:09
*/
?>
<div
style=
"padding: 5px;"
>
<form
id=
"type-add"
class=
"layui-form"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
名称
</label>
<div
class=
"layui-input-inline"
>
<input
name=
"name"
class=
"layui-input"
>
</div>
</div>
</form>
</div>
backend/views/investment/type-update.php
0 → 100644
View file @
35a7af46
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-20
* Time: 下午4:27
*/
?>
<div
style=
"padding: 5px;"
>
<form
id=
"type-update"
class=
"layui-form"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
type=
"hidden"
name=
"id"
value=
"
<?=
$model
->
id
?>
"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
名称
</label>
<div
class=
"layui-input-inline"
>
<input
name=
"name"
class=
"layui-input"
value=
"
<?=
$model
->
name
?>
"
>
</div>
</div>
</form>
</div>
backend/views/investment/type.php
0 → 100644
View file @
35a7af46
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-20
* Time: 下午2:46
*/
/**
* @var \yii\web\View $this
*/
$this
->
registerJsFile
(
'@web/js/investment-type/index.js'
);
?>
<h4>
空投类型管理
</h4>
<div
class=
"layui-row"
>
<button
class=
"layui-btn"
id=
"add"
>
添加类型
</button>
</div>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md6"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
</div>
<script
type=
"text/html"
id=
"operationTpl"
>
<
button
class
=
"layui-btn layui-btn-sm"
lay
-
event
=
"update"
>
修改
<
/button
>
<
button
class
=
"layui-btn layui-btn-sm layui-btn-danger"
lay
-
event
=
"delete"
>
删除
<
/button
>
</script>
backend/web/js/investment-type/index.js
0 → 100644
View file @
35a7af46
/**
* 空投类型js
* @author rlgyzhcn@qq.com
*/
var
table
=
layui
.
table
;
table
.
render
({
elem
:
"#table1"
,
url
:
'/admin/investment/type'
,
cols
:
[[
{
field
:
'id'
,
title
:
"ID"
},
{
field
:
'name'
,
title
:
"类型"
},
{
title
:
'操作'
,
templet
:
"#operationTpl"
}
]],
});
$
(
"#add"
).
click
(
function
()
{
$
.
get
(
'/admin/investment/type-add'
,
{},
function
(
str
)
{
var
index
=
layer
.
open
({
type
:
1
,
title
:
'添加类型'
,
id
:
'addType'
,
skin
:
'layui-layer-lan'
,
area
:
[
'320px'
,
'auto'
],
content
:
str
,
btn
:
[
'确认'
,
'取消'
],
btn1
:
function
()
{
var
name
=
$
(
"#type-add input[name='name']"
).
val
();
var
_csrf
=
$
(
"#type-add input[name='_csrf']"
).
val
();
$
.
post
(
'/admin/investment/type-add'
,
{
_csrf
:
_csrf
,
name
:
name
},
function
(
res
)
{
layer
.
msg
(
res
.
msg
);
if
(
res
.
code
==
0
)
{
layer
.
close
(
index
);
table
.
reload
(
'table1'
,
{
curr
:
1
});
}
});
}
});
});
});
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
data
=
obj
.
data
;
var
event
=
obj
.
event
;
if
(
event
==
'delete'
)
{
var
confirm
=
layer
.
confirm
(
'删除?'
,
{
icon
:
3
,
title
:
'删除'
},
function
(
index
)
{
$
.
get
(
'/admin/investment/type-delete'
,
{
id
:
data
.
id
},
function
(
res
)
{
layer
.
close
(
confirm
);
table
.
reload
(
'table1'
,
{
curr
:
1
});
});
});
}
else
if
(
event
==
'update'
)
{
$
.
get
(
'/admin/investment/type-update'
,
{
id
:
data
.
id
},
function
(
res
)
{
if
(
typeof
res
!=
'string'
&&
res
.
code
!=
0
)
{
layer
.
msg
(
res
.
msg
);
}
else
{
var
index
=
layer
.
open
({
type
:
1
,
title
:
'修改'
,
id
:
'updateType'
,
skin
:
'layui-layer-lan'
,
area
:
[
'320px'
,
'auto'
],
content
:
res
,
btn
:
[
'确认'
,
'取消'
],
btn1
:
function
()
{
var
name
=
$
(
"#type-update input[name='name']"
).
val
();
var
_csrf
=
$
(
"#type-update input[name='_csrf']"
).
val
();
$
.
post
(
'/admin/investment/type-update'
,
{
_csrf
:
_csrf
,
name
:
name
,
id
:
data
.
id
},
function
(
res
)
{
layer
.
msg
(
res
.
msg
);
if
(
res
.
code
==
0
)
{
layer
.
close
(
index
);
table
.
reload
(
'table1'
,
{
curr
:
1
});
}
});
}
});
}
})
}
});
\ No newline at end of file
common/models/pwallet/InvestmentType.php
0 → 100644
View file @
35a7af46
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-20
* Time: 下午3:28
*/
namespace
common\models\pwallet
;
use
Yii
;
use
common\core\BaseActiveRecord
;
/**
* Class InvestmentType
* @property integer $id
* @property string $name
* @property string $create_at
* @package common\models\pwallet
*/
class
InvestmentType
extends
BaseActiveRecord
{
/**
* @return null|object|\yii\db\Connection
* @throws \yii\base\InvalidConfigException
*/
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'db_pwallet'
);
}
public
static
function
isExists
(
$name
)
{
return
(
bool
)
self
::
findOne
([
'name'
=>
$name
]);
}
}
\ No newline at end of file
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