mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 17:31:49 +08:00 
			
		
		
		
	update: add coupon and notice switch
This commit is contained in:
		| @@ -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) | ||||
|     { | ||||
|         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) | ||||
|     { | ||||
|         if (empty($request->input('id'))) { | ||||
|   | ||||
| @@ -13,7 +13,8 @@ class NoticeController extends Controller | ||||
|     { | ||||
|         $current = $request->input('current') ? $request->input('current') : 1; | ||||
|         $pageSize = 5; | ||||
|         $model = Notice::orderBy('created_at', 'DESC'); | ||||
|         $model = Notice::orderBy('created_at', 'DESC') | ||||
|             ->where('show', 1); | ||||
|         $total = $model->count(); | ||||
|         $res = $model->forPage($current, $pageSize) | ||||
|             ->get(); | ||||
|   | ||||
| @@ -87,6 +87,7 @@ class AdminRoute | ||||
|             $router->post('/notice/save', 'Admin\\NoticeController@save'); | ||||
|             $router->post('/notice/update', 'Admin\\NoticeController@update'); | ||||
|             $router->post('/notice/drop', 'Admin\\NoticeController@drop'); | ||||
|             $router->post('/notice/show', 'Admin\\NoticeController@show'); | ||||
|             // Ticket | ||||
|             $router->get ('/ticket/fetch', 'Admin\\TicketController@fetch'); | ||||
|             $router->post('/ticket/reply', 'Admin\\TicketController@reply'); | ||||
| @@ -95,6 +96,7 @@ class AdminRoute | ||||
|             $router->get ('/coupon/fetch', 'Admin\\CouponController@fetch'); | ||||
|             $router->post('/coupon/generate', 'Admin\\CouponController@generate'); | ||||
|             $router->post('/coupon/drop', 'Admin\\CouponController@drop'); | ||||
|             $router->post('/coupon/show', 'Admin\\CouponController@show'); | ||||
|             // Knowledge | ||||
|             $router->get ('/knowledge/fetch', 'Admin\\KnowledgeController@fetch'); | ||||
|             $router->get ('/knowledge/getCategory', 'Admin\\KnowledgeController@getCategory'); | ||||
|   | ||||
| @@ -81,7 +81,7 @@ class CouponService | ||||
|  | ||||
|     public function check() | ||||
|     { | ||||
|         if (!$this->coupon) { | ||||
|         if (!$this->coupon || !$this->coupon->show) { | ||||
|             abort(500, __('Invalid coupon')); | ||||
|         } | ||||
|         if ($this->coupon->limit_use <= 0 && $this->coupon->limit_use !== NULL) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user