mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update
This commit is contained in:
parent
70c1d5c874
commit
2d7d5a564e
37
app/Http/Controllers/Admin/CouponController.php
Normal file
37
app/Http/Controllers/Admin/CouponController.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Requests\Admin\CouponSave;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
use App\Models\Helper;
|
||||||
|
|
||||||
|
class CouponController extends Controller
|
||||||
|
{
|
||||||
|
public function fetch (Request $request) {
|
||||||
|
return response([
|
||||||
|
'data' => Coupon::all()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save (Request $request) {
|
||||||
|
$params = $request->only([
|
||||||
|
'name',
|
||||||
|
'type',
|
||||||
|
'value',
|
||||||
|
'expired_at',
|
||||||
|
'limit_use'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$params['code'] = Helper::guid();
|
||||||
|
if (!Coupon::create($params)) {
|
||||||
|
abort(500, '创建失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response([
|
||||||
|
'data' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
13
app/Http/Controllers/CoponController.php
Normal file
13
app/Http/Controllers/CoponController.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Coupon;
|
||||||
|
|
||||||
|
class CouponController extends Controller
|
||||||
|
{
|
||||||
|
public function check (Request $request) {
|
||||||
|
}
|
||||||
|
}
|
38
app/Http/Requests/Admin/CouponSave.php
Normal file
38
app/Http/Requests/Admin/CouponSave.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class CouponSave extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required',
|
||||||
|
'type' => 'required|in:1,2',
|
||||||
|
'value' => 'required|integer',
|
||||||
|
'expired_at' => 'required|integer',
|
||||||
|
'limit_use' => 'nullable|integer'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name.required' => '名称不能为空',
|
||||||
|
'type.required' => '类型不能为空',
|
||||||
|
'type.in' => '类型格式有误',
|
||||||
|
'value.required' => '金额或比例不能为空',
|
||||||
|
'value.integer' => '金额或比例格式有误',
|
||||||
|
'expired_at.required' => '过期时间不能为空',
|
||||||
|
'expired_at.integer' => '过期时间格式有误',
|
||||||
|
'limit_use.integer' => '使用次数格式有误'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
12
app/Models/Coupon.php
Normal file
12
app/Models/Coupon.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Coupon extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'v2_coupon';
|
||||||
|
protected $dateFormat = 'U';
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
}
|
20
install.sql
20
install.sql
@ -5,6 +5,22 @@ SET time_zone = '+00:00';
|
|||||||
SET foreign_key_checks = 0;
|
SET foreign_key_checks = 0;
|
||||||
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
|
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `v2_coupon`;
|
||||||
|
CREATE TABLE `v2_coupon` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
|
||||||
|
`type` tinyint(1) NOT NULL,
|
||||||
|
`value` int(11) NOT NULL,
|
||||||
|
`status` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`expired_at` int(11) NOT NULL,
|
||||||
|
`created_at` int(11) NOT NULL,
|
||||||
|
`updated_at` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `v2_invite_code`;
|
DROP TABLE IF EXISTS `v2_invite_code`;
|
||||||
CREATE TABLE `v2_invite_code` (
|
CREATE TABLE `v2_invite_code` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
@ -81,8 +97,6 @@ CREATE TABLE `v2_plan` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `v2_server`;
|
DROP TABLE IF EXISTS `v2_server`;
|
||||||
CREATE TABLE `v2_server` (
|
CREATE TABLE `v2_server` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
@ -186,4 +200,4 @@ CREATE TABLE `v2_user` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- 2019-12-30 11:13:16
|
-- 2019-12-31 09:09:02
|
@ -56,6 +56,9 @@ Route::prefix('v1')
|
|||||||
Route::post('ticket/close', 'Admin\\TicketController@close');
|
Route::post('ticket/close', 'Admin\\TicketController@close');
|
||||||
// Mail
|
// Mail
|
||||||
Route::post('mail/send', 'Admin\\MailController@send');
|
Route::post('mail/send', 'Admin\\MailController@send');
|
||||||
|
// Coupon
|
||||||
|
Route::get ('coupon/fetch', 'Admin\\CouponController@fetch');
|
||||||
|
Route::post('coupon/save', 'Admin\\CouponController@save');
|
||||||
});
|
});
|
||||||
// User
|
// User
|
||||||
Route::prefix('user')
|
Route::prefix('user')
|
||||||
|
12
update.sql
12
update.sql
@ -90,3 +90,15 @@ CREATE TABLE `v2_mail_log` (
|
|||||||
`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` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
`code` char(32) NOT NULL,
|
||||||
|
`name` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
|
||||||
|
`type` tinyint(1) NOT NULL,
|
||||||
|
`value` int(11) NOT NULL,
|
||||||
|
`status` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
|
`expired_at` int(11) NOT NULL,
|
||||||
|
`created_at` int(11) NOT NULL,
|
||||||
|
`updated_at` int(11) NOT NULL
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user