mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: add coupon and notice switch
This commit is contained in:
parent
94a7ab412c
commit
1790de63f6
@ -30,6 +30,25 @@ class CouponController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function show(Request $request)
|
||||||
|
{
|
||||||
|
if (empty($request->input('id'))) {
|
||||||
|
abort(500, '参数有误');
|
||||||
|
}
|
||||||
|
$coupon = Coupon::find($request->input('id'));
|
||||||
|
if (!$coupon) {
|
||||||
|
abort(500, '优惠券不存在');
|
||||||
|
}
|
||||||
|
$coupon->show = $coupon->show ? 0 : 1;
|
||||||
|
if (!$coupon->save()) {
|
||||||
|
abort(500, '保存失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response([
|
||||||
|
'data' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function generate(CouponGenerate $request)
|
public function generate(CouponGenerate $request)
|
||||||
{
|
{
|
||||||
if ($request->input('generate_count')) {
|
if ($request->input('generate_count')) {
|
||||||
|
@ -40,6 +40,27 @@ class NoticeController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function show(Request $request)
|
||||||
|
{
|
||||||
|
if (empty($request->input('id'))) {
|
||||||
|
abort(500, '参数有误');
|
||||||
|
}
|
||||||
|
$notice = Notice::find($request->input('id'));
|
||||||
|
if (!$notice) {
|
||||||
|
abort(500, '公告不存在');
|
||||||
|
}
|
||||||
|
$notice->show = $notice->show ? 0 : 1;
|
||||||
|
if (!$notice->save()) {
|
||||||
|
abort(500, '保存失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response([
|
||||||
|
'data' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function drop(Request $request)
|
public function drop(Request $request)
|
||||||
{
|
{
|
||||||
if (empty($request->input('id'))) {
|
if (empty($request->input('id'))) {
|
||||||
|
@ -13,7 +13,8 @@ class NoticeController extends Controller
|
|||||||
{
|
{
|
||||||
$current = $request->input('current') ? $request->input('current') : 1;
|
$current = $request->input('current') ? $request->input('current') : 1;
|
||||||
$pageSize = 5;
|
$pageSize = 5;
|
||||||
$model = Notice::orderBy('created_at', 'DESC');
|
$model = Notice::orderBy('created_at', 'DESC')
|
||||||
|
->where('show', 1);
|
||||||
$total = $model->count();
|
$total = $model->count();
|
||||||
$res = $model->forPage($current, $pageSize)
|
$res = $model->forPage($current, $pageSize)
|
||||||
->get();
|
->get();
|
||||||
|
@ -87,6 +87,7 @@ class AdminRoute
|
|||||||
$router->post('/notice/save', 'Admin\\NoticeController@save');
|
$router->post('/notice/save', 'Admin\\NoticeController@save');
|
||||||
$router->post('/notice/update', 'Admin\\NoticeController@update');
|
$router->post('/notice/update', 'Admin\\NoticeController@update');
|
||||||
$router->post('/notice/drop', 'Admin\\NoticeController@drop');
|
$router->post('/notice/drop', 'Admin\\NoticeController@drop');
|
||||||
|
$router->post('/notice/show', 'Admin\\NoticeController@show');
|
||||||
// Ticket
|
// Ticket
|
||||||
$router->get ('/ticket/fetch', 'Admin\\TicketController@fetch');
|
$router->get ('/ticket/fetch', 'Admin\\TicketController@fetch');
|
||||||
$router->post('/ticket/reply', 'Admin\\TicketController@reply');
|
$router->post('/ticket/reply', 'Admin\\TicketController@reply');
|
||||||
@ -95,6 +96,7 @@ class AdminRoute
|
|||||||
$router->get ('/coupon/fetch', 'Admin\\CouponController@fetch');
|
$router->get ('/coupon/fetch', 'Admin\\CouponController@fetch');
|
||||||
$router->post('/coupon/generate', 'Admin\\CouponController@generate');
|
$router->post('/coupon/generate', 'Admin\\CouponController@generate');
|
||||||
$router->post('/coupon/drop', 'Admin\\CouponController@drop');
|
$router->post('/coupon/drop', 'Admin\\CouponController@drop');
|
||||||
|
$router->post('/coupon/show', 'Admin\\CouponController@show');
|
||||||
// Knowledge
|
// Knowledge
|
||||||
$router->get ('/knowledge/fetch', 'Admin\\KnowledgeController@fetch');
|
$router->get ('/knowledge/fetch', 'Admin\\KnowledgeController@fetch');
|
||||||
$router->get ('/knowledge/getCategory', 'Admin\\KnowledgeController@getCategory');
|
$router->get ('/knowledge/getCategory', 'Admin\\KnowledgeController@getCategory');
|
||||||
|
@ -81,7 +81,7 @@ class CouponService
|
|||||||
|
|
||||||
public function check()
|
public function check()
|
||||||
{
|
{
|
||||||
if (!$this->coupon) {
|
if (!$this->coupon || !$this->coupon->show) {
|
||||||
abort(500, __('Invalid coupon'));
|
abort(500, __('Invalid coupon'));
|
||||||
}
|
}
|
||||||
if ($this->coupon->limit_use <= 0 && $this->coupon->limit_use !== NULL) {
|
if ($this->coupon->limit_use <= 0 && $this->coupon->limit_use !== NULL) {
|
||||||
|
@ -40,6 +40,7 @@ CREATE TABLE `v2_coupon` (
|
|||||||
`name` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
|
`name` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
|
||||||
`type` tinyint(1) NOT NULL,
|
`type` tinyint(1) NOT NULL,
|
||||||
`value` int(11) NOT NULL,
|
`value` int(11) NOT NULL,
|
||||||
|
`show` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
`limit_use` int(11) DEFAULT NULL,
|
`limit_use` int(11) DEFAULT NULL,
|
||||||
`limit_use_with_user` int(11) DEFAULT NULL,
|
`limit_use_with_user` int(11) DEFAULT NULL,
|
||||||
`limit_plan_ids` varchar(255) DEFAULT NULL,
|
`limit_plan_ids` varchar(255) DEFAULT NULL,
|
||||||
@ -98,6 +99,7 @@ CREATE TABLE `v2_notice` (
|
|||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`title` varchar(255) NOT NULL,
|
`title` varchar(255) NOT NULL,
|
||||||
`content` text NOT NULL,
|
`content` text NOT NULL,
|
||||||
|
`show` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
`img_url` varchar(255) DEFAULT NULL,
|
`img_url` varchar(255) DEFAULT NULL,
|
||||||
`created_at` int(11) NOT NULL,
|
`created_at` int(11) NOT NULL,
|
||||||
`updated_at` int(11) NOT NULL,
|
`updated_at` int(11) NOT NULL,
|
||||||
@ -369,4 +371,4 @@ CREATE TABLE `v2_user` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- 2022-01-04 16:20:42
|
-- 2022-01-21 18:20:29
|
||||||
|
@ -477,3 +477,9 @@ DROP `alter_id`;
|
|||||||
|
|
||||||
ALTER TABLE `v2_user`
|
ALTER TABLE `v2_user`
|
||||||
CHANGE `commission_type` `commission_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0: system 1: period 2: onetime' AFTER `discount`;
|
CHANGE `commission_type` `commission_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0: system 1: period 2: onetime' AFTER `discount`;
|
||||||
|
|
||||||
|
ALTER TABLE `v2_coupon`
|
||||||
|
ADD `show` tinyint(1) NOT NULL DEFAULT '0' AFTER `value`;
|
||||||
|
|
||||||
|
ALTER TABLE `v2_notice`
|
||||||
|
ADD `show` tinyint(1) NOT NULL DEFAULT '0' AFTER `content`;
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user