This commit is contained in:
root 2020-01-02 00:05:54 +08:00
parent 453a078cd5
commit 9f4c19bcab

View File

@ -54,7 +54,17 @@ class OrderController extends Controller
]); ]);
} }
private function isExistNotPayOrder () {
return Order::where('status', 1)
->where('user_id', $request->session()->get('id'))
->first();
}
public function save (OrderSave $request) { public function save (OrderSave $request) {
if ($this->isExistNotPayOrder()) {
abort(500, '存在未付款订单,请取消后再试');
}
$plan = Plan::find($request->input('plan_id')); $plan = Plan::find($request->input('plan_id'));
$user = User::find($request->session()->get('id')); $user = User::find($request->session()->get('id'));
@ -257,6 +267,25 @@ class OrderController extends Controller
]); ]);
} }
public function cancel (Request $request) {
if (empty($request->input('trade_no'))) {
abort(500, '参数有误');
}
$order = Order::where('trade_no', $request->input('trade_no'))
->where('user_id', $request->session()->get('id'))
->first();
if (!$order) {
abort(500, '订单不存在');
}
$order->status = 2;
if (!$order->save()) {
abort(500, '取消失败');
}
return response([
'data' => true
]);
}
private function alipayF2F ($tradeNo, $totalAmount) { private function alipayF2F ($tradeNo, $totalAmount) {
$gateway = Omnipay::create('Alipay_AopF2F'); $gateway = Omnipay::create('Alipay_AopF2F');
$gateway->setSignType('RSA2'); //RSA/RSA2 $gateway->setSignType('RSA2'); //RSA/RSA2