update: add payment sort

This commit is contained in:
tokumeikoi 2022-09-24 02:37:02 +08:00
parent b6085fd34d
commit 8e23e74e53
5 changed files with 30 additions and 4 deletions

View File

@ -8,6 +8,7 @@ use App\Utils\Helper;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Payment;
use Illuminate\Support\Facades\DB;
class PaymentController extends Controller
{
@ -24,7 +25,7 @@ class PaymentController extends Controller
public function fetch()
{
$payments = Payment::all();
$payments = Payment::orderBy('sort', 'ASC')->get();
foreach ($payments as $k => $v) {
$notifyUrl = url("/api/v1/guest/payment/notify/{$v->payment}/{$v->uuid}");
if ($v->notify_domain) {
@ -107,4 +108,26 @@ class PaymentController extends Controller
'data' => $payment->delete()
]);
}
public function sort(Request $request)
{
$request->validate([
'ids' => 'required|array'
], [
'ids.required' => '参数有误',
'ids.array' => '参数有误'
]);
DB::beginTransaction();
foreach ($request->input('ids') as $k => $v) {
if (!Payment::find($v)->update(['sort' => $k + 1])) {
DB::rollBack();
abort(500, '保存失败');
}
}
DB::commit();
return response([
'data' => true
]);
}
}

View File

@ -232,7 +232,9 @@ class OrderController extends Controller
'handling_fee_fixed',
'handling_fee_percent'
])
->where('enable', 1)->get();
->where('enable', 1)
->orderBy('sort', 'ASC')
->get();
return response([
'data' => $methods

View File

@ -112,6 +112,7 @@ class AdminRoute
$router->post('/payment/save', 'Admin\\PaymentController@save');
$router->post('/payment/drop', 'Admin\\PaymentController@drop');
$router->post('/payment/show', 'Admin\\PaymentController@show');
$router->post('/payment/sort', 'Admin\\PaymentController@sort');
// System
$router->get ('/system/getSystemStatus', 'Admin\\SystemController@getSystemStatus');
$router->get ('/system/getQueueStats', 'Admin\\SystemController@getQueueStats');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long