This commit is contained in:
root 2019-11-29 01:58:20 +08:00
parent 75a5b93abd
commit b14596f14f
4 changed files with 53 additions and 0 deletions

View File

@ -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, '参数错误');

View 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' => '续费状态格式不正确'
];
}
}

View File

@ -8,4 +8,5 @@ class Order extends Model
{
protected $table = 'v2_order';
protected $dateFormat = 'U';
protected $guarded = ['id'];
}

View File

@ -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');