Ken hai 4 días
pai
achega
6f9e5c09be
Modificáronse 1 ficheiros con 14 adicións e 2 borrados
  1. 14 2
      app/Http/Controllers/admin/Withdraw.php

+ 14 - 2
app/Http/Controllers/admin/Withdraw.php

@@ -61,8 +61,20 @@ class Withdraw extends Controller
                 ->with(['userInfo'])
                 ->orderByRaw('CASE WHEN status = 0 THEN 0 ELSE 1 END')
                 ->orderByDesc('created_at')
-                ->forpage($page, $limit)->get();
-            $result = ['total' => $count, 'data' => $list];
+                ->forpage($page, $limit)->get()->toArray();
+
+            $totalAmount = 0;
+            $totalSuccess = 0;
+            $totalFail = 0;
+            foreach ($list as $item) {
+                $item['amount'] = floatval($item['amount']);
+                $totalAmount += $item['amount'];
+                if (in_array($item['status'], [1, 2])) $totalSuccess += $item['amount'];
+                if ($item['status'] == 3) $totalFail += $item['amount'];
+            }
+
+
+            $result = ['total' => $count, 'total_fail' => $totalFail, 'total_success' => $totalSuccess, 'total_amount' => $totalAmount, 'data' => $list];
         } catch (ValidationException $e) {
             return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
         } catch (Exception $e) {