Ken 1 săptămână în urmă
părinte
comite
0c3e842b21
1 a modificat fișierele cu 13 adăugiri și 8 ștergeri
  1. 13 8
      app/Http/Controllers/admin/Home.php

+ 13 - 8
app/Http/Controllers/admin/Home.php

@@ -24,17 +24,21 @@ class Home extends Controller
 
             $start = request()->input('start_date');
             $end = request()->input('end_date');
-            if(empty($end))$end = date('Y-m-d');
-            if(empty($start))$start = date('Y-m-d');
+            if (empty($end)) $end = date('Y-m-d');
+            if (empty($start)) $start = date('Y-m-d');
 
 
             $end = Carbon::createFromFormat('Y-m-d', $end)->addDay()->format('Y-m-d');
             $query = PaymentOrder::query();
-
-            $params['type'] = 2;
-            $where = PaymentOrderService::getWhere($params);
-            $query->where($where)->whereBetween('created_at', [$start, $end]);
+            $query->where('type', 2)->whereBetween('created_at', [$start, $end]);
             $query1 = clone $query;
+            $sql  = $query1->toSql();
+            $bindings = $query1->getBindings();
+            // 将绑定的参数替换到 SQL 查询中
+            foreach ($bindings as $binding) {
+                // 使用 ? 替换成绑定的值
+                $sql = preg_replace('/\?/', "'" . addslashes($binding) . "'", $sql, 1);
+            }
 
             $totalAmount = (float)$query1->sum('amount');
             $query1 = clone $query;
@@ -49,8 +53,8 @@ class Home extends Controller
             $query1 = clone $query;
             $usdTotalSuccess = (float)$query1->where('status', 1)->sum('amount');
             $query1 = clone $query;
-            $usdTotalFail = (float)$query1->where('status', 2)
-                ->sum('amount');
+            $usdTotalFail = (float)$query1->where('status', 2)->sum('amount');
+
             $result = [
                 'withdraw_usdt' => [
                     'total_fail' => $usdTotalFail,
@@ -61,6 +65,7 @@ class Home extends Controller
                     'total_fail' => $totalFail,
                     'total_success' => $totalSuccess,
                     'total_amount' => $totalAmount,
+                    '$sql'=>$sql
                 ]
 
             ];