Ken 4 dias atrás
pai
commit
399c393097
1 arquivos alterados com 19 adições e 2 exclusões
  1. 19 2
      app/Services/PaymentOrderService.php

+ 19 - 2
app/Services/PaymentOrderService.php

@@ -93,7 +93,7 @@ class PaymentOrderService extends BaseService
     /**
      * @description: 分页查询
      * @param array $search
-     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
+     * @return array
      */
     public static function paginate(array $search = [])
     {
@@ -102,7 +102,24 @@ class PaymentOrderService extends BaseService
             ->with(['userInfo'])
             ->orderByDesc('created_at')
             ->paginate($limit);
-        return ['total' => $paginator->total(), 'data' => $paginator->items()];
+
+
+        $totalAmount = 0;
+        $totalSuccess = 0;
+        $totalFail = 0;
+        $list = $paginator->items();
+        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'];
+        }
+        return [
+            'total' => $paginator->total(),
+            'total_amount' => $totalAmount,
+            'total_success' => $totalSuccess,
+            'total_fail' => $totalFail,
+            'data' => $list];
     }
 
     /**