update: order manual

This commit is contained in:
tokumeikoi
2021-08-28 15:11:59 +09:00
parent 23462e2753
commit c95d374cc0
5 changed files with 61 additions and 68 deletions

View File

@ -63,10 +63,45 @@ class OrderController extends Controller
]);
}
public function paid(Request $request)
{
$order = Order::where('trade_no', $request->input('trade_no'))
->first();
if (!$order) {
abort(500, '订单不存在');
}
if ($order->status !== 0) abort(500, '只能对待支付的订单进行操作');
$orderService = new OrderService($order);
if (!$orderService->paid('manual_operation')) {
abort(500, '更新失败');
}
return response([
'data' => true
]);
}
public function cancel(Request $request)
{
$order = Order::where('trade_no', $request->input('trade_no'))
->first();
if (!$order) {
abort(500, '订单不存在');
}
if ($order->status !== 0) abort(500, '只能对待支付的订单进行操作');
$orderService = new OrderService($order);
if (!$orderService->cancel()) {
abort(500, '更新失败');
}
return response([
'data' => true
]);
}
public function update(OrderUpdate $request)
{
$params = $request->only([
'status',
'commission_status'
]);
@ -76,27 +111,6 @@ class OrderController extends Controller
abort(500, '订单不存在');
}
if (isset($params['status'])) {
$orderService = new OrderService($order);
switch ((int)$params['status']) {
case 1: {
if (!$orderService->success(time())) {
abort(500, '更新失败');
}
break;
}
case 2: {
if (!$orderService->cancel()) {
abort(500, '更新失败');
}
break;
}
}
return response([
'data' => true
]);
}
try {
$order->update($params);
} catch (\Exception $e) {
@ -108,26 +122,6 @@ class OrderController extends Controller
]);
}
public function repair(Request $request)
{
if (empty($request->input('trade_no'))) {
abort(500, '参数错误');
}
$order = Order::where('trade_no', $request->input('trade_no'))
->where('status', 0)
->first();
if (!$order) {
abort(500, '订单不存在或订单已支付');
}
$order->status = 1;
if (!$order->save()) {
abort(500, '保存失败');
}
return response([
'data' => true
]);
}
public function assign(OrderAssign $request)
{
$plan = Plan::find($request->input('plan_id'));

View File

@ -34,7 +34,7 @@ class PaymentController extends Controller
}
if ($order->status === 1) return true;
$orderService = new OrderService($order);
if (!$orderService->success($callbackNo)) {
if (!$orderService->paid($callbackNo)) {
return false;
}
$telegramService = new TelegramService();