mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update
This commit is contained in:
parent
75a5b93abd
commit
b14596f14f
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\Admin\OrderUpdate;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order;
|
||||
@ -40,6 +41,27 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function update (OrderUpdate $request) {
|
||||
$updateData = $request->only([
|
||||
'status',
|
||||
'commission_status'
|
||||
]);
|
||||
|
||||
$order = Order::where('trade_no', $request->input('trade_no'))
|
||||
->first();
|
||||
if (!$order) {
|
||||
abort(500, '订单不存在');
|
||||
}
|
||||
|
||||
if (!$order->update($updateData)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function repair (Request $request) {
|
||||
if (empty($request->input('trade_no'))) {
|
||||
abort(500, '参数错误');
|
||||
|
29
app/Http/Requests/Admin/OrderUpdate.php
Normal file
29
app/Http/Requests/Admin/OrderUpdate.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class OrderUpdate extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'status' => 'in:0,1,2,3',
|
||||
'commission_status' => 'in:0,1'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'status.in' => '销售状态格式不正确',
|
||||
'commission_status.in' => '续费状态格式不正确'
|
||||
];
|
||||
}
|
||||
}
|
@ -8,4 +8,5 @@ class Order extends Model
|
||||
{
|
||||
protected $table = 'v2_order';
|
||||
protected $dateFormat = 'U';
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ Route::prefix('v1')
|
||||
// Order
|
||||
Route::get('order', 'Admin\\OrderController@index');
|
||||
Route::post('order/repair', 'Admin\\OrderController@repair');
|
||||
Route::post('order/update', 'Admin\\OrderController@update');
|
||||
// User
|
||||
Route::get('user', 'Admin\\UserController@index');
|
||||
Route::post('user/update', 'Admin\\UserController@update');
|
||||
|
Loading…
Reference in New Issue
Block a user