doge 5 дней назад
Родитель
Сommit
359315b58a

+ 6 - 0
app/Http/Controllers/admin/PaymentOrder.php

@@ -9,6 +9,7 @@ use App\Services\PaymentOrderService;
 use Exception;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Validation\ValidationException;
+use App\Models\Agent\AgentWithdrawal;
 use App\Models\PaymentOrder as PaymentOrderModel;
 use App\Models\Wallet;
 use App\Models\Recharge;
@@ -44,6 +45,11 @@ class PaymentOrder extends Controller
                 + (int)\App\Models\Agent\AgentRecharge::where('type', 2)->where('status', 0)->count();
         } catch (\Illuminate\Database\QueryException $e) {
         }
+        // 代理提现角标统计全部待审核申请,和会员提现分开。
+        try {
+            $data['agentWithdraw'] = (int) AgentWithdrawal::query()->where('status', 'pending')->count();
+        } catch (\Illuminate\Database\QueryException $e) {
+        }
         // 代理申请(会员前台提交)与合营代理分成方案申请:所有待审核持续提示,不限制申请日期。
         try {
             $data['agentApplication'] = (int)DB::table('agent_applications')->where('status', 'pending')->count();

+ 2 - 2
docs/前端交付/bot-28/后台/后台实时推送-前端接入.md

@@ -300,11 +300,11 @@ Echo 回调收到的对象:
 | 频道 | `data` 字段(均为整数) |
 | --- | --- |
 | `admin.stats.platform_count` | `total`、`apple`、`android`、`pc`、`mobile`、`wechat`、`unknown` |
-| `admin.stats.unprocessed` | `usdtRecharge`、`rgRecharge`、`rmbRecharge`、`usdtWithdraw`、`rgWithdraw`、`rmbWithdraw`、`agentRecharge`、`agentApplication`、`agentPlanApplication`、`shareClaim` |
+| `admin.stats.unprocessed` | `usdtRecharge`、`rgRecharge`、`rmbRecharge`、`usdtWithdraw`、`rgWithdraw`、`rmbWithdraw`、`agentRecharge`、`agentWithdraw`、`agentApplication`、`agentPlanApplication`、`shareClaim` |
 
 `admin.stats.third_game_balance` 的事件 `data` 包含 `balance`、`currency`、`stale`,与 `GET /admin/home/third-game-balance` 的 `data` 相同。见[商户余额字段定义](../../后台首页第三方游戏商户余额-前端接入.md)。
 
-平台统计的 `wechat` 已包含在 `mobile` 中。订单角标沿用原接口的近 24 小时口径;`agentRecharge`、`agentApplication`(代理申请待审核)、`agentPlanApplication`(合营方案申请待审核)、`shareClaim` 统计全部待处理、不限申请日期。代理三项仅在代理表已迁移时返回。权限分别沿用 `admin/online/platformCount` 和 `admin/paymentOrder/unProcessed`。
+平台统计的 `wechat` 已包含在 `mobile` 中。会员订单角标统计近 24 小时。`agentRecharge`、`agentWithdraw`(代理提现待审核)、`agentApplication`(代理申请待审核)、`agentPlanApplication`(合营方案申请待审核)、`shareClaim` 统计全部待处理记录。代理各项在对应数据可用时返回。权限分别沿用 `admin/online/platformCount` 和 `admin/paymentOrder/unProcessed`。
 
 relay 默认每 5 秒读取这两项统计,仅在值变化时登记并推送,首次扫描也会发送快照。该机制覆盖跨仓库写入、在线平台变化、活跃及订单时间窗口到期;不依赖 HTTP 列表刷新触发。两频道同样支持 `seq` 去重和断线补发。
 

+ 4 - 0
docs/总后台/代理提现列表.md

@@ -112,3 +112,7 @@ GET /admin/agent/withdrawals?page=1&limit=20&status=pending&start_date=2026-08-0
 ```
 
 重复执行不符合当前状态的动作会返回 `code=-3`,例如已付款订单不能再次付款。
+
+## 3. 待审核提醒
+
+[代理提现提醒接入文档](代理提现提醒-前端接入.md)

+ 69 - 0
docs/总后台/代理提现提醒-前端接入.md

@@ -0,0 +1,69 @@
+# 总后台代理提现提醒
+
+`agentWithdraw` 为待审核(`pending`)的代理提现笔数,类型为整数。统计所有提现通道和申请日期。审核通过或驳回后,该订单从待审核数量中扣除。没有待审核订单时返回 `0`。
+
+## HTTP API
+
+| 项目 | 值 |
+|---|---|
+| 接口 | `GET /admin/paymentOrder/unProcessed` |
+| 认证 | 沿用总后台登录态 |
+| 请求参数 | 无 |
+| 成功码 | `code = 0` |
+| 新增字段 | `data.agentWithdraw` |
+
+```json
+{
+  "code": 0,
+  "timestamp": 1794382200,
+  "msg": "OK",
+  "data": {
+    "usdtRecharge": 0,
+    "rgRecharge": 0,
+    "rmbRecharge": 0,
+    "usdtWithdraw": 0,
+    "rgWithdraw": 0,
+    "rmbWithdraw": 0,
+    "agentRecharge": 1,
+    "agentWithdraw": 2,
+    "agentApplication": 0,
+    "agentPlanApplication": 0,
+    "shareClaim": 0
+  }
+}
+```
+
+## WebSocket
+
+| 项目 | 值 |
+|---|---|
+| 私有频道 | `admin.stats.unprocessed`(协议频道名 `private-admin.stats.unprocessed`) |
+| 事件名 | `stats.updated`(Laravel Echo 监听名 `.stats.updated`) |
+| 新增字段 | 事件载荷的 `data.agentWithdraw` |
+| `data` | 当前待处理统计快照,字段与 HTTP 响应中的 `data` 相同 |
+
+```json
+{
+  "seq": 2201,
+  "id": 5530,
+  "channel": "admin.stats.unprocessed",
+  "event": "stats.updated",
+  "action": "updated",
+  "key": {"scope": "all"},
+  "data": {
+    "usdtRecharge": 0,
+    "rgRecharge": 0,
+    "rmbRecharge": 0,
+    "usdtWithdraw": 0,
+    "rgWithdraw": 0,
+    "rmbWithdraw": 0,
+    "agentRecharge": 1,
+    "agentWithdraw": 2,
+    "agentApplication": 0,
+    "agentPlanApplication": 0,
+    "shareClaim": 0
+  },
+  "source": "bot-28",
+  "created_at": "2026-11-11 15:30:00"
+}
+```

+ 2 - 2
docs/总后台/后台实时推送-前端接入.md

@@ -300,11 +300,11 @@ Echo 回调收到的对象:
 | 频道 | `data` 字段(均为整数) |
 | --- | --- |
 | `admin.stats.platform_count` | `total`、`apple`、`android`、`pc`、`mobile`、`wechat`、`unknown` |
-| `admin.stats.unprocessed` | `usdtRecharge`、`rgRecharge`、`rmbRecharge`、`usdtWithdraw`、`rgWithdraw`、`rmbWithdraw`、`agentRecharge`、`agentApplication`、`agentPlanApplication`、`shareClaim` |
+| `admin.stats.unprocessed` | `usdtRecharge`、`rgRecharge`、`rmbRecharge`、`usdtWithdraw`、`rgWithdraw`、`rmbWithdraw`、`agentRecharge`、`agentWithdraw`、`agentApplication`、`agentPlanApplication`、`shareClaim` |
 
 `admin.stats.third_game_balance` 的事件 `data` 包含 `balance`、`currency`、`stale`,与 `GET /admin/home/third-game-balance` 的 `data` 相同。见[商户余额字段定义](../前端交付/后台首页第三方游戏商户余额-前端接入.md)。
 
-平台统计的 `wechat` 已包含在 `mobile` 中。订单角标沿用原接口的近 24 小时口径;`agentRecharge`、`agentApplication`(代理申请待审核)、`agentPlanApplication`(合营方案申请待审核)、`shareClaim` 统计全部待处理、不限申请日期。代理三项仅在代理表已迁移时返回。权限分别沿用 `admin/online/platformCount` 和 `admin/paymentOrder/unProcessed`。
+平台统计的 `wechat` 已包含在 `mobile` 中。会员订单角标统计近 24 小时。`agentRecharge`、`agentWithdraw`(代理提现待审核)、`agentApplication`(代理申请待审核)、`agentPlanApplication`(合营方案申请待审核)、`shareClaim` 统计全部待处理记录。代理各项在对应数据可用时返回。权限分别沿用 `admin/online/platformCount` 和 `admin/paymentOrder/unProcessed`。
 
 relay 默认每 5 秒读取这两项统计,仅在值变化时登记并推送,首次扫描也会发送快照。该机制覆盖跨仓库写入、在线平台变化、活跃及订单时间窗口到期;不依赖 HTTP 列表刷新触发。两频道同样支持 `seq` 去重和断线补发。
 

+ 31 - 0
tests/Integration/AdminRealtimeSummaryTest.php

@@ -333,6 +333,37 @@ class AdminRealtimeSummaryTest extends TestCase
         $this->assertSame(8, DB::table('payment_orders')->count(), '扫描只读业务表');
     }
 
+    public function test_agent_withdrawal_badge_matches_http_and_pushes_when_the_pending_count_changes(): void
+    {
+        Schema::create('agent_withdrawals', function (Blueprint $table) {
+            $table->id();
+            $table->string('status');
+            $table->dateTime('created_at');
+        });
+        $channel = 'admin.stats.unprocessed';
+        $initial = collect($this->tick(0))->firstWhere('channel', $channel);
+        $this->assertSame(0, $initial['data']['agentWithdraw']);
+
+        $withdrawals = DB::table('agent_withdrawals');
+        $createdAt = $this->clock->copy()->subDays(3)->toDateTimeString();
+        foreach (['pending', 'pending', 'approved', 'processing', 'paid', 'rejected', 'failed'] as $status) {
+            $withdrawals->insert(['status' => $status, 'created_at' => $createdAt]);
+        }
+        $pending = collect($this->tick(6))->where('channel', $channel)->sole();
+        $this->assertSame('stats.updated', $pending['event']);
+        $this->assertSame(2, $pending['data']['agentWithdraw'], 'pending applications are counted even after 24 hours');
+        $this->assertSame(1, $pending['data']['usdtWithdraw'], 'agent withdrawals are counted separately');
+        $this->assertSame((new PaymentOrder())->unProcessed()->getData(true)['data'], $pending['data']);
+        $this->assertSame($pending['data'], AdminRealtimeFeed::replay($initial['seq'], [$channel])['events'][0]['data']);
+
+        (clone $withdrawals)->where('id', 1)->update(['status' => 'approved']);
+        (clone $withdrawals)->where('id', 2)->update(['status' => 'rejected']);
+        $reviewed = collect($this->tick(12))->where('channel', $channel)->sole();
+        $this->assertSame(0, $reviewed['data']['agentWithdraw']);
+        $this->assertSame((new PaymentOrder())->unProcessed()->getData(true)['data'], $reviewed['data']);
+        $this->assertSame([], $this->tick(18));
+    }
+
     public function test_failed_outbox_registration_does_not_swallow_the_snapshot_change(): void
     {
         Schema::rename('admin_realtime_events', 'unavailable_realtime_events');