mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update: order manual
This commit is contained in:
parent
23462e2753
commit
c95d374cc0
@ -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)
|
public function update(OrderUpdate $request)
|
||||||
{
|
{
|
||||||
$params = $request->only([
|
$params = $request->only([
|
||||||
'status',
|
|
||||||
'commission_status'
|
'commission_status'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -76,27 +111,6 @@ class OrderController extends Controller
|
|||||||
abort(500, '订单不存在');
|
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 {
|
try {
|
||||||
$order->update($params);
|
$order->update($params);
|
||||||
} catch (\Exception $e) {
|
} 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)
|
public function assign(OrderAssign $request)
|
||||||
{
|
{
|
||||||
$plan = Plan::find($request->input('plan_id'));
|
$plan = Plan::find($request->input('plan_id'));
|
||||||
|
@ -34,7 +34,7 @@ class PaymentController extends Controller
|
|||||||
}
|
}
|
||||||
if ($order->status === 1) return true;
|
if ($order->status === 1) return true;
|
||||||
$orderService = new OrderService($order);
|
$orderService = new OrderService($order);
|
||||||
if (!$orderService->success($callbackNo)) {
|
if (!$orderService->paid($callbackNo)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$telegramService = new TelegramService();
|
$telegramService = new TelegramService();
|
||||||
|
@ -63,9 +63,10 @@ class AdminRoute
|
|||||||
});
|
});
|
||||||
// Order
|
// Order
|
||||||
$router->get ('/order/fetch', 'Admin\\OrderController@fetch');
|
$router->get ('/order/fetch', 'Admin\\OrderController@fetch');
|
||||||
$router->post('/order/repair', 'Admin\\OrderController@repair');
|
|
||||||
$router->post('/order/update', 'Admin\\OrderController@update');
|
$router->post('/order/update', 'Admin\\OrderController@update');
|
||||||
$router->post('/order/assign', 'Admin\\OrderController@assign');
|
$router->post('/order/assign', 'Admin\\OrderController@assign');
|
||||||
|
$router->post('/order/paid', 'Admin\\OrderController@paid');
|
||||||
|
$router->post('/order/cancel', 'Admin\\OrderController@cancel');
|
||||||
// User
|
// User
|
||||||
$router->get ('/user/fetch', 'Admin\\UserController@fetch');
|
$router->get ('/user/fetch', 'Admin\\UserController@fetch');
|
||||||
$router->post('/user/update', 'Admin\\UserController@update');
|
$router->post('/user/update', 'Admin\\UserController@update');
|
||||||
|
@ -81,25 +81,6 @@ class OrderService
|
|||||||
DB::commit();
|
DB::commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancel():bool
|
|
||||||
{
|
|
||||||
$order = $this->order;
|
|
||||||
DB::beginTransaction();
|
|
||||||
$order->status = 2;
|
|
||||||
if (!$order->save()) {
|
|
||||||
DB::rollBack();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($order->balance_amount) {
|
|
||||||
$userService = new UserService();
|
|
||||||
if (!$userService->addBalance($order->user_id, $order->balance_amount)) {
|
|
||||||
DB::rollBack();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DB::commit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setOrderType(User $user)
|
public function setOrderType(User $user)
|
||||||
{
|
{
|
||||||
@ -232,18 +213,35 @@ class OrderService
|
|||||||
$order->surplus_order_ids = array_column($orders->toArray(), 'id');
|
$order->surplus_order_ids = array_column($orders->toArray(), 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function success(string $callbackNo)
|
public function paid(string $callbackNo)
|
||||||
{
|
{
|
||||||
$order = $this->order;
|
$order = $this->order;
|
||||||
if ($order->status !== 0) {
|
if ($order->status !== 0) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$order->status = 1;
|
$order->status = 1;
|
||||||
$order->paid_at = time();
|
$order->paid_at = time();
|
||||||
$order->callback_no = $callbackNo;
|
$order->callback_no = $callbackNo;
|
||||||
return $order->save();
|
return $order->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cancel():bool
|
||||||
|
{
|
||||||
|
$order = $this->order;
|
||||||
|
DB::beginTransaction();
|
||||||
|
$order->status = 2;
|
||||||
|
if (!$order->save()) {
|
||||||
|
DB::rollBack();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($order->balance_amount) {
|
||||||
|
$userService = new UserService();
|
||||||
|
if (!$userService->addBalance($order->user_id, $order->balance_amount)) {
|
||||||
|
DB::rollBack();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DB::commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private function buyByResetTraffic()
|
private function buyByResetTraffic()
|
||||||
{
|
{
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user