Ken 2 هفته پیش
والد
کامیت
37799c7cbf
1فایلهای تغییر یافته به همراه16 افزوده شده و 6 حذف شده
  1. 16 6
      app/Http/Controllers/admin/Withdraw.php

+ 16 - 6
app/Http/Controllers/admin/Withdraw.php

@@ -11,6 +11,7 @@ use App\Services\WithdrawService;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Validation\ValidationException;
 use Exception;
+use App\Models\Withdraw as WithdrawModel;
 use App\Models\Config;
 
 class Withdraw extends Controller
@@ -55,12 +56,21 @@ class Withdraw extends Controller
     public function index()
     {
         try {
-            request()->validate([
+            $params = request()->validate([
+                'page' => ['nullable', 'integer', 'min:1'],
+                'limit' => ['nullable', 'integer', 'min:1'],
                 'member_id' => ['nullable', 'string', 'min:1'],
                 'status' => ['nullable', 'integer', 'min:0', 'max:2']
             ]);
-            $search = request()->all();
-            $result = WithdrawService::paginate($search);
+            $page = request()->input('page', 1);
+            $limit = request()->input('limit', 10);
+            $query = WithdrawModel::query();
+            $where = WithdrawService::getWhere($params);
+            $count = $query->where($where)->count();
+            $list = $query->where($where)
+                ->orderBy('created_at', 'desc')
+                ->forpage($page, $limit)->get();
+            $result = ['total' => $count, 'data' => $list];
         } catch (ValidationException $e) {
             return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
         } catch (Exception $e) {
@@ -92,13 +102,13 @@ class Withdraw extends Controller
             ]);
             $id = request()->input('id');
             $status = request()->input('status');
-            
+
 
             $w = WithdrawService::findOne(['id' => $id, 'status' => 0]);
-        
+
             if (!$w) throw new Exception("数据不存在", HttpStatus::CUSTOM_ERROR);
             // 汇率
-            $rate = $w->exchange_rate??1;
+            $rate = $w->exchange_rate ?? 1;
             if ($status == 1) {
                 $w->status = 1;
                 $w->save();