mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
update
This commit is contained in:
parent
2eb594a4fa
commit
9eefb32a4c
@ -9,5 +9,21 @@ use App\Models\Coupon;
|
|||||||
class CouponController extends Controller
|
class CouponController extends Controller
|
||||||
{
|
{
|
||||||
public function check (Request $request) {
|
public function check (Request $request) {
|
||||||
|
if (empty($request->input('code'))) {
|
||||||
|
abort(500, '参数错误');
|
||||||
|
}
|
||||||
|
$coupon = Coupon::where('code', $request->input('code'))->first();
|
||||||
|
if (!$coupon) {
|
||||||
|
abort(500, '优惠券无效');
|
||||||
|
}
|
||||||
|
if (time() < $coupon->started_at) {
|
||||||
|
abort(500, '优惠券还未到可用时间');
|
||||||
|
}
|
||||||
|
if (time() > $coupon->ended_at) {
|
||||||
|
abort(500, '优惠券已过期');
|
||||||
|
}
|
||||||
|
return response([
|
||||||
|
'data' => $coupon
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,13 @@ SET NAMES utf8mb4;
|
|||||||
DROP TABLE IF EXISTS `v2_coupon`;
|
DROP TABLE IF EXISTS `v2_coupon`;
|
||||||
CREATE TABLE `v2_coupon` (
|
CREATE TABLE `v2_coupon` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`code` char(8) NOT NULL,
|
||||||
`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,
|
||||||
`status` tinyint(1) NOT NULL DEFAULT '0',
|
`limit_use` int(11) DEFAULT NULL,
|
||||||
`expired_at` int(11) NOT NULL,
|
`started_at` int(11) NOT NULL,
|
||||||
|
`ended_at` int(11) NOT 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,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
@ -200,4 +202,4 @@ CREATE TABLE `v2_user` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- 2019-12-31 09:09:02
|
-- 2019-12-31 17:47:41
|
@ -98,6 +98,8 @@ Route::prefix('v1')
|
|||||||
// Server
|
// Server
|
||||||
Route::get ('server/fetch', 'ServerController@fetch');
|
Route::get ('server/fetch', 'ServerController@fetch');
|
||||||
Route::get ('server/log/fetch', 'ServerController@logFetch');
|
Route::get ('server/log/fetch', 'ServerController@logFetch');
|
||||||
|
// Coupon
|
||||||
|
Route::post('coupon/check', 'CouponController@check');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Passport
|
// Passport
|
||||||
|
11
update.sql
11
update.sql
@ -103,3 +103,14 @@ CREATE TABLE `v2_coupon` (
|
|||||||
`created_at` int(11) NOT NULL,
|
`created_at` int(11) NOT NULL,
|
||||||
`updated_at` int(11) NOT NULL,
|
`updated_at` int(11) NOT NULL,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `v2_coupon_log` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`coupon_id` int(11) NOT NULL,
|
||||||
|
`user_id` int(11) NOT NULL,
|
||||||
|
`order_id` int(11) NOT NULL,
|
||||||
|
`total_amount` int(11) NOT NULL,
|
||||||
|
`discount_amount` int(11) NOT NULL,
|
||||||
|
`created_at` int(11) NOT NULL,
|
||||||
|
`updated_at` int(11) NOT NULL
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user