Browse Source

取消订单增加校验器

master
Lemon 5 years ago
parent
commit
b05c228d4a
  1. 6
      app/Controller/OrderController.php
  2. 40
      app/Request/OnlineCancelRequest.php

6
app/Controller/OrderController.php

@ -7,6 +7,7 @@ use App\Constants\LogLabel;
use App\Model\OrderMain;
use App\Request\OrderOfflineRequest;
use App\Request\OrderOnlineRequest;
use App\Request\OnlineCancelRequest;
use App\Request\UserOrdersRequest;
use App\Service\SeparateAccountsServiceInterface;
use Hyperf\DbConnection\Db;
@ -101,9 +102,10 @@ class OrderController extends BaseController
/**
* 用户取消订单
* @param OnlineCancelRequest $request
*/
public function onlineCancel(){
$orderId = $this->request->input('order_id');
public function onlineCancel(OnlineCancelRequest $request){
$orderId = $request->input('order_id');
$orderMain = OrderMain::where('id',$orderId)
->select('global_order_id')
->first();

40
app/Request/OnlineCancelRequest.php

@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace App\Request;
class OnlineCancelRequest extends BaseFormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'order_id' => 'required|nonempty|integer|exists:ims_cjdc_order_main,id',
];
}
public function messages(): array
{
return [
'order_id.*' => ':attribute信息不正确',
];
}
public function attributes(): array
{
return [
'order_id' => '订单号',
];
}
}
Loading…
Cancel
Save