取消订单
This commit is contained in:
parent
9efe1d4233
commit
2a46e58e23
@ -63,7 +63,6 @@ class OrderController extends Controller
|
||||
$order_at = Carbon::parse($res->last()->order_at);
|
||||
$conditions['starttime'] = $order_at->copy()->startOfMonth()->startOfDay()->format('Y-m-d H:i:s');
|
||||
$conditions['endtime'] = $order_at->copy()->endOfMonth()->endOfDay()->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
$count = $this->orderService->count($conditions);
|
||||
$count['starttime'] = $conditions['starttime'];
|
||||
@ -84,4 +83,18 @@ class OrderController extends Controller
|
||||
|
||||
return res($res, '下单成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$ids = $this->request->ids();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$res = $this->orderService->cancel($id);
|
||||
}
|
||||
|
||||
return res(true, '取消成功');
|
||||
}
|
||||
}
|
||||
|
@ -27,5 +27,6 @@ $router->group(['prefix' => 'companies', 'as' => 'companies'], function ($router
|
||||
|
||||
$router->get('/orders/paginate', ['as' => 'orders/paginate', 'uses' => 'OrderController@paginate']);
|
||||
$router->post('/orders/store', ['as' => 'orders/store', 'uses' => 'OrderController@store']);
|
||||
$router->post('/orders/cancel', ['as' => 'orders/cancel', 'uses' => 'OrderController@cancel']);
|
||||
});
|
||||
});
|
||||
|
@ -141,6 +141,21 @@ class OrderService extends Service
|
||||
*/
|
||||
public function cancel($id)
|
||||
{
|
||||
if (!$node = $this->orderRepository->find($id)) {
|
||||
throw new NotExistException('订单不存在或已删除');
|
||||
}
|
||||
|
||||
if ($node->order_status !== 0) {
|
||||
throw new NotExistException('订单已出库,不能取消');
|
||||
}
|
||||
|
||||
if ($node->transaction_status !== 0) {
|
||||
throw new NotExistException('订单已付款,不能取消');
|
||||
}
|
||||
|
||||
$this->orderRepository->setModel($node)->update(['order_status' => 1]);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user