Просмотр исходного кода

✨ 管理后台 AI 积分:查看账号与流水、手工加减积分、手工结算

dashboard-v6 新增 /admin/credits,后端 /v3/admin/credit-{overview,accounts,ledger,adjustments,settlements}
(逻辑在 App\Services\V3\CreditAdminService,仅 root / administrator)。

- 概览:余额合计、累计赚取 / 调整 / 消耗、最近 14 天每日结算、最近一次结算(任务或后台手工)。
- 手工加减积分:用户用 UserSelect 搜索选择,必须写原因;按 ref 幂等,扣减后余额不能为负。
  credit_ledger 新增 nullable 列 operator_uid 记录操作的管理员。
- 手工结算:「补齐漏结算」与每日任务同一套逻辑,「重算某一天」按当前策略重算;可重复执行,
  同一用户同一天覆盖不累加。credits:settle-activity 改走同一个 Service,并记录最近一次运行。
- OpenAPI 生成器:单个资源的控制器声明 @meta 时也输出 meta(其他端点规格无变化)。
- 测试:Pest AdminCreditV3Test、api-test 24_admin_credits、dashboard-test admin-credits.spec
  (新增可选管理员账号 E2E_ADMIN_USER / E2E_ADMIN_PASS)。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 6 часов назад
Родитель
Сommit
bcd1d4ef2f
68 измененных файлов с 13740 добавлено и 70 удалено
  1. 132 0
      api-test/cases/24_admin_credits.php
  2. 45 0
      api-test/client/.openapi-generator/FILES
  3. 1736 52
      api-test/client/lib/Api/AdminApi.php
  4. 443 0
      api-test/client/lib/Model/GetApiV3AdminCreditAccounts200Response.php
  5. 763 0
      api-test/client/lib/Model/GetApiV3AdminCreditAccounts200ResponseDataInner.php
  6. 443 0
      api-test/client/lib/Model/GetApiV3AdminCreditLedger200Response.php
  7. 409 0
      api-test/client/lib/Model/GetApiV3AdminCreditOverview200Response.php
  8. 620 0
      api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseData.php
  9. 681 0
      api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseDataLastSettlement.php
  10. 511 0
      api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner.php
  11. 579 0
      api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseDataTotals.php
  12. 443 0
      api-test/client/lib/Model/PostApiV3AdminCreditAdjustments200Response.php
  13. 1057 0
      api-test/client/lib/Model/PostApiV3AdminCreditAdjustments200ResponseData.php
  14. 443 0
      api-test/client/lib/Model/PostApiV3AdminCreditAdjustments200ResponseMeta.php
  15. 520 0
      api-test/client/lib/Model/PostApiV3AdminCreditAdjustmentsRequest.php
  16. 409 0
      api-test/client/lib/Model/PostApiV3AdminCreditSettlements200Response.php
  17. 763 0
      api-test/client/lib/Model/PostApiV3AdminCreditSettlements200ResponseData.php
  18. 409 0
      api-test/client/lib/Model/PostApiV3AdminCreditSettlementsRequest.php
  19. 8 13
      api-v13/app/Console/Commands/SettleCreditActivity.php
  20. 35 0
      api-v13/app/Http/Controllers/V3/AdminCreditAccountController.php
  21. 52 0
      api-v13/app/Http/Controllers/V3/AdminCreditAdjustmentController.php
  22. 38 0
      api-v13/app/Http/Controllers/V3/AdminCreditLedgerController.php
  23. 26 0
      api-v13/app/Http/Controllers/V3/AdminCreditOverviewController.php
  24. 42 0
      api-v13/app/Http/Controllers/V3/AdminCreditSettlementController.php
  25. 29 0
      api-v13/app/Http/Requests/V3/IndexAdminCreditAccountRequest.php
  26. 37 0
      api-v13/app/Http/Requests/V3/IndexAdminCreditLedgerRequest.php
  27. 31 0
      api-v13/app/Http/Requests/V3/StoreAdminCreditAdjustmentRequest.php
  28. 30 0
      api-v13/app/Http/Requests/V3/StoreAdminCreditSettlementRequest.php
  29. 49 0
      api-v13/app/Http/Resources/V3/AdminCreditAccountResource.php
  30. 62 0
      api-v13/app/Http/Resources/V3/AdminCreditLedgerResource.php
  31. 32 0
      api-v13/app/Http/Resources/V3/AdminCreditOverviewResource.php
  32. 23 0
      api-v13/app/Http/Resources/V3/AdminCreditSettlementResource.php
  33. 17 0
      api-v13/app/Models/CreditLedgerEntry.php
  34. 234 0
      api-v13/app/Services/V3/CreditAdminService.php
  35. 4 1
      api-v13/app/Services/V3/CreditService.php
  36. 28 0
      api-v13/database/migrations/2026_11_19_100000_add_operator_uid_to_credit_ledger.php
  37. 3 1
      api-v13/documents/tasks.md
  38. 2 0
      api-v13/resources/lang/en/messages.php
  39. 2 0
      api-v13/resources/lang/zh-Hans/messages.php
  40. 12 0
      api-v13/routes/v3/admin.php
  41. 239 0
      api-v13/tests/Feature/AdminCreditV3Test.php
  42. 4 0
      dashboard-test/.env.example
  43. 1 1
      dashboard-test/src/lib/api.ts
  44. 7 0
      dashboard-test/src/lib/env.ts
  45. 167 0
      dashboard-test/src/tests/admin-credits.spec.ts
  46. 8 0
      dashboard-test/src/tests/auth.setup.ts
  47. 45 0
      dashboard-v6/src/api/adminCredits.ts
  48. 501 0
      dashboard-v6/src/api/schema.d.ts
  49. 154 0
      dashboard-v6/src/features/admin-credits/CreditAccountTable.tsx
  50. 101 0
      dashboard-v6/src/features/admin-credits/CreditAdjustModal.tsx
  51. 61 0
      dashboard-v6/src/features/admin-credits/CreditAdmin.tsx
  52. 164 0
      dashboard-v6/src/features/admin-credits/CreditLedgerTable.tsx
  53. 189 0
      dashboard-v6/src/features/admin-credits/CreditOverview.tsx
  54. 27 0
      dashboard-v6/src/hooks/useAdminCredits.ts
  55. 2 2
      dashboard-v6/src/hooks/useAdminStats.ts
  56. 3 0
      dashboard-v6/src/layouts/admin/index.tsx
  57. 75 0
      dashboard-v6/src/locales/en-US/admin.ts
  58. 75 0
      dashboard-v6/src/locales/zh-Hans/admin.ts
  59. 75 0
      dashboard-v6/src/locales/zh-Hant/admin.ts
  60. 14 0
      dashboard-v6/src/pages/admin/credits.tsx
  61. 2 0
      dashboard-v6/src/routes/adminRoutes.ts
  62. 10 0
      openapi/public/assets/protocol/main.yaml
  63. 88 0
      openapi/public/assets/protocol/resources/auto/v3-admin-credit-accounts.yaml
  64. 212 0
      openapi/public/assets/protocol/resources/auto/v3-admin-credit-adjustments.yaml
  65. 145 0
      openapi/public/assets/protocol/resources/auto/v3-admin-credit-ledger.yaml
  66. 62 0
      openapi/public/assets/protocol/resources/auto/v3-admin-credit-overview.yaml
  67. 102 0
      openapi/public/assets/protocol/resources/auto/v3-admin-credit-settlements.yaml
  68. 5 0
      openapi/scripts/generate.php

+ 132 - 0
api-test/cases/24_admin_credits.php

@@ -0,0 +1,132 @@
+<?php
+
+use \WikipaliApi\Api\AdminApi;
+use \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest;
+use \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest;
+
+/*
+ * v3 管理后台 · AI 对话积分:/v3/admin/credit-overview、credit-accounts、credit-ledger、
+ * credit-adjustments、credit-settlements(仅 root / administrator)。
+ *
+ * 测试账号是普通用户时只测 401 / 403;是管理员时再测读、422 与写。
+ * 写都是幂等的:结算重复执行结果覆盖;给自己 +1 再 -1 用固定的 ref,每台服务器只入账一次、净额为 0。
+ */
+
+/** 测试账号是不是管理员(看 /v3/me 的 roles) */
+function credit_admin(string $token): bool
+{
+    $me = raw('GET', '/v3/me', null, null, $token);
+    $roles = $me['body']['data']['roles'] ?? [];
+
+    return (bool) array_intersect(['administrator', 'root'], $roles);
+}
+
+function admin_token_or_skip(): string
+{
+    $token = required_token();
+    if (! credit_admin($token)) {
+        skip('测试账号不是管理员');
+    }
+
+    return $token;
+}
+
+/* ---- 无 token → 401 ---- */
+
+test('GET /v3/admin/credit-overview(无 token)→ 401', function () {
+    $res = request(fn () => api(AdminApi::class)->getApiV3AdminCreditOverviewWithHttpInfo());
+    assert_status(401, $res, 'credit-overview');
+    assert_problem($res, 'credit-overview');
+});
+
+test('POST /v3/admin/credit-settlements(无 token)→ 401', function () {
+    $res = request(fn () => api(AdminApi::class)->postApiV3AdminCreditSettlementsWithHttpInfo(new PostApiV3AdminCreditSettlementsRequest()));
+    assert_status(401, $res, 'credit-settlements');
+});
+
+/* ---- 普通用户 → 403 ---- */
+
+test('GET /v3/admin/credit-accounts(非管理员)→ 403', function () {
+    $token = required_token();
+    if (credit_admin($token)) {
+        skip('测试账号是管理员');
+    }
+    $res = request(fn () => api(AdminApi::class, $token)->getApiV3AdminCreditAccountsWithHttpInfo());
+    assert_status(403, $res, 'credit-accounts');
+    assert_problem($res, 'credit-accounts');
+});
+
+/* ---- 管理员:读 ---- */
+
+test('GET /v3/admin/credit-overview → 200', function () {
+    $res = request(fn () => api(AdminApi::class, admin_token_or_skip())->getApiV3AdminCreditOverviewWithHttpInfo());
+    assert_status(200, $res, 'credit-overview');
+    foreach (['today', 'earn_since', 'policy_version', 'policy', 'totals', 'recent_days', 'last_settlement'] as $key) {
+        assert_has_key($key, $res['body']['data'], 'credit-overview.data');
+    }
+    assert_eq(14, count($res['body']['data']['recent_days']), 'recent_days 14 天');
+});
+
+test('GET /v3/admin/credit-accounts → 200 分页', function () {
+    $res = request(fn () => api(AdminApi::class, admin_token_or_skip())->getApiV3AdminCreditAccountsWithHttpInfo(per_page: 5));
+    assert_status(200, $res, 'credit-accounts');
+    assert_has_key('total', $res['body']['meta'], 'credit-accounts.meta');
+    foreach ($res['body']['data'] as $row) {
+        foreach (['account_type', 'account_id', 'earned_balance', 'spent_total', 'free_used_today', 'daily_free'] as $key) {
+            assert_has_key($key, $row, 'credit-accounts.data[]');
+        }
+    }
+});
+
+test('GET /v3/admin/credit-ledger(只给 account_id)→ 422', function () {
+    $res = request(fn () => api(AdminApi::class, admin_token_or_skip())->getApiV3AdminCreditLedgerWithHttpInfo(
+        filter_account_id: '00000000-0000-4000-8000-000000000000',
+    ));
+    assert_status(422, $res, 'credit-ledger');
+    assert_field_error('filter.account_type', $res, 'credit-ledger');
+});
+
+/* ---- 管理员:写(幂等) ---- */
+
+test('POST /v3/admin/credit-settlements → 201(可重复执行)', function () {
+    $res = request(fn () => api(AdminApi::class, admin_token_or_skip())->postApiV3AdminCreditSettlementsWithHttpInfo(
+        new PostApiV3AdminCreditSettlementsRequest(),
+    ));
+    assert_status(201, $res, 'credit-settlements');
+    assert_eq('missing', $res['body']['data']['mode'], 'credit-settlements.mode');
+});
+
+test('POST /v3/admin/credit-settlements(未来日期)→ 422', function () {
+    $body = new PostApiV3AdminCreditSettlementsRequest();
+    $body->setDate(gmdate('Y-m-d', time() + 86400 * 2));
+    $res = request(fn () => api(AdminApi::class, admin_token_or_skip())->postApiV3AdminCreditSettlementsWithHttpInfo($body));
+    assert_status(422, $res, 'credit-settlements');
+    assert_field_error('date', $res, 'credit-settlements');
+});
+
+test('POST /v3/admin/credit-adjustments:给自己 +1 再 -1(固定 ref,只入账一次)', function () {
+    $token = admin_token_or_skip();
+    $me = raw('GET', '/v3/me', null, null, $token)['body']['data']['id'];
+    foreach ([['8f0b5a52-3c1e-4e0a-9d7a-5b1f0c2e0001', 1], ['8f0b5a52-3c1e-4e0a-9d7a-5b1f0c2e0002', -1]] as [$ref, $delta]) {
+        $body = new PostApiV3AdminCreditAdjustmentsRequest();
+        $body->setUser($me);
+        $body->setDelta($delta);
+        $body->setNote('api-test 幂等写入');
+        $body->setRef($ref);
+        $res = request(fn () => api(AdminApi::class, $token)->postApiV3AdminCreditAdjustmentsWithHttpInfo($body));
+        if (! in_array($res['status'], [200, 201], true)) {
+            assert_status(201, $res, "credit-adjustments {$delta}");
+        }
+        assert_eq($delta, $res['body']['data']['delta'], 'credit-adjustments.delta');
+    }
+});
+
+test('POST /v3/admin/credit-adjustments(delta 为 0、缺原因)→ 422', function () {
+    $body = new PostApiV3AdminCreditAdjustmentsRequest();
+    $body->setUser('nobody');
+    $body->setDelta(0);
+    $body->setNote('');
+    $res = request(fn () => api(AdminApi::class, admin_token_or_skip())->postApiV3AdminCreditAdjustmentsWithHttpInfo($body));
+    assert_status(422, $res, 'credit-adjustments');
+    assert_field_error('delta', $res, 'credit-adjustments');
+});

+ 45 - 0
api-test/client/.openapi-generator/FILES

@@ -62,6 +62,14 @@ docs/Model/GetApiV3AdminAgentStats200ResponseDataFeedbackReasonsInner.md
 docs/Model/GetApiV3AdminAgentStats200ResponseDataRange.md
 docs/Model/GetApiV3AdminAgentStats200ResponseDataSummary.md
 docs/Model/GetApiV3AdminAgentStats200ResponseDataToolsInner.md
+docs/Model/GetApiV3AdminCreditAccounts200Response.md
+docs/Model/GetApiV3AdminCreditAccounts200ResponseDataInner.md
+docs/Model/GetApiV3AdminCreditLedger200Response.md
+docs/Model/GetApiV3AdminCreditOverview200Response.md
+docs/Model/GetApiV3AdminCreditOverview200ResponseData.md
+docs/Model/GetApiV3AdminCreditOverview200ResponseDataLastSettlement.md
+docs/Model/GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner.md
+docs/Model/GetApiV3AdminCreditOverview200ResponseDataTotals.md
 docs/Model/GetApiV3AdminReadingStats200Response.md
 docs/Model/GetApiV3AdminReadingStats200ResponseData.md
 docs/Model/GetApiV3AdminReadingStats200ResponseDataDailyInner.md
@@ -193,6 +201,13 @@ docs/Model/PatchApiV3GroupsGroupRequest.md
 docs/Model/PatchApiV3MeAgentThreadsThreadRequest.md
 docs/Model/PatchApiV3PasswordResetsTokenRequest.md
 docs/Model/PatchApiV3TermsTermRequest.md
+docs/Model/PostApiV3AdminCreditAdjustments200Response.md
+docs/Model/PostApiV3AdminCreditAdjustments200ResponseData.md
+docs/Model/PostApiV3AdminCreditAdjustments200ResponseMeta.md
+docs/Model/PostApiV3AdminCreditAdjustmentsRequest.md
+docs/Model/PostApiV3AdminCreditSettlements200Response.md
+docs/Model/PostApiV3AdminCreditSettlements200ResponseData.md
+docs/Model/PostApiV3AdminCreditSettlementsRequest.md
 docs/Model/PostApiV3AgentCharges200Response.md
 docs/Model/PostApiV3AgentCharges200ResponseData.md
 docs/Model/PostApiV3AgentChargesRequest.md
@@ -312,6 +327,14 @@ lib/Model/GetApiV3AdminAgentStats200ResponseDataFeedbackReasonsInner.php
 lib/Model/GetApiV3AdminAgentStats200ResponseDataRange.php
 lib/Model/GetApiV3AdminAgentStats200ResponseDataSummary.php
 lib/Model/GetApiV3AdminAgentStats200ResponseDataToolsInner.php
+lib/Model/GetApiV3AdminCreditAccounts200Response.php
+lib/Model/GetApiV3AdminCreditAccounts200ResponseDataInner.php
+lib/Model/GetApiV3AdminCreditLedger200Response.php
+lib/Model/GetApiV3AdminCreditOverview200Response.php
+lib/Model/GetApiV3AdminCreditOverview200ResponseData.php
+lib/Model/GetApiV3AdminCreditOverview200ResponseDataLastSettlement.php
+lib/Model/GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner.php
+lib/Model/GetApiV3AdminCreditOverview200ResponseDataTotals.php
 lib/Model/GetApiV3AdminReadingStats200Response.php
 lib/Model/GetApiV3AdminReadingStats200ResponseData.php
 lib/Model/GetApiV3AdminReadingStats200ResponseDataDailyInner.php
@@ -444,6 +467,13 @@ lib/Model/PatchApiV3GroupsGroupRequest.php
 lib/Model/PatchApiV3MeAgentThreadsThreadRequest.php
 lib/Model/PatchApiV3PasswordResetsTokenRequest.php
 lib/Model/PatchApiV3TermsTermRequest.php
+lib/Model/PostApiV3AdminCreditAdjustments200Response.php
+lib/Model/PostApiV3AdminCreditAdjustments200ResponseData.php
+lib/Model/PostApiV3AdminCreditAdjustments200ResponseMeta.php
+lib/Model/PostApiV3AdminCreditAdjustmentsRequest.php
+lib/Model/PostApiV3AdminCreditSettlements200Response.php
+lib/Model/PostApiV3AdminCreditSettlements200ResponseData.php
+lib/Model/PostApiV3AdminCreditSettlementsRequest.php
 lib/Model/PostApiV3AgentCharges200Response.php
 lib/Model/PostApiV3AgentCharges200ResponseData.php
 lib/Model/PostApiV3AgentChargesRequest.php
@@ -560,6 +590,14 @@ test/Model/GetApiV3AdminAgentStats200ResponseDataSummaryTest.php
 test/Model/GetApiV3AdminAgentStats200ResponseDataTest.php
 test/Model/GetApiV3AdminAgentStats200ResponseDataToolsInnerTest.php
 test/Model/GetApiV3AdminAgentStats200ResponseTest.php
+test/Model/GetApiV3AdminCreditAccounts200ResponseDataInnerTest.php
+test/Model/GetApiV3AdminCreditAccounts200ResponseTest.php
+test/Model/GetApiV3AdminCreditLedger200ResponseTest.php
+test/Model/GetApiV3AdminCreditOverview200ResponseDataLastSettlementTest.php
+test/Model/GetApiV3AdminCreditOverview200ResponseDataRecentDaysInnerTest.php
+test/Model/GetApiV3AdminCreditOverview200ResponseDataTest.php
+test/Model/GetApiV3AdminCreditOverview200ResponseDataTotalsTest.php
+test/Model/GetApiV3AdminCreditOverview200ResponseTest.php
 test/Model/GetApiV3AdminReadingStats200ResponseDataDailyInnerTest.php
 test/Model/GetApiV3AdminReadingStats200ResponseDataDurationBucketsInnerTest.php
 test/Model/GetApiV3AdminReadingStats200ResponseDataPitakaShareInnerTest.php
@@ -691,6 +729,13 @@ test/Model/PatchApiV3GroupsGroupRequestTest.php
 test/Model/PatchApiV3MeAgentThreadsThreadRequestTest.php
 test/Model/PatchApiV3PasswordResetsTokenRequestTest.php
 test/Model/PatchApiV3TermsTermRequestTest.php
+test/Model/PostApiV3AdminCreditAdjustments200ResponseDataTest.php
+test/Model/PostApiV3AdminCreditAdjustments200ResponseMetaTest.php
+test/Model/PostApiV3AdminCreditAdjustments200ResponseTest.php
+test/Model/PostApiV3AdminCreditAdjustmentsRequestTest.php
+test/Model/PostApiV3AdminCreditSettlements200ResponseDataTest.php
+test/Model/PostApiV3AdminCreditSettlements200ResponseTest.php
+test/Model/PostApiV3AdminCreditSettlementsRequestTest.php
 test/Model/PostApiV3AgentCharges200ResponseDataTest.php
 test/Model/PostApiV3AgentCharges200ResponseTest.php
 test/Model/PostApiV3AgentChargesRequestTest.php

+ 1736 - 52
api-test/client/lib/Api/AdminApi.php

@@ -89,9 +89,24 @@ class AdminApi
         'getApiV3AdminAgentStats' => [
             'application/json',
         ],
+        'getApiV3AdminCreditAccounts' => [
+            'application/json',
+        ],
+        'getApiV3AdminCreditLedger' => [
+            'application/json',
+        ],
+        'getApiV3AdminCreditOverview' => [
+            'application/json',
+        ],
         'getApiV3AdminReadingStats' => [
             'application/json',
         ],
+        'postApiV3AdminCreditAdjustments' => [
+            'application/json',
+        ],
+        'postApiV3AdminCreditSettlements' => [
+            'application/json',
+        ],
     ];
 
     /**
@@ -1911,42 +1926,44 @@ class AdminApi
     }
 
     /**
-     * Operation getApiV3AdminReadingStats
+     * Operation getApiV3AdminCreditAccounts
      *
-     * 阅读统计
+     * 列出积分账号
      *
-     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
-     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
-     * @param  string|null $client 客户端 (optional, default to 'all')
-     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型 (optional)
+     * @param  string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
      *
      * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
      * @throws \InvalidArgumentException
-     * @return \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
      */
-    public function getApiV3AdminReadingStats($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    public function getApiV3AdminCreditAccounts($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
     {
-        list($response) = $this->getApiV3AdminReadingStatsWithHttpInfo($from, $to, $client, $contentType);
+        list($response) = $this->getApiV3AdminCreditAccountsWithHttpInfo($per_page, $filter_account_type, $filter_q, $page, $contentType);
         return $response;
     }
 
     /**
-     * Operation getApiV3AdminReadingStatsWithHttpInfo
+     * Operation getApiV3AdminCreditAccountsWithHttpInfo
      *
-     * 阅读统计
+     * 列出积分账号
      *
-     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
-     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
-     * @param  string|null $client 客户端 (optional, default to 'all')
-     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型 (optional)
+     * @param  string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
      *
      * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
      * @throws \InvalidArgumentException
-     * @return array of \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     * @return array of \WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
      */
-    public function getApiV3AdminReadingStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    public function getApiV3AdminCreditAccountsWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
     {
-        $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
+        $request = $this->getApiV3AdminCreditAccountsRequest($per_page, $filter_account_type, $filter_q, $page, $contentType);
 
         try {
             $options = $this->createHttpClientOption();
@@ -1974,7 +1991,7 @@ class AdminApi
             switch($statusCode) {
                 case 200:
                     return $this->handleResponseWithDataType(
-                        '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
+                        '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response',
                         $request,
                         $response,
                     );
@@ -2008,7 +2025,7 @@ class AdminApi
             }
 
             return $this->handleResponseWithDataType(
-                '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
+                '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response',
                 $request,
                 $response,
             );
@@ -2017,7 +2034,7 @@ class AdminApi
                 case 200:
                     $data = ObjectSerializer::deserialize(
                         $e->getResponseBody(),
-                        '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
+                        '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response',
                         $e->getResponseHeaders()
                     );
                     $e->setResponseObject($data);
@@ -2046,21 +2063,22 @@ class AdminApi
     }
 
     /**
-     * Operation getApiV3AdminReadingStatsAsync
+     * Operation getApiV3AdminCreditAccountsAsync
      *
-     * 阅读统计
+     * 列出积分账号
      *
-     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
-     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
-     * @param  string|null $client 客户端 (optional, default to 'all')
-     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型 (optional)
+     * @param  string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
      *
      * @throws \InvalidArgumentException
      * @return \GuzzleHttp\Promise\PromiseInterface
      */
-    public function getApiV3AdminReadingStatsAsync($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    public function getApiV3AdminCreditAccountsAsync($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
     {
-        return $this->getApiV3AdminReadingStatsAsyncWithHttpInfo($from, $to, $client, $contentType)
+        return $this->getApiV3AdminCreditAccountsAsyncWithHttpInfo($per_page, $filter_account_type, $filter_q, $page, $contentType)
             ->then(
                 function ($response) {
                     return $response[0];
@@ -2069,22 +2087,23 @@ class AdminApi
     }
 
     /**
-     * Operation getApiV3AdminReadingStatsAsyncWithHttpInfo
+     * Operation getApiV3AdminCreditAccountsAsyncWithHttpInfo
      *
-     * 阅读统计
+     * 列出积分账号
      *
-     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
-     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
-     * @param  string|null $client 客户端 (optional, default to 'all')
-     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型 (optional)
+     * @param  string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
      *
      * @throws \InvalidArgumentException
      * @return \GuzzleHttp\Promise\PromiseInterface
      */
-    public function getApiV3AdminReadingStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    public function getApiV3AdminCreditAccountsAsyncWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
     {
-        $returnType = '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response';
-        $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
+        $returnType = '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200Response';
+        $request = $this->getApiV3AdminCreditAccountsRequest($per_page, $filter_account_type, $filter_q, $page, $contentType);
 
         return $this->client
             ->sendAsync($request, $this->createHttpClientOption())
@@ -2123,24 +2142,26 @@ class AdminApi
     }
 
     /**
-     * Create request for operation 'getApiV3AdminReadingStats'
+     * Create request for operation 'getApiV3AdminCreditAccounts'
      *
-     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
-     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
-     * @param  string|null $client 客户端 (optional, default to 'all')
-     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型 (optional)
+     * @param  string|null $filter_q 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditAccounts'] to see the possible values for this operation
      *
      * @throws \InvalidArgumentException
      * @return \GuzzleHttp\Psr7\Request
      */
-    public function getApiV3AdminReadingStatsRequest($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    public function getApiV3AdminCreditAccountsRequest($per_page = 20, $filter_account_type = null, $filter_q = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditAccounts'][0])
     {
 
 
 
 
 
-        $resourcePath = '/v3/admin/reading-stats';
+
+        $resourcePath = '/v3/admin/credit-accounts';
         $formParams = [];
         $queryParams = [];
         $headerParams = [];
@@ -2149,17 +2170,17 @@ class AdminApi
 
         // query params
         $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
-            $from,
-            'from', // param base name
-            'string', // openApiType
+            $per_page,
+            'per_page', // param base name
+            'integer', // openApiType
             'form', // style
             true, // explode
             false // required
         ) ?? []);
         // query params
         $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
-            $to,
-            'to', // param base name
+            $filter_account_type,
+            'filter[account_type]', // param base name
             'string', // openApiType
             'form', // style
             true, // explode
@@ -2167,13 +2188,22 @@ class AdminApi
         ) ?? []);
         // query params
         $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
-            $client,
-            'client', // param base name
+            $filter_q,
+            'filter[q]', // param base name
             'string', // openApiType
             'form', // style
             true, // explode
             false // required
         ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $page,
+            'page', // param base name
+            'integer', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
 
 
 
@@ -2239,6 +2269,1660 @@ class AdminApi
         );
     }
 
+    /**
+     * Operation getApiV3AdminCreditLedger
+     *
+     * 列出积分流水
+     *
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
+     * @param  string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
+     * @param  string|null $filter_kind 流水类型 (optional)
+     * @param  string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
+     * @param  string|null $filter_source 来源 (optional)
+     * @param  string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
+     * @param  string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditLedger200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3AdminCreditLedger($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
+    {
+        list($response) = $this->getApiV3AdminCreditLedgerWithHttpInfo($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3AdminCreditLedgerWithHttpInfo
+     *
+     * 列出积分流水
+     *
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
+     * @param  string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
+     * @param  string|null $filter_kind 流水类型 (optional)
+     * @param  string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
+     * @param  string|null $filter_source 来源 (optional)
+     * @param  string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
+     * @param  string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3AdminCreditLedger200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3AdminCreditLedgerWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
+    {
+        $request = $this->getApiV3AdminCreditLedgerRequest($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response',
+                        $request,
+                        $response,
+                    );
+                case 401:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 401:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3AdminCreditLedgerAsync
+     *
+     * 列出积分流水
+     *
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
+     * @param  string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
+     * @param  string|null $filter_kind 流水类型 (optional)
+     * @param  string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
+     * @param  string|null $filter_source 来源 (optional)
+     * @param  string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
+     * @param  string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3AdminCreditLedgerAsync($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
+    {
+        return $this->getApiV3AdminCreditLedgerAsyncWithHttpInfo($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3AdminCreditLedgerAsyncWithHttpInfo
+     *
+     * 列出积分流水
+     *
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
+     * @param  string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
+     * @param  string|null $filter_kind 流水类型 (optional)
+     * @param  string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
+     * @param  string|null $filter_source 来源 (optional)
+     * @param  string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
+     * @param  string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3AdminCreditLedgerAsyncWithHttpInfo($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3AdminCreditLedger200Response';
+        $request = $this->getApiV3AdminCreditLedgerRequest($per_page, $filter_account_type, $filter_account_id, $filter_kind, $filter_bucket, $filter_source, $filter_from, $filter_to, $page, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3AdminCreditLedger'
+     *
+     * @param  int|null $per_page 每页数量,最大 100 (optional, default to 20)
+     * @param  string|null $filter_account_type 账号类型;给 account_id 时必填 (optional)
+     * @param  string|null $filter_account_id 账号 id(用户 uuid 或游客设备 id) (optional)
+     * @param  string|null $filter_kind 流水类型 (optional)
+     * @param  string|null $filter_bucket 池子:free 每日赠送 / earned 积分余额 (optional)
+     * @param  string|null $filter_source 来源 (optional)
+     * @param  string|null $filter_from 起始日(UTC,Y-m-d,按流水归属日) (optional)
+     * @param  string|null $filter_to 结束日(UTC,Y-m-d,含当天) (optional)
+     * @param  int|null $page 页码 (optional, default to 1)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditLedger'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3AdminCreditLedgerRequest($per_page = 20, $filter_account_type = null, $filter_account_id = null, $filter_kind = null, $filter_bucket = null, $filter_source = null, $filter_from = null, $filter_to = null, $page = 1, string $contentType = self::contentTypes['getApiV3AdminCreditLedger'][0])
+    {
+
+
+
+
+
+
+
+
+
+
+
+        $resourcePath = '/v3/admin/credit-ledger';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $per_page,
+            'per_page', // param base name
+            'integer', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $filter_account_type,
+            'filter[account_type]', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $filter_account_id,
+            'filter[account_id]', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $filter_kind,
+            'filter[kind]', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $filter_bucket,
+            'filter[bucket]', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $filter_source,
+            'filter[source]', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $filter_from,
+            'filter[from]', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $filter_to,
+            'filter[to]', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $page,
+            'page', // param base name
+            'integer', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Operation getApiV3AdminCreditOverview
+     *
+     * 积分概览
+     *
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditOverview200Response|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3AdminCreditOverview(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
+    {
+        list($response) = $this->getApiV3AdminCreditOverviewWithHttpInfo($contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3AdminCreditOverviewWithHttpInfo
+     *
+     * 积分概览
+     *
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3AdminCreditOverview200Response|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3AdminCreditOverviewWithHttpInfo(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
+    {
+        $request = $this->getApiV3AdminCreditOverviewRequest($contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response',
+                        $request,
+                        $response,
+                    );
+                case 401:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 401:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3AdminCreditOverviewAsync
+     *
+     * 积分概览
+     *
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3AdminCreditOverviewAsync(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
+    {
+        return $this->getApiV3AdminCreditOverviewAsyncWithHttpInfo($contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3AdminCreditOverviewAsyncWithHttpInfo
+     *
+     * 积分概览
+     *
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3AdminCreditOverviewAsyncWithHttpInfo(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3AdminCreditOverview200Response';
+        $request = $this->getApiV3AdminCreditOverviewRequest($contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3AdminCreditOverview'
+     *
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminCreditOverview'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3AdminCreditOverviewRequest(string $contentType = self::contentTypes['getApiV3AdminCreditOverview'][0])
+    {
+
+
+        $resourcePath = '/v3/admin/credit-overview';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Operation getApiV3AdminReadingStats
+     *
+     * 阅读统计
+     *
+     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
+     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
+     * @param  string|null $client 客户端 (optional, default to 'all')
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
+     */
+    public function getApiV3AdminReadingStats($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    {
+        list($response) = $this->getApiV3AdminReadingStatsWithHttpInfo($from, $to, $client, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation getApiV3AdminReadingStatsWithHttpInfo
+     *
+     * 阅读统计
+     *
+     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
+     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
+     * @param  string|null $client 客户端 (optional, default to 'all')
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\GetApiV3AdminReadingStats200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function getApiV3AdminReadingStatsWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    {
+        $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
+                        $request,
+                        $response,
+                    );
+                case 401:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 401:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation getApiV3AdminReadingStatsAsync
+     *
+     * 阅读统计
+     *
+     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
+     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
+     * @param  string|null $client 客户端 (optional, default to 'all')
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3AdminReadingStatsAsync($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    {
+        return $this->getApiV3AdminReadingStatsAsyncWithHttpInfo($from, $to, $client, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation getApiV3AdminReadingStatsAsyncWithHttpInfo
+     *
+     * 阅读统计
+     *
+     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
+     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
+     * @param  string|null $client 客户端 (optional, default to 'all')
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function getApiV3AdminReadingStatsAsyncWithHttpInfo($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    {
+        $returnType = '\WikipaliApi\Model\GetApiV3AdminReadingStats200Response';
+        $request = $this->getApiV3AdminReadingStatsRequest($from, $to, $client, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'getApiV3AdminReadingStats'
+     *
+     * @param  string|null $from 起始日(UTC,Y-m-d) (optional, default to '今天往前 29 天')
+     * @param  string|null $to 结束日(UTC,Y-m-d,含当天) (optional, default to '今天')
+     * @param  string|null $client 客户端 (optional, default to 'all')
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['getApiV3AdminReadingStats'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function getApiV3AdminReadingStatsRequest($from = '今天往前 29 天', $to = '今天', $client = 'all', string $contentType = self::contentTypes['getApiV3AdminReadingStats'][0])
+    {
+
+
+
+
+
+        $resourcePath = '/v3/admin/reading-stats';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $from,
+            'from', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $to,
+            'to', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+        // query params
+        $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+            $client,
+            'client', // param base name
+            'string', // openApiType
+            'form', // style
+            true, // explode
+            false // required
+        ) ?? []);
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'GET',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Operation postApiV3AdminCreditAdjustments
+     *
+     * 手工加减积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request post_api_v3_admin_credit_adjustments_request (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
+     */
+    public function postApiV3AdminCreditAdjustments($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
+    {
+        list($response) = $this->postApiV3AdminCreditAdjustmentsWithHttpInfo($post_api_v3_admin_credit_adjustments_request, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation postApiV3AdminCreditAdjustmentsWithHttpInfo
+     *
+     * 手工加减积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function postApiV3AdminCreditAdjustmentsWithHttpInfo($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
+    {
+        $request = $this->postApiV3AdminCreditAdjustmentsRequest($post_api_v3_admin_credit_adjustments_request, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
+                        $request,
+                        $response,
+                    );
+                case 201:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
+                        $request,
+                        $response,
+                    );
+                case 401:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 201:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 401:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation postApiV3AdminCreditAdjustmentsAsync
+     *
+     * 手工加减积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function postApiV3AdminCreditAdjustmentsAsync($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
+    {
+        return $this->postApiV3AdminCreditAdjustmentsAsyncWithHttpInfo($post_api_v3_admin_credit_adjustments_request, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation postApiV3AdminCreditAdjustmentsAsyncWithHttpInfo
+     *
+     * 手工加减积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function postApiV3AdminCreditAdjustmentsAsyncWithHttpInfo($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
+    {
+        $returnType = '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200Response';
+        $request = $this->postApiV3AdminCreditAdjustmentsRequest($post_api_v3_admin_credit_adjustments_request, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'postApiV3AdminCreditAdjustments'
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditAdjustmentsRequest $post_api_v3_admin_credit_adjustments_request (required)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditAdjustments'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function postApiV3AdminCreditAdjustmentsRequest($post_api_v3_admin_credit_adjustments_request, string $contentType = self::contentTypes['postApiV3AdminCreditAdjustments'][0])
+    {
+
+        // verify the required parameter 'post_api_v3_admin_credit_adjustments_request' is set
+        if ($post_api_v3_admin_credit_adjustments_request === null || (is_array($post_api_v3_admin_credit_adjustments_request) && count($post_api_v3_admin_credit_adjustments_request) === 0)) {
+            throw new \InvalidArgumentException(
+                'Missing the required parameter $post_api_v3_admin_credit_adjustments_request when calling postApiV3AdminCreditAdjustments'
+            );
+        }
+
+
+        $resourcePath = '/v3/admin/credit-adjustments';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (isset($post_api_v3_admin_credit_adjustments_request)) {
+            if (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the body
+                try {
+                    $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($post_api_v3_admin_credit_adjustments_request), JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                $httpBody = $post_api_v3_admin_credit_adjustments_request;
+            }
+        } elseif (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'POST',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
+    /**
+     * Operation postApiV3AdminCreditSettlements
+     *
+     * 手工结算积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request post_api_v3_admin_credit_settlements_request (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return \WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails
+     */
+    public function postApiV3AdminCreditSettlements($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
+    {
+        list($response) = $this->postApiV3AdminCreditSettlementsWithHttpInfo($post_api_v3_admin_credit_settlements_request, $contentType);
+        return $response;
+    }
+
+    /**
+     * Operation postApiV3AdminCreditSettlementsWithHttpInfo
+     *
+     * 手工结算积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
+     *
+     * @throws \WikipaliApi\ApiException on non-2xx response or if the response body is not in the expected format
+     * @throws \InvalidArgumentException
+     * @return array of \WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response|\WikipaliApi\Model\ProblemDetails|\WikipaliApi\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings)
+     */
+    public function postApiV3AdminCreditSettlementsWithHttpInfo($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
+    {
+        $request = $this->postApiV3AdminCreditSettlementsRequest($post_api_v3_admin_credit_settlements_request, $contentType);
+
+        try {
+            $options = $this->createHttpClientOption();
+            try {
+                $response = $this->client->send($request, $options);
+            } catch (RequestException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+                    $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+                );
+            } catch (ConnectException $e) {
+                throw new ApiException(
+                    "[{$e->getCode()}] {$e->getMessage()}",
+                    (int) $e->getCode(),
+                    null,
+                    null
+                );
+            }
+
+            $statusCode = $response->getStatusCode();
+
+
+            switch($statusCode) {
+                case 200:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
+                        $request,
+                        $response,
+                    );
+                case 201:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
+                        $request,
+                        $response,
+                    );
+                case 401:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+                case 422:
+                    return $this->handleResponseWithDataType(
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $request,
+                        $response,
+                    );
+            }
+
+            
+
+            if ($statusCode < 200 || $statusCode > 299) {
+                throw new ApiException(
+                    sprintf(
+                        '[%d] Error connecting to the API (%s)',
+                        $statusCode,
+                        (string) $request->getUri()
+                    ),
+                    $statusCode,
+                    $response->getHeaders(),
+                    (string) $response->getBody()
+                );
+            }
+
+            return $this->handleResponseWithDataType(
+                '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
+                $request,
+                $response,
+            );
+        } catch (ApiException $e) {
+            switch ($e->getCode()) {
+                case 200:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 201:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 401:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+                case 422:
+                    $data = ObjectSerializer::deserialize(
+                        $e->getResponseBody(),
+                        '\WikipaliApi\Model\ProblemDetails',
+                        $e->getResponseHeaders()
+                    );
+                    $e->setResponseObject($data);
+                    throw $e;
+            }
+        
+
+            throw $e;
+        }
+    }
+
+    /**
+     * Operation postApiV3AdminCreditSettlementsAsync
+     *
+     * 手工结算积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function postApiV3AdminCreditSettlementsAsync($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
+    {
+        return $this->postApiV3AdminCreditSettlementsAsyncWithHttpInfo($post_api_v3_admin_credit_settlements_request, $contentType)
+            ->then(
+                function ($response) {
+                    return $response[0];
+                }
+            );
+    }
+
+    /**
+     * Operation postApiV3AdminCreditSettlementsAsyncWithHttpInfo
+     *
+     * 手工结算积分
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Promise\PromiseInterface
+     */
+    public function postApiV3AdminCreditSettlementsAsyncWithHttpInfo($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
+    {
+        $returnType = '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200Response';
+        $request = $this->postApiV3AdminCreditSettlementsRequest($post_api_v3_admin_credit_settlements_request, $contentType);
+
+        return $this->client
+            ->sendAsync($request, $this->createHttpClientOption())
+            ->then(
+                function ($response) use ($returnType) {
+                    if ($returnType === '\SplFileObject') {
+                        $content = $response->getBody(); //stream goes to serializer
+                    } else {
+                        $content = (string) $response->getBody();
+                        if ($returnType !== 'string') {
+                            $content = json_decode($content);
+                        }
+                    }
+
+                    return [
+                        ObjectSerializer::deserialize($content, $returnType, []),
+                        $response->getStatusCode(),
+                        $response->getHeaders()
+                    ];
+                },
+                function ($exception) {
+                    $response = $exception->getResponse();
+                    $statusCode = $response->getStatusCode();
+                    throw new ApiException(
+                        sprintf(
+                            '[%d] Error connecting to the API (%s)',
+                            $statusCode,
+                            $exception->getRequest()->getUri()
+                        ),
+                        $statusCode,
+                        $response->getHeaders(),
+                        (string) $response->getBody()
+                    );
+                }
+            );
+    }
+
+    /**
+     * Create request for operation 'postApiV3AdminCreditSettlements'
+     *
+     * @param  \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest|null $post_api_v3_admin_credit_settlements_request (optional)
+     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['postApiV3AdminCreditSettlements'] to see the possible values for this operation
+     *
+     * @throws \InvalidArgumentException
+     * @return \GuzzleHttp\Psr7\Request
+     */
+    public function postApiV3AdminCreditSettlementsRequest($post_api_v3_admin_credit_settlements_request = null, string $contentType = self::contentTypes['postApiV3AdminCreditSettlements'][0])
+    {
+
+
+
+        $resourcePath = '/v3/admin/credit-settlements';
+        $formParams = [];
+        $queryParams = [];
+        $headerParams = [];
+        $httpBody = '';
+        $multipart = false;
+
+
+
+
+
+        $headers = $this->headerSelector->selectHeaders(
+            ['application/json', 'application/problem+json', ],
+            $contentType,
+            $multipart
+        );
+
+        // for model (json/xml)
+        if (isset($post_api_v3_admin_credit_settlements_request)) {
+            if (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the body
+                try {
+                    $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($post_api_v3_admin_credit_settlements_request), JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                $httpBody = $post_api_v3_admin_credit_settlements_request;
+            }
+        } elseif (count($formParams) > 0) {
+            if ($multipart) {
+                $multipartContents = [];
+                foreach ($formParams as $formParamName => $formParamValue) {
+                    $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+                    foreach ($formParamValueItems as $formParamValueItem) {
+                        $multipartContents[] = [
+                            'name' => $formParamName,
+                            'contents' => $formParamValueItem
+                        ];
+                    }
+                }
+                // for HTTP post (form)
+                $httpBody = new MultipartStream($multipartContents);
+
+            } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+                # if Content-Type contains "application/json", json_encode the form parameters
+                try {
+                    $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
+                } catch (\JsonException $e) {
+                    throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
+                }
+            } else {
+                // for HTTP post (form)
+                $httpBody = ObjectSerializer::buildQuery($formParams);
+            }
+        }
+
+        // this endpoint requires Bearer authentication (access token)
+        if (!empty($this->config->getAccessToken())) {
+            $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
+        }
+
+        $defaultHeaders = [];
+        if ($this->config->getUserAgent()) {
+            $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+        }
+
+        $headers = array_merge(
+            $defaultHeaders,
+            $headerParams,
+            $headers
+        );
+
+        $operationHost = $this->config->getHost();
+        $query = ObjectSerializer::buildQuery($queryParams);
+        return new Request(
+            'POST',
+            $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+            $headers,
+            $httpBody
+        );
+    }
+
     /**
      * Create http client option
      *

+ 443 - 0
api-test/client/lib/Model/GetApiV3AdminCreditAccounts200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3AdminCreditAccounts200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditAccounts200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditAccounts200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_accounts_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\GetApiV3AdminCreditAccounts200ResponseDataInner[]',
+        'meta' => '\WikipaliApi\Model\PaginationMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditAccounts200ResponseDataInner[]|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminCreditAccounts200ResponseDataInner[]|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\PaginationMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\PaginationMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 763 - 0
api-test/client/lib/Model/GetApiV3AdminCreditAccounts200ResponseDataInner.php

@@ -0,0 +1,763 @@
+<?php
+/**
+ * GetApiV3AdminCreditAccounts200ResponseDataInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditAccounts200ResponseDataInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditAccounts200ResponseDataInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_accounts_200_response_data_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'account_type' => 'string',
+        'account_id' => 'string',
+        'user' => '\WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser',
+        'earned_balance' => 'int',
+        'earned_total' => 'int',
+        'adjusted_total' => 'int',
+        'spent_total' => 'int',
+        'free_used_today' => 'int',
+        'daily_free' => 'int',
+        'last_activity_at' => 'string'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'account_type' => null,
+        'account_id' => null,
+        'user' => null,
+        'earned_balance' => null,
+        'earned_total' => null,
+        'adjusted_total' => null,
+        'spent_total' => null,
+        'free_used_today' => null,
+        'daily_free' => null,
+        'last_activity_at' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'account_type' => false,
+        'account_id' => false,
+        'user' => true,
+        'earned_balance' => false,
+        'earned_total' => false,
+        'adjusted_total' => false,
+        'spent_total' => false,
+        'free_used_today' => false,
+        'daily_free' => false,
+        'last_activity_at' => true
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'account_type' => 'account_type',
+        'account_id' => 'account_id',
+        'user' => 'user',
+        'earned_balance' => 'earned_balance',
+        'earned_total' => 'earned_total',
+        'adjusted_total' => 'adjusted_total',
+        'spent_total' => 'spent_total',
+        'free_used_today' => 'free_used_today',
+        'daily_free' => 'daily_free',
+        'last_activity_at' => 'last_activity_at'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'account_type' => 'setAccountType',
+        'account_id' => 'setAccountId',
+        'user' => 'setUser',
+        'earned_balance' => 'setEarnedBalance',
+        'earned_total' => 'setEarnedTotal',
+        'adjusted_total' => 'setAdjustedTotal',
+        'spent_total' => 'setSpentTotal',
+        'free_used_today' => 'setFreeUsedToday',
+        'daily_free' => 'setDailyFree',
+        'last_activity_at' => 'setLastActivityAt'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'account_type' => 'getAccountType',
+        'account_id' => 'getAccountId',
+        'user' => 'getUser',
+        'earned_balance' => 'getEarnedBalance',
+        'earned_total' => 'getEarnedTotal',
+        'adjusted_total' => 'getAdjustedTotal',
+        'spent_total' => 'getSpentTotal',
+        'free_used_today' => 'getFreeUsedToday',
+        'daily_free' => 'getDailyFree',
+        'last_activity_at' => 'getLastActivityAt'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+    public const ACCOUNT_TYPE_USER = 'user';
+    public const ACCOUNT_TYPE_GUEST = 'guest';
+
+    /**
+     * Gets allowable values of the enum
+     *
+     * @return string[]
+     */
+    public function getAccountTypeAllowableValues()
+    {
+        return [
+            self::ACCOUNT_TYPE_USER,
+            self::ACCOUNT_TYPE_GUEST,
+        ];
+    }
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('account_type', $data ?? [], null);
+        $this->setIfExists('account_id', $data ?? [], null);
+        $this->setIfExists('user', $data ?? [], null);
+        $this->setIfExists('earned_balance', $data ?? [], null);
+        $this->setIfExists('earned_total', $data ?? [], null);
+        $this->setIfExists('adjusted_total', $data ?? [], null);
+        $this->setIfExists('spent_total', $data ?? [], null);
+        $this->setIfExists('free_used_today', $data ?? [], null);
+        $this->setIfExists('daily_free', $data ?? [], null);
+        $this->setIfExists('last_activity_at', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        $allowedValues = $this->getAccountTypeAllowableValues();
+        if (!is_null($this->container['account_type']) && !in_array($this->container['account_type'], $allowedValues, true)) {
+            $invalidProperties[] = sprintf(
+                "invalid value '%s' for 'account_type', must be one of '%s'",
+                $this->container['account_type'],
+                implode("', '", $allowedValues)
+            );
+        }
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets account_type
+     *
+     * @return string|null
+     */
+    public function getAccountType()
+    {
+        return $this->container['account_type'];
+    }
+
+    /**
+     * Sets account_type
+     *
+     * @param string|null $account_type account_type
+     *
+     * @return self
+     */
+    public function setAccountType($account_type)
+    {
+        if (is_null($account_type)) {
+            throw new \InvalidArgumentException('non-nullable account_type cannot be null');
+        }
+        $allowedValues = $this->getAccountTypeAllowableValues();
+        if (!in_array($account_type, $allowedValues, true)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    "Invalid value '%s' for 'account_type', must be one of '%s'",
+                    $account_type,
+                    implode("', '", $allowedValues)
+                )
+            );
+        }
+        $this->container['account_type'] = $account_type;
+
+        return $this;
+    }
+
+    /**
+     * Gets account_id
+     *
+     * @return string|null
+     */
+    public function getAccountId()
+    {
+        return $this->container['account_id'];
+    }
+
+    /**
+     * Sets account_id
+     *
+     * @param string|null $account_id account_id
+     *
+     * @return self
+     */
+    public function setAccountId($account_id)
+    {
+        if (is_null($account_id)) {
+            throw new \InvalidArgumentException('non-nullable account_id cannot be null');
+        }
+        $this->container['account_id'] = $account_id;
+
+        return $this;
+    }
+
+    /**
+     * Gets user
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null
+     */
+    public function getUser()
+    {
+        return $this->container['user'];
+    }
+
+    /**
+     * Sets user
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null $user user
+     *
+     * @return self
+     */
+    public function setUser($user)
+    {
+        if (is_null($user)) {
+            array_push($this->openAPINullablesSetToNull, 'user');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('user', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['user'] = $user;
+
+        return $this;
+    }
+
+    /**
+     * Gets earned_balance
+     *
+     * @return int|null
+     */
+    public function getEarnedBalance()
+    {
+        return $this->container['earned_balance'];
+    }
+
+    /**
+     * Sets earned_balance
+     *
+     * @param int|null $earned_balance earned_balance
+     *
+     * @return self
+     */
+    public function setEarnedBalance($earned_balance)
+    {
+        if (is_null($earned_balance)) {
+            throw new \InvalidArgumentException('non-nullable earned_balance cannot be null');
+        }
+        $this->container['earned_balance'] = $earned_balance;
+
+        return $this;
+    }
+
+    /**
+     * Gets earned_total
+     *
+     * @return int|null
+     */
+    public function getEarnedTotal()
+    {
+        return $this->container['earned_total'];
+    }
+
+    /**
+     * Sets earned_total
+     *
+     * @param int|null $earned_total earned_total
+     *
+     * @return self
+     */
+    public function setEarnedTotal($earned_total)
+    {
+        if (is_null($earned_total)) {
+            throw new \InvalidArgumentException('non-nullable earned_total cannot be null');
+        }
+        $this->container['earned_total'] = $earned_total;
+
+        return $this;
+    }
+
+    /**
+     * Gets adjusted_total
+     *
+     * @return int|null
+     */
+    public function getAdjustedTotal()
+    {
+        return $this->container['adjusted_total'];
+    }
+
+    /**
+     * Sets adjusted_total
+     *
+     * @param int|null $adjusted_total adjusted_total
+     *
+     * @return self
+     */
+    public function setAdjustedTotal($adjusted_total)
+    {
+        if (is_null($adjusted_total)) {
+            throw new \InvalidArgumentException('non-nullable adjusted_total cannot be null');
+        }
+        $this->container['adjusted_total'] = $adjusted_total;
+
+        return $this;
+    }
+
+    /**
+     * Gets spent_total
+     *
+     * @return int|null
+     */
+    public function getSpentTotal()
+    {
+        return $this->container['spent_total'];
+    }
+
+    /**
+     * Sets spent_total
+     *
+     * @param int|null $spent_total spent_total
+     *
+     * @return self
+     */
+    public function setSpentTotal($spent_total)
+    {
+        if (is_null($spent_total)) {
+            throw new \InvalidArgumentException('non-nullable spent_total cannot be null');
+        }
+        $this->container['spent_total'] = $spent_total;
+
+        return $this;
+    }
+
+    /**
+     * Gets free_used_today
+     *
+     * @return int|null
+     */
+    public function getFreeUsedToday()
+    {
+        return $this->container['free_used_today'];
+    }
+
+    /**
+     * Sets free_used_today
+     *
+     * @param int|null $free_used_today free_used_today
+     *
+     * @return self
+     */
+    public function setFreeUsedToday($free_used_today)
+    {
+        if (is_null($free_used_today)) {
+            throw new \InvalidArgumentException('non-nullable free_used_today cannot be null');
+        }
+        $this->container['free_used_today'] = $free_used_today;
+
+        return $this;
+    }
+
+    /**
+     * Gets daily_free
+     *
+     * @return int|null
+     */
+    public function getDailyFree()
+    {
+        return $this->container['daily_free'];
+    }
+
+    /**
+     * Sets daily_free
+     *
+     * @param int|null $daily_free daily_free
+     *
+     * @return self
+     */
+    public function setDailyFree($daily_free)
+    {
+        if (is_null($daily_free)) {
+            throw new \InvalidArgumentException('non-nullable daily_free cannot be null');
+        }
+        $this->container['daily_free'] = $daily_free;
+
+        return $this;
+    }
+
+    /**
+     * Gets last_activity_at
+     *
+     * @return string|null
+     */
+    public function getLastActivityAt()
+    {
+        return $this->container['last_activity_at'];
+    }
+
+    /**
+     * Sets last_activity_at
+     *
+     * @param string|null $last_activity_at last_activity_at
+     *
+     * @return self
+     */
+    public function setLastActivityAt($last_activity_at)
+    {
+        if (is_null($last_activity_at)) {
+            array_push($this->openAPINullablesSetToNull, 'last_activity_at');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('last_activity_at', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['last_activity_at'] = $last_activity_at;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 443 - 0
api-test/client/lib/Model/GetApiV3AdminCreditLedger200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * GetApiV3AdminCreditLedger200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditLedger200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditLedger200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_ledger_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseData[]',
+        'meta' => '\WikipaliApi\Model\PaginationMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseData[]|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseData[]|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\PaginationMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\PaginationMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 409 - 0
api-test/client/lib/Model/GetApiV3AdminCreditOverview200Response.php

@@ -0,0 +1,409 @@
+<?php
+/**
+ * GetApiV3AdminCreditOverview200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditOverview200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditOverview200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_overview_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseData'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseData|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseData|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 620 - 0
api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseData.php

@@ -0,0 +1,620 @@
+<?php
+/**
+ * GetApiV3AdminCreditOverview200ResponseData
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditOverview200ResponseData Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditOverview200ResponseData implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_overview_200_response_data';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'today' => 'string',
+        'earn_since' => 'string',
+        'policy_version' => 'int',
+        'policy' => 'object',
+        'totals' => '\WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataTotals',
+        'recent_days' => '\WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner[]',
+        'last_settlement' => '\WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataLastSettlement'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'today' => null,
+        'earn_since' => null,
+        'policy_version' => null,
+        'policy' => null,
+        'totals' => null,
+        'recent_days' => null,
+        'last_settlement' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'today' => false,
+        'earn_since' => false,
+        'policy_version' => false,
+        'policy' => false,
+        'totals' => false,
+        'recent_days' => false,
+        'last_settlement' => true
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'today' => 'today',
+        'earn_since' => 'earn_since',
+        'policy_version' => 'policy_version',
+        'policy' => 'policy',
+        'totals' => 'totals',
+        'recent_days' => 'recent_days',
+        'last_settlement' => 'last_settlement'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'today' => 'setToday',
+        'earn_since' => 'setEarnSince',
+        'policy_version' => 'setPolicyVersion',
+        'policy' => 'setPolicy',
+        'totals' => 'setTotals',
+        'recent_days' => 'setRecentDays',
+        'last_settlement' => 'setLastSettlement'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'today' => 'getToday',
+        'earn_since' => 'getEarnSince',
+        'policy_version' => 'getPolicyVersion',
+        'policy' => 'getPolicy',
+        'totals' => 'getTotals',
+        'recent_days' => 'getRecentDays',
+        'last_settlement' => 'getLastSettlement'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('today', $data ?? [], null);
+        $this->setIfExists('earn_since', $data ?? [], null);
+        $this->setIfExists('policy_version', $data ?? [], null);
+        $this->setIfExists('policy', $data ?? [], null);
+        $this->setIfExists('totals', $data ?? [], null);
+        $this->setIfExists('recent_days', $data ?? [], null);
+        $this->setIfExists('last_settlement', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets today
+     *
+     * @return string|null
+     */
+    public function getToday()
+    {
+        return $this->container['today'];
+    }
+
+    /**
+     * Sets today
+     *
+     * @param string|null $today today
+     *
+     * @return self
+     */
+    public function setToday($today)
+    {
+        if (is_null($today)) {
+            throw new \InvalidArgumentException('non-nullable today cannot be null');
+        }
+        $this->container['today'] = $today;
+
+        return $this;
+    }
+
+    /**
+     * Gets earn_since
+     *
+     * @return string|null
+     */
+    public function getEarnSince()
+    {
+        return $this->container['earn_since'];
+    }
+
+    /**
+     * Sets earn_since
+     *
+     * @param string|null $earn_since earn_since
+     *
+     * @return self
+     */
+    public function setEarnSince($earn_since)
+    {
+        if (is_null($earn_since)) {
+            throw new \InvalidArgumentException('non-nullable earn_since cannot be null');
+        }
+        $this->container['earn_since'] = $earn_since;
+
+        return $this;
+    }
+
+    /**
+     * Gets policy_version
+     *
+     * @return int|null
+     */
+    public function getPolicyVersion()
+    {
+        return $this->container['policy_version'];
+    }
+
+    /**
+     * Sets policy_version
+     *
+     * @param int|null $policy_version policy_version
+     *
+     * @return self
+     */
+    public function setPolicyVersion($policy_version)
+    {
+        if (is_null($policy_version)) {
+            throw new \InvalidArgumentException('non-nullable policy_version cannot be null');
+        }
+        $this->container['policy_version'] = $policy_version;
+
+        return $this;
+    }
+
+    /**
+     * Gets policy
+     *
+     * @return object|null
+     */
+    public function getPolicy()
+    {
+        return $this->container['policy'];
+    }
+
+    /**
+     * Sets policy
+     *
+     * @param object|null $policy policy
+     *
+     * @return self
+     */
+    public function setPolicy($policy)
+    {
+        if (is_null($policy)) {
+            throw new \InvalidArgumentException('non-nullable policy cannot be null');
+        }
+        $this->container['policy'] = $policy;
+
+        return $this;
+    }
+
+    /**
+     * Gets totals
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataTotals|null
+     */
+    public function getTotals()
+    {
+        return $this->container['totals'];
+    }
+
+    /**
+     * Sets totals
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataTotals|null $totals totals
+     *
+     * @return self
+     */
+    public function setTotals($totals)
+    {
+        if (is_null($totals)) {
+            throw new \InvalidArgumentException('non-nullable totals cannot be null');
+        }
+        $this->container['totals'] = $totals;
+
+        return $this;
+    }
+
+    /**
+     * Gets recent_days
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner[]|null
+     */
+    public function getRecentDays()
+    {
+        return $this->container['recent_days'];
+    }
+
+    /**
+     * Sets recent_days
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner[]|null $recent_days recent_days
+     *
+     * @return self
+     */
+    public function setRecentDays($recent_days)
+    {
+        if (is_null($recent_days)) {
+            throw new \InvalidArgumentException('non-nullable recent_days cannot be null');
+        }
+        $this->container['recent_days'] = $recent_days;
+
+        return $this;
+    }
+
+    /**
+     * Gets last_settlement
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataLastSettlement|null
+     */
+    public function getLastSettlement()
+    {
+        return $this->container['last_settlement'];
+    }
+
+    /**
+     * Sets last_settlement
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminCreditOverview200ResponseDataLastSettlement|null $last_settlement last_settlement
+     *
+     * @return self
+     */
+    public function setLastSettlement($last_settlement)
+    {
+        if (is_null($last_settlement)) {
+            array_push($this->openAPINullablesSetToNull, 'last_settlement');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('last_settlement', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['last_settlement'] = $last_settlement;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 681 - 0
api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseDataLastSettlement.php

@@ -0,0 +1,681 @@
+<?php
+/**
+ * GetApiV3AdminCreditOverview200ResponseDataLastSettlement
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditOverview200ResponseDataLastSettlement Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditOverview200ResponseDataLastSettlement implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_overview_200_response_data_last_settlement';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'mode' => 'string',
+        'from' => 'string',
+        'to' => 'string',
+        'users' => 'int',
+        'pairs' => 'int',
+        'trigger' => 'string',
+        'operator' => 'string',
+        'ran_at' => 'string',
+        'seconds' => 'float'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'mode' => null,
+        'from' => null,
+        'to' => null,
+        'users' => null,
+        'pairs' => null,
+        'trigger' => null,
+        'operator' => null,
+        'ran_at' => null,
+        'seconds' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'mode' => false,
+        'from' => false,
+        'to' => false,
+        'users' => false,
+        'pairs' => false,
+        'trigger' => false,
+        'operator' => false,
+        'ran_at' => false,
+        'seconds' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'mode' => 'mode',
+        'from' => 'from',
+        'to' => 'to',
+        'users' => 'users',
+        'pairs' => 'pairs',
+        'trigger' => 'trigger',
+        'operator' => 'operator',
+        'ran_at' => 'ran_at',
+        'seconds' => 'seconds'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'mode' => 'setMode',
+        'from' => 'setFrom',
+        'to' => 'setTo',
+        'users' => 'setUsers',
+        'pairs' => 'setPairs',
+        'trigger' => 'setTrigger',
+        'operator' => 'setOperator',
+        'ran_at' => 'setRanAt',
+        'seconds' => 'setSeconds'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'mode' => 'getMode',
+        'from' => 'getFrom',
+        'to' => 'getTo',
+        'users' => 'getUsers',
+        'pairs' => 'getPairs',
+        'trigger' => 'getTrigger',
+        'operator' => 'getOperator',
+        'ran_at' => 'getRanAt',
+        'seconds' => 'getSeconds'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('mode', $data ?? [], null);
+        $this->setIfExists('from', $data ?? [], null);
+        $this->setIfExists('to', $data ?? [], null);
+        $this->setIfExists('users', $data ?? [], null);
+        $this->setIfExists('pairs', $data ?? [], null);
+        $this->setIfExists('trigger', $data ?? [], null);
+        $this->setIfExists('operator', $data ?? [], null);
+        $this->setIfExists('ran_at', $data ?? [], null);
+        $this->setIfExists('seconds', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets mode
+     *
+     * @return string|null
+     */
+    public function getMode()
+    {
+        return $this->container['mode'];
+    }
+
+    /**
+     * Sets mode
+     *
+     * @param string|null $mode mode
+     *
+     * @return self
+     */
+    public function setMode($mode)
+    {
+        if (is_null($mode)) {
+            throw new \InvalidArgumentException('non-nullable mode cannot be null');
+        }
+        $this->container['mode'] = $mode;
+
+        return $this;
+    }
+
+    /**
+     * Gets from
+     *
+     * @return string|null
+     */
+    public function getFrom()
+    {
+        return $this->container['from'];
+    }
+
+    /**
+     * Sets from
+     *
+     * @param string|null $from from
+     *
+     * @return self
+     */
+    public function setFrom($from)
+    {
+        if (is_null($from)) {
+            throw new \InvalidArgumentException('non-nullable from cannot be null');
+        }
+        $this->container['from'] = $from;
+
+        return $this;
+    }
+
+    /**
+     * Gets to
+     *
+     * @return string|null
+     */
+    public function getTo()
+    {
+        return $this->container['to'];
+    }
+
+    /**
+     * Sets to
+     *
+     * @param string|null $to to
+     *
+     * @return self
+     */
+    public function setTo($to)
+    {
+        if (is_null($to)) {
+            throw new \InvalidArgumentException('non-nullable to cannot be null');
+        }
+        $this->container['to'] = $to;
+
+        return $this;
+    }
+
+    /**
+     * Gets users
+     *
+     * @return int|null
+     */
+    public function getUsers()
+    {
+        return $this->container['users'];
+    }
+
+    /**
+     * Sets users
+     *
+     * @param int|null $users users
+     *
+     * @return self
+     */
+    public function setUsers($users)
+    {
+        if (is_null($users)) {
+            throw new \InvalidArgumentException('non-nullable users cannot be null');
+        }
+        $this->container['users'] = $users;
+
+        return $this;
+    }
+
+    /**
+     * Gets pairs
+     *
+     * @return int|null
+     */
+    public function getPairs()
+    {
+        return $this->container['pairs'];
+    }
+
+    /**
+     * Sets pairs
+     *
+     * @param int|null $pairs pairs
+     *
+     * @return self
+     */
+    public function setPairs($pairs)
+    {
+        if (is_null($pairs)) {
+            throw new \InvalidArgumentException('non-nullable pairs cannot be null');
+        }
+        $this->container['pairs'] = $pairs;
+
+        return $this;
+    }
+
+    /**
+     * Gets trigger
+     *
+     * @return string|null
+     */
+    public function getTrigger()
+    {
+        return $this->container['trigger'];
+    }
+
+    /**
+     * Sets trigger
+     *
+     * @param string|null $trigger trigger
+     *
+     * @return self
+     */
+    public function setTrigger($trigger)
+    {
+        if (is_null($trigger)) {
+            throw new \InvalidArgumentException('non-nullable trigger cannot be null');
+        }
+        $this->container['trigger'] = $trigger;
+
+        return $this;
+    }
+
+    /**
+     * Gets operator
+     *
+     * @return string|null
+     */
+    public function getOperator()
+    {
+        return $this->container['operator'];
+    }
+
+    /**
+     * Sets operator
+     *
+     * @param string|null $operator operator
+     *
+     * @return self
+     */
+    public function setOperator($operator)
+    {
+        if (is_null($operator)) {
+            throw new \InvalidArgumentException('non-nullable operator cannot be null');
+        }
+        $this->container['operator'] = $operator;
+
+        return $this;
+    }
+
+    /**
+     * Gets ran_at
+     *
+     * @return string|null
+     */
+    public function getRanAt()
+    {
+        return $this->container['ran_at'];
+    }
+
+    /**
+     * Sets ran_at
+     *
+     * @param string|null $ran_at ran_at
+     *
+     * @return self
+     */
+    public function setRanAt($ran_at)
+    {
+        if (is_null($ran_at)) {
+            throw new \InvalidArgumentException('non-nullable ran_at cannot be null');
+        }
+        $this->container['ran_at'] = $ran_at;
+
+        return $this;
+    }
+
+    /**
+     * Gets seconds
+     *
+     * @return float|null
+     */
+    public function getSeconds()
+    {
+        return $this->container['seconds'];
+    }
+
+    /**
+     * Sets seconds
+     *
+     * @param float|null $seconds seconds
+     *
+     * @return self
+     */
+    public function setSeconds($seconds)
+    {
+        if (is_null($seconds)) {
+            throw new \InvalidArgumentException('non-nullable seconds cannot be null');
+        }
+        $this->container['seconds'] = $seconds;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 511 - 0
api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner.php

@@ -0,0 +1,511 @@
+<?php
+/**
+ * GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditOverview200ResponseDataRecentDaysInner implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_overview_200_response_data_recent_days_inner';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'day' => 'string',
+        'users' => 'int',
+        'reading' => 'int',
+        'editing' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'day' => null,
+        'users' => null,
+        'reading' => null,
+        'editing' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'day' => false,
+        'users' => false,
+        'reading' => false,
+        'editing' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'day' => 'day',
+        'users' => 'users',
+        'reading' => 'reading',
+        'editing' => 'editing'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'day' => 'setDay',
+        'users' => 'setUsers',
+        'reading' => 'setReading',
+        'editing' => 'setEditing'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'day' => 'getDay',
+        'users' => 'getUsers',
+        'reading' => 'getReading',
+        'editing' => 'getEditing'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('day', $data ?? [], null);
+        $this->setIfExists('users', $data ?? [], null);
+        $this->setIfExists('reading', $data ?? [], null);
+        $this->setIfExists('editing', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets day
+     *
+     * @return string|null
+     */
+    public function getDay()
+    {
+        return $this->container['day'];
+    }
+
+    /**
+     * Sets day
+     *
+     * @param string|null $day day
+     *
+     * @return self
+     */
+    public function setDay($day)
+    {
+        if (is_null($day)) {
+            throw new \InvalidArgumentException('non-nullable day cannot be null');
+        }
+        $this->container['day'] = $day;
+
+        return $this;
+    }
+
+    /**
+     * Gets users
+     *
+     * @return int|null
+     */
+    public function getUsers()
+    {
+        return $this->container['users'];
+    }
+
+    /**
+     * Sets users
+     *
+     * @param int|null $users users
+     *
+     * @return self
+     */
+    public function setUsers($users)
+    {
+        if (is_null($users)) {
+            throw new \InvalidArgumentException('non-nullable users cannot be null');
+        }
+        $this->container['users'] = $users;
+
+        return $this;
+    }
+
+    /**
+     * Gets reading
+     *
+     * @return int|null
+     */
+    public function getReading()
+    {
+        return $this->container['reading'];
+    }
+
+    /**
+     * Sets reading
+     *
+     * @param int|null $reading reading
+     *
+     * @return self
+     */
+    public function setReading($reading)
+    {
+        if (is_null($reading)) {
+            throw new \InvalidArgumentException('non-nullable reading cannot be null');
+        }
+        $this->container['reading'] = $reading;
+
+        return $this;
+    }
+
+    /**
+     * Gets editing
+     *
+     * @return int|null
+     */
+    public function getEditing()
+    {
+        return $this->container['editing'];
+    }
+
+    /**
+     * Sets editing
+     *
+     * @param int|null $editing editing
+     *
+     * @return self
+     */
+    public function setEditing($editing)
+    {
+        if (is_null($editing)) {
+            throw new \InvalidArgumentException('non-nullable editing cannot be null');
+        }
+        $this->container['editing'] = $editing;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 579 - 0
api-test/client/lib/Model/GetApiV3AdminCreditOverview200ResponseDataTotals.php

@@ -0,0 +1,579 @@
+<?php
+/**
+ * GetApiV3AdminCreditOverview200ResponseDataTotals
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * GetApiV3AdminCreditOverview200ResponseDataTotals Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class GetApiV3AdminCreditOverview200ResponseDataTotals implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'get_api_v3_admin_credit_overview_200_response_data_totals';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'user_accounts' => 'int',
+        'guest_accounts' => 'int',
+        'outstanding_balance' => 'int',
+        'earned_total' => 'int',
+        'adjusted_total' => 'int',
+        'spent_today' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'user_accounts' => null,
+        'guest_accounts' => null,
+        'outstanding_balance' => null,
+        'earned_total' => null,
+        'adjusted_total' => null,
+        'spent_today' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'user_accounts' => false,
+        'guest_accounts' => false,
+        'outstanding_balance' => false,
+        'earned_total' => false,
+        'adjusted_total' => false,
+        'spent_today' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'user_accounts' => 'user_accounts',
+        'guest_accounts' => 'guest_accounts',
+        'outstanding_balance' => 'outstanding_balance',
+        'earned_total' => 'earned_total',
+        'adjusted_total' => 'adjusted_total',
+        'spent_today' => 'spent_today'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'user_accounts' => 'setUserAccounts',
+        'guest_accounts' => 'setGuestAccounts',
+        'outstanding_balance' => 'setOutstandingBalance',
+        'earned_total' => 'setEarnedTotal',
+        'adjusted_total' => 'setAdjustedTotal',
+        'spent_today' => 'setSpentToday'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'user_accounts' => 'getUserAccounts',
+        'guest_accounts' => 'getGuestAccounts',
+        'outstanding_balance' => 'getOutstandingBalance',
+        'earned_total' => 'getEarnedTotal',
+        'adjusted_total' => 'getAdjustedTotal',
+        'spent_today' => 'getSpentToday'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('user_accounts', $data ?? [], null);
+        $this->setIfExists('guest_accounts', $data ?? [], null);
+        $this->setIfExists('outstanding_balance', $data ?? [], null);
+        $this->setIfExists('earned_total', $data ?? [], null);
+        $this->setIfExists('adjusted_total', $data ?? [], null);
+        $this->setIfExists('spent_today', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets user_accounts
+     *
+     * @return int|null
+     */
+    public function getUserAccounts()
+    {
+        return $this->container['user_accounts'];
+    }
+
+    /**
+     * Sets user_accounts
+     *
+     * @param int|null $user_accounts user_accounts
+     *
+     * @return self
+     */
+    public function setUserAccounts($user_accounts)
+    {
+        if (is_null($user_accounts)) {
+            throw new \InvalidArgumentException('non-nullable user_accounts cannot be null');
+        }
+        $this->container['user_accounts'] = $user_accounts;
+
+        return $this;
+    }
+
+    /**
+     * Gets guest_accounts
+     *
+     * @return int|null
+     */
+    public function getGuestAccounts()
+    {
+        return $this->container['guest_accounts'];
+    }
+
+    /**
+     * Sets guest_accounts
+     *
+     * @param int|null $guest_accounts guest_accounts
+     *
+     * @return self
+     */
+    public function setGuestAccounts($guest_accounts)
+    {
+        if (is_null($guest_accounts)) {
+            throw new \InvalidArgumentException('non-nullable guest_accounts cannot be null');
+        }
+        $this->container['guest_accounts'] = $guest_accounts;
+
+        return $this;
+    }
+
+    /**
+     * Gets outstanding_balance
+     *
+     * @return int|null
+     */
+    public function getOutstandingBalance()
+    {
+        return $this->container['outstanding_balance'];
+    }
+
+    /**
+     * Sets outstanding_balance
+     *
+     * @param int|null $outstanding_balance outstanding_balance
+     *
+     * @return self
+     */
+    public function setOutstandingBalance($outstanding_balance)
+    {
+        if (is_null($outstanding_balance)) {
+            throw new \InvalidArgumentException('non-nullable outstanding_balance cannot be null');
+        }
+        $this->container['outstanding_balance'] = $outstanding_balance;
+
+        return $this;
+    }
+
+    /**
+     * Gets earned_total
+     *
+     * @return int|null
+     */
+    public function getEarnedTotal()
+    {
+        return $this->container['earned_total'];
+    }
+
+    /**
+     * Sets earned_total
+     *
+     * @param int|null $earned_total earned_total
+     *
+     * @return self
+     */
+    public function setEarnedTotal($earned_total)
+    {
+        if (is_null($earned_total)) {
+            throw new \InvalidArgumentException('non-nullable earned_total cannot be null');
+        }
+        $this->container['earned_total'] = $earned_total;
+
+        return $this;
+    }
+
+    /**
+     * Gets adjusted_total
+     *
+     * @return int|null
+     */
+    public function getAdjustedTotal()
+    {
+        return $this->container['adjusted_total'];
+    }
+
+    /**
+     * Sets adjusted_total
+     *
+     * @param int|null $adjusted_total adjusted_total
+     *
+     * @return self
+     */
+    public function setAdjustedTotal($adjusted_total)
+    {
+        if (is_null($adjusted_total)) {
+            throw new \InvalidArgumentException('non-nullable adjusted_total cannot be null');
+        }
+        $this->container['adjusted_total'] = $adjusted_total;
+
+        return $this;
+    }
+
+    /**
+     * Gets spent_today
+     *
+     * @return int|null
+     */
+    public function getSpentToday()
+    {
+        return $this->container['spent_today'];
+    }
+
+    /**
+     * Sets spent_today
+     *
+     * @param int|null $spent_today spent_today
+     *
+     * @return self
+     */
+    public function setSpentToday($spent_today)
+    {
+        if (is_null($spent_today)) {
+            throw new \InvalidArgumentException('non-nullable spent_today cannot be null');
+        }
+        $this->container['spent_today'] = $spent_today;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 443 - 0
api-test/client/lib/Model/PostApiV3AdminCreditAdjustments200Response.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * PostApiV3AdminCreditAdjustments200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * PostApiV3AdminCreditAdjustments200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class PostApiV3AdminCreditAdjustments200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'post_api_v3_admin_credit_adjustments_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseData',
+        'meta' => '\WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseMeta'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null,
+        'meta' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false,
+        'meta' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data',
+        'meta' => 'meta'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData',
+        'meta' => 'setMeta'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData',
+        'meta' => 'getMeta'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+        $this->setIfExists('meta', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseData|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseData|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+
+    /**
+     * Gets meta
+     *
+     * @return \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseMeta|null
+     */
+    public function getMeta()
+    {
+        return $this->container['meta'];
+    }
+
+    /**
+     * Sets meta
+     *
+     * @param \WikipaliApi\Model\PostApiV3AdminCreditAdjustments200ResponseMeta|null $meta meta
+     *
+     * @return self
+     */
+    public function setMeta($meta)
+    {
+        if (is_null($meta)) {
+            throw new \InvalidArgumentException('non-nullable meta cannot be null');
+        }
+        $this->container['meta'] = $meta;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 1057 - 0
api-test/client/lib/Model/PostApiV3AdminCreditAdjustments200ResponseData.php

@@ -0,0 +1,1057 @@
+<?php
+/**
+ * PostApiV3AdminCreditAdjustments200ResponseData
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * PostApiV3AdminCreditAdjustments200ResponseData Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class PostApiV3AdminCreditAdjustments200ResponseData implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'post_api_v3_admin_credit_adjustments_200_response_data';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'account_type' => 'string',
+        'account_id' => 'string',
+        'user' => '\WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser',
+        'delta' => 'int',
+        'kind' => 'string',
+        'bucket' => 'string',
+        'source' => 'string',
+        'ref' => 'string',
+        'day' => 'string',
+        'policy_version' => 'int',
+        'client_ip' => 'string',
+        'note' => 'string',
+        'operator' => '\WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser',
+        'created_at' => 'string',
+        'updated_at' => 'string'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'account_type' => null,
+        'account_id' => null,
+        'user' => null,
+        'delta' => null,
+        'kind' => null,
+        'bucket' => null,
+        'source' => null,
+        'ref' => null,
+        'day' => null,
+        'policy_version' => null,
+        'client_ip' => null,
+        'note' => null,
+        'operator' => null,
+        'created_at' => null,
+        'updated_at' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'account_type' => false,
+        'account_id' => false,
+        'user' => true,
+        'delta' => false,
+        'kind' => false,
+        'bucket' => false,
+        'source' => false,
+        'ref' => false,
+        'day' => false,
+        'policy_version' => false,
+        'client_ip' => true,
+        'note' => true,
+        'operator' => true,
+        'created_at' => false,
+        'updated_at' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'account_type' => 'account_type',
+        'account_id' => 'account_id',
+        'user' => 'user',
+        'delta' => 'delta',
+        'kind' => 'kind',
+        'bucket' => 'bucket',
+        'source' => 'source',
+        'ref' => 'ref',
+        'day' => 'day',
+        'policy_version' => 'policy_version',
+        'client_ip' => 'client_ip',
+        'note' => 'note',
+        'operator' => 'operator',
+        'created_at' => 'created_at',
+        'updated_at' => 'updated_at'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'account_type' => 'setAccountType',
+        'account_id' => 'setAccountId',
+        'user' => 'setUser',
+        'delta' => 'setDelta',
+        'kind' => 'setKind',
+        'bucket' => 'setBucket',
+        'source' => 'setSource',
+        'ref' => 'setRef',
+        'day' => 'setDay',
+        'policy_version' => 'setPolicyVersion',
+        'client_ip' => 'setClientIp',
+        'note' => 'setNote',
+        'operator' => 'setOperator',
+        'created_at' => 'setCreatedAt',
+        'updated_at' => 'setUpdatedAt'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'account_type' => 'getAccountType',
+        'account_id' => 'getAccountId',
+        'user' => 'getUser',
+        'delta' => 'getDelta',
+        'kind' => 'getKind',
+        'bucket' => 'getBucket',
+        'source' => 'getSource',
+        'ref' => 'getRef',
+        'day' => 'getDay',
+        'policy_version' => 'getPolicyVersion',
+        'client_ip' => 'getClientIp',
+        'note' => 'getNote',
+        'operator' => 'getOperator',
+        'created_at' => 'getCreatedAt',
+        'updated_at' => 'getUpdatedAt'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+    public const ACCOUNT_TYPE_USER = 'user';
+    public const ACCOUNT_TYPE_GUEST = 'guest';
+    public const KIND_EARN = 'earn';
+    public const KIND_SPEND = 'spend';
+    public const KIND_REFUND = 'refund';
+    public const KIND_ADJUST = 'adjust';
+    public const BUCKET_FREE = 'free';
+    public const BUCKET_EARNED = 'earned';
+    public const SOURCE_READING = 'reading';
+    public const SOURCE_EDITING = 'editing';
+    public const SOURCE_AGENT_RUN = 'agent_run';
+    public const SOURCE_ADMIN = 'admin';
+
+    /**
+     * Gets allowable values of the enum
+     *
+     * @return string[]
+     */
+    public function getAccountTypeAllowableValues()
+    {
+        return [
+            self::ACCOUNT_TYPE_USER,
+            self::ACCOUNT_TYPE_GUEST,
+        ];
+    }
+
+    /**
+     * Gets allowable values of the enum
+     *
+     * @return string[]
+     */
+    public function getKindAllowableValues()
+    {
+        return [
+            self::KIND_EARN,
+            self::KIND_SPEND,
+            self::KIND_REFUND,
+            self::KIND_ADJUST,
+        ];
+    }
+
+    /**
+     * Gets allowable values of the enum
+     *
+     * @return string[]
+     */
+    public function getBucketAllowableValues()
+    {
+        return [
+            self::BUCKET_FREE,
+            self::BUCKET_EARNED,
+        ];
+    }
+
+    /**
+     * Gets allowable values of the enum
+     *
+     * @return string[]
+     */
+    public function getSourceAllowableValues()
+    {
+        return [
+            self::SOURCE_READING,
+            self::SOURCE_EDITING,
+            self::SOURCE_AGENT_RUN,
+            self::SOURCE_ADMIN,
+        ];
+    }
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('account_type', $data ?? [], null);
+        $this->setIfExists('account_id', $data ?? [], null);
+        $this->setIfExists('user', $data ?? [], null);
+        $this->setIfExists('delta', $data ?? [], null);
+        $this->setIfExists('kind', $data ?? [], null);
+        $this->setIfExists('bucket', $data ?? [], null);
+        $this->setIfExists('source', $data ?? [], null);
+        $this->setIfExists('ref', $data ?? [], null);
+        $this->setIfExists('day', $data ?? [], null);
+        $this->setIfExists('policy_version', $data ?? [], null);
+        $this->setIfExists('client_ip', $data ?? [], null);
+        $this->setIfExists('note', $data ?? [], null);
+        $this->setIfExists('operator', $data ?? [], null);
+        $this->setIfExists('created_at', $data ?? [], null);
+        $this->setIfExists('updated_at', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        $allowedValues = $this->getAccountTypeAllowableValues();
+        if (!is_null($this->container['account_type']) && !in_array($this->container['account_type'], $allowedValues, true)) {
+            $invalidProperties[] = sprintf(
+                "invalid value '%s' for 'account_type', must be one of '%s'",
+                $this->container['account_type'],
+                implode("', '", $allowedValues)
+            );
+        }
+
+        $allowedValues = $this->getKindAllowableValues();
+        if (!is_null($this->container['kind']) && !in_array($this->container['kind'], $allowedValues, true)) {
+            $invalidProperties[] = sprintf(
+                "invalid value '%s' for 'kind', must be one of '%s'",
+                $this->container['kind'],
+                implode("', '", $allowedValues)
+            );
+        }
+
+        $allowedValues = $this->getBucketAllowableValues();
+        if (!is_null($this->container['bucket']) && !in_array($this->container['bucket'], $allowedValues, true)) {
+            $invalidProperties[] = sprintf(
+                "invalid value '%s' for 'bucket', must be one of '%s'",
+                $this->container['bucket'],
+                implode("', '", $allowedValues)
+            );
+        }
+
+        $allowedValues = $this->getSourceAllowableValues();
+        if (!is_null($this->container['source']) && !in_array($this->container['source'], $allowedValues, true)) {
+            $invalidProperties[] = sprintf(
+                "invalid value '%s' for 'source', must be one of '%s'",
+                $this->container['source'],
+                implode("', '", $allowedValues)
+            );
+        }
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets account_type
+     *
+     * @return string|null
+     */
+    public function getAccountType()
+    {
+        return $this->container['account_type'];
+    }
+
+    /**
+     * Sets account_type
+     *
+     * @param string|null $account_type account_type
+     *
+     * @return self
+     */
+    public function setAccountType($account_type)
+    {
+        if (is_null($account_type)) {
+            throw new \InvalidArgumentException('non-nullable account_type cannot be null');
+        }
+        $allowedValues = $this->getAccountTypeAllowableValues();
+        if (!in_array($account_type, $allowedValues, true)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    "Invalid value '%s' for 'account_type', must be one of '%s'",
+                    $account_type,
+                    implode("', '", $allowedValues)
+                )
+            );
+        }
+        $this->container['account_type'] = $account_type;
+
+        return $this;
+    }
+
+    /**
+     * Gets account_id
+     *
+     * @return string|null
+     */
+    public function getAccountId()
+    {
+        return $this->container['account_id'];
+    }
+
+    /**
+     * Sets account_id
+     *
+     * @param string|null $account_id account_id
+     *
+     * @return self
+     */
+    public function setAccountId($account_id)
+    {
+        if (is_null($account_id)) {
+            throw new \InvalidArgumentException('non-nullable account_id cannot be null');
+        }
+        $this->container['account_id'] = $account_id;
+
+        return $this;
+    }
+
+    /**
+     * Gets user
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null
+     */
+    public function getUser()
+    {
+        return $this->container['user'];
+    }
+
+    /**
+     * Sets user
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null $user user
+     *
+     * @return self
+     */
+    public function setUser($user)
+    {
+        if (is_null($user)) {
+            array_push($this->openAPINullablesSetToNull, 'user');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('user', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['user'] = $user;
+
+        return $this;
+    }
+
+    /**
+     * Gets delta
+     *
+     * @return int|null
+     */
+    public function getDelta()
+    {
+        return $this->container['delta'];
+    }
+
+    /**
+     * Sets delta
+     *
+     * @param int|null $delta delta
+     *
+     * @return self
+     */
+    public function setDelta($delta)
+    {
+        if (is_null($delta)) {
+            throw new \InvalidArgumentException('non-nullable delta cannot be null');
+        }
+        $this->container['delta'] = $delta;
+
+        return $this;
+    }
+
+    /**
+     * Gets kind
+     *
+     * @return string|null
+     */
+    public function getKind()
+    {
+        return $this->container['kind'];
+    }
+
+    /**
+     * Sets kind
+     *
+     * @param string|null $kind kind
+     *
+     * @return self
+     */
+    public function setKind($kind)
+    {
+        if (is_null($kind)) {
+            throw new \InvalidArgumentException('non-nullable kind cannot be null');
+        }
+        $allowedValues = $this->getKindAllowableValues();
+        if (!in_array($kind, $allowedValues, true)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    "Invalid value '%s' for 'kind', must be one of '%s'",
+                    $kind,
+                    implode("', '", $allowedValues)
+                )
+            );
+        }
+        $this->container['kind'] = $kind;
+
+        return $this;
+    }
+
+    /**
+     * Gets bucket
+     *
+     * @return string|null
+     */
+    public function getBucket()
+    {
+        return $this->container['bucket'];
+    }
+
+    /**
+     * Sets bucket
+     *
+     * @param string|null $bucket bucket
+     *
+     * @return self
+     */
+    public function setBucket($bucket)
+    {
+        if (is_null($bucket)) {
+            throw new \InvalidArgumentException('non-nullable bucket cannot be null');
+        }
+        $allowedValues = $this->getBucketAllowableValues();
+        if (!in_array($bucket, $allowedValues, true)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    "Invalid value '%s' for 'bucket', must be one of '%s'",
+                    $bucket,
+                    implode("', '", $allowedValues)
+                )
+            );
+        }
+        $this->container['bucket'] = $bucket;
+
+        return $this;
+    }
+
+    /**
+     * Gets source
+     *
+     * @return string|null
+     */
+    public function getSource()
+    {
+        return $this->container['source'];
+    }
+
+    /**
+     * Sets source
+     *
+     * @param string|null $source source
+     *
+     * @return self
+     */
+    public function setSource($source)
+    {
+        if (is_null($source)) {
+            throw new \InvalidArgumentException('non-nullable source cannot be null');
+        }
+        $allowedValues = $this->getSourceAllowableValues();
+        if (!in_array($source, $allowedValues, true)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    "Invalid value '%s' for 'source', must be one of '%s'",
+                    $source,
+                    implode("', '", $allowedValues)
+                )
+            );
+        }
+        $this->container['source'] = $source;
+
+        return $this;
+    }
+
+    /**
+     * Gets ref
+     *
+     * @return string|null
+     */
+    public function getRef()
+    {
+        return $this->container['ref'];
+    }
+
+    /**
+     * Sets ref
+     *
+     * @param string|null $ref ref
+     *
+     * @return self
+     */
+    public function setRef($ref)
+    {
+        if (is_null($ref)) {
+            throw new \InvalidArgumentException('non-nullable ref cannot be null');
+        }
+        $this->container['ref'] = $ref;
+
+        return $this;
+    }
+
+    /**
+     * Gets day
+     *
+     * @return string|null
+     */
+    public function getDay()
+    {
+        return $this->container['day'];
+    }
+
+    /**
+     * Sets day
+     *
+     * @param string|null $day day
+     *
+     * @return self
+     */
+    public function setDay($day)
+    {
+        if (is_null($day)) {
+            throw new \InvalidArgumentException('non-nullable day cannot be null');
+        }
+        $this->container['day'] = $day;
+
+        return $this;
+    }
+
+    /**
+     * Gets policy_version
+     *
+     * @return int|null
+     */
+    public function getPolicyVersion()
+    {
+        return $this->container['policy_version'];
+    }
+
+    /**
+     * Sets policy_version
+     *
+     * @param int|null $policy_version policy_version
+     *
+     * @return self
+     */
+    public function setPolicyVersion($policy_version)
+    {
+        if (is_null($policy_version)) {
+            throw new \InvalidArgumentException('non-nullable policy_version cannot be null');
+        }
+        $this->container['policy_version'] = $policy_version;
+
+        return $this;
+    }
+
+    /**
+     * Gets client_ip
+     *
+     * @return string|null
+     */
+    public function getClientIp()
+    {
+        return $this->container['client_ip'];
+    }
+
+    /**
+     * Sets client_ip
+     *
+     * @param string|null $client_ip client_ip
+     *
+     * @return self
+     */
+    public function setClientIp($client_ip)
+    {
+        if (is_null($client_ip)) {
+            array_push($this->openAPINullablesSetToNull, 'client_ip');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('client_ip', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['client_ip'] = $client_ip;
+
+        return $this;
+    }
+
+    /**
+     * Gets note
+     *
+     * @return string|null
+     */
+    public function getNote()
+    {
+        return $this->container['note'];
+    }
+
+    /**
+     * Sets note
+     *
+     * @param string|null $note note
+     *
+     * @return self
+     */
+    public function setNote($note)
+    {
+        if (is_null($note)) {
+            array_push($this->openAPINullablesSetToNull, 'note');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('note', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['note'] = $note;
+
+        return $this;
+    }
+
+    /**
+     * Gets operator
+     *
+     * @return \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null
+     */
+    public function getOperator()
+    {
+        return $this->container['operator'];
+    }
+
+    /**
+     * Sets operator
+     *
+     * @param \WikipaliApi\Model\GetApiV3AdminAgentRuns200ResponseDataInnerUser|null $operator operator
+     *
+     * @return self
+     */
+    public function setOperator($operator)
+    {
+        if (is_null($operator)) {
+            array_push($this->openAPINullablesSetToNull, 'operator');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('operator', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['operator'] = $operator;
+
+        return $this;
+    }
+
+    /**
+     * Gets created_at
+     *
+     * @return string|null
+     */
+    public function getCreatedAt()
+    {
+        return $this->container['created_at'];
+    }
+
+    /**
+     * Sets created_at
+     *
+     * @param string|null $created_at created_at
+     *
+     * @return self
+     */
+    public function setCreatedAt($created_at)
+    {
+        if (is_null($created_at)) {
+            throw new \InvalidArgumentException('non-nullable created_at cannot be null');
+        }
+        $this->container['created_at'] = $created_at;
+
+        return $this;
+    }
+
+    /**
+     * Gets updated_at
+     *
+     * @return string|null
+     */
+    public function getUpdatedAt()
+    {
+        return $this->container['updated_at'];
+    }
+
+    /**
+     * Sets updated_at
+     *
+     * @param string|null $updated_at updated_at
+     *
+     * @return self
+     */
+    public function setUpdatedAt($updated_at)
+    {
+        if (is_null($updated_at)) {
+            throw new \InvalidArgumentException('non-nullable updated_at cannot be null');
+        }
+        $this->container['updated_at'] = $updated_at;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 443 - 0
api-test/client/lib/Model/PostApiV3AdminCreditAdjustments200ResponseMeta.php

@@ -0,0 +1,443 @@
+<?php
+/**
+ * PostApiV3AdminCreditAdjustments200ResponseMeta
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * PostApiV3AdminCreditAdjustments200ResponseMeta Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class PostApiV3AdminCreditAdjustments200ResponseMeta implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'post_api_v3_admin_credit_adjustments_200_response_meta';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'created' => 'bool',
+        'earned_balance' => 'int'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'created' => null,
+        'earned_balance' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'created' => false,
+        'earned_balance' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'created' => 'created',
+        'earned_balance' => 'earned_balance'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'created' => 'setCreated',
+        'earned_balance' => 'setEarnedBalance'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'created' => 'getCreated',
+        'earned_balance' => 'getEarnedBalance'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('created', $data ?? [], null);
+        $this->setIfExists('earned_balance', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets created
+     *
+     * @return bool|null
+     */
+    public function getCreated()
+    {
+        return $this->container['created'];
+    }
+
+    /**
+     * Sets created
+     *
+     * @param bool|null $created 这次是否新入账
+     *
+     * @return self
+     */
+    public function setCreated($created)
+    {
+        if (is_null($created)) {
+            throw new \InvalidArgumentException('non-nullable created cannot be null');
+        }
+        $this->container['created'] = $created;
+
+        return $this;
+    }
+
+    /**
+     * Gets earned_balance
+     *
+     * @return int|null
+     */
+    public function getEarnedBalance()
+    {
+        return $this->container['earned_balance'];
+    }
+
+    /**
+     * Sets earned_balance
+     *
+     * @param int|null $earned_balance 该用户调整后的积分余额
+     *
+     * @return self
+     */
+    public function setEarnedBalance($earned_balance)
+    {
+        if (is_null($earned_balance)) {
+            throw new \InvalidArgumentException('non-nullable earned_balance cannot be null');
+        }
+        $this->container['earned_balance'] = $earned_balance;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 520 - 0
api-test/client/lib/Model/PostApiV3AdminCreditAdjustmentsRequest.php

@@ -0,0 +1,520 @@
+<?php
+/**
+ * PostApiV3AdminCreditAdjustmentsRequest
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * PostApiV3AdminCreditAdjustmentsRequest Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class PostApiV3AdminCreditAdjustmentsRequest implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'post_api_v3_admin_credit_adjustments_request';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'delta' => 'int',
+        'user' => 'string',
+        'note' => 'string',
+        'ref' => 'string'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'delta' => null,
+        'user' => null,
+        'note' => null,
+        'ref' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'delta' => false,
+        'user' => false,
+        'note' => false,
+        'ref' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'delta' => 'delta',
+        'user' => 'user',
+        'note' => 'note',
+        'ref' => 'ref'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'delta' => 'setDelta',
+        'user' => 'setUser',
+        'note' => 'setNote',
+        'ref' => 'setRef'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'delta' => 'getDelta',
+        'user' => 'getUser',
+        'note' => 'getNote',
+        'ref' => 'getRef'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('delta', $data ?? [], null);
+        $this->setIfExists('user', $data ?? [], null);
+        $this->setIfExists('note', $data ?? [], null);
+        $this->setIfExists('ref', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        if ($this->container['delta'] === null) {
+            $invalidProperties[] = "'delta' can't be null";
+        }
+        if ($this->container['user'] === null) {
+            $invalidProperties[] = "'user' can't be null";
+        }
+        if ($this->container['note'] === null) {
+            $invalidProperties[] = "'note' can't be null";
+        }
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets delta
+     *
+     * @return int
+     */
+    public function getDelta()
+    {
+        return $this->container['delta'];
+    }
+
+    /**
+     * Sets delta
+     *
+     * @param int $delta 加减多少积分,非零,绝对值最大 1000000
+     *
+     * @return self
+     */
+    public function setDelta($delta)
+    {
+        if (is_null($delta)) {
+            throw new \InvalidArgumentException('non-nullable delta cannot be null');
+        }
+        $this->container['delta'] = $delta;
+
+        return $this;
+    }
+
+    /**
+     * Gets user
+     *
+     * @return string
+     */
+    public function getUser()
+    {
+        return $this->container['user'];
+    }
+
+    /**
+     * Sets user
+     *
+     * @param string $user 用户 uuid、用户名或邮箱
+     *
+     * @return self
+     */
+    public function setUser($user)
+    {
+        if (is_null($user)) {
+            throw new \InvalidArgumentException('non-nullable user cannot be null');
+        }
+        $this->container['user'] = $user;
+
+        return $this;
+    }
+
+    /**
+     * Gets note
+     *
+     * @return string
+     */
+    public function getNote()
+    {
+        return $this->container['note'];
+    }
+
+    /**
+     * Sets note
+     *
+     * @param string $note 原因(记进流水备注)
+     *
+     * @return self
+     */
+    public function setNote($note)
+    {
+        if (is_null($note)) {
+            throw new \InvalidArgumentException('non-nullable note cannot be null');
+        }
+        $this->container['note'] = $note;
+
+        return $this;
+    }
+
+    /**
+     * Gets ref
+     *
+     * @return string|null
+     */
+    public function getRef()
+    {
+        return $this->container['ref'];
+    }
+
+    /**
+     * Sets ref
+     *
+     * @param string|null $ref 调整单号(uuid),防重复提交;不给由服务端生成
+     *
+     * @return self
+     */
+    public function setRef($ref)
+    {
+        if (is_null($ref)) {
+            throw new \InvalidArgumentException('non-nullable ref cannot be null');
+        }
+        $this->container['ref'] = $ref;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 409 - 0
api-test/client/lib/Model/PostApiV3AdminCreditSettlements200Response.php

@@ -0,0 +1,409 @@
+<?php
+/**
+ * PostApiV3AdminCreditSettlements200Response
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * PostApiV3AdminCreditSettlements200Response Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class PostApiV3AdminCreditSettlements200Response implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'post_api_v3_admin_credit_settlements_200_response';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'data' => '\WikipaliApi\Model\PostApiV3AdminCreditSettlements200ResponseData'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'data' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'data' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'data' => 'data'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'data' => 'setData'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'data' => 'getData'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('data', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets data
+     *
+     * @return \WikipaliApi\Model\PostApiV3AdminCreditSettlements200ResponseData|null
+     */
+    public function getData()
+    {
+        return $this->container['data'];
+    }
+
+    /**
+     * Sets data
+     *
+     * @param \WikipaliApi\Model\PostApiV3AdminCreditSettlements200ResponseData|null $data data
+     *
+     * @return self
+     */
+    public function setData($data)
+    {
+        if (is_null($data)) {
+            throw new \InvalidArgumentException('non-nullable data cannot be null');
+        }
+        $this->container['data'] = $data;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 763 - 0
api-test/client/lib/Model/PostApiV3AdminCreditSettlements200ResponseData.php

@@ -0,0 +1,763 @@
+<?php
+/**
+ * PostApiV3AdminCreditSettlements200ResponseData
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * PostApiV3AdminCreditSettlements200ResponseData Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class PostApiV3AdminCreditSettlements200ResponseData implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'post_api_v3_admin_credit_settlements_200_response_data';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'mode' => 'string',
+        'from' => 'string',
+        'to' => 'string',
+        'users' => 'int',
+        'pairs' => 'int',
+        'trigger' => 'string',
+        'operator' => 'string',
+        'ran_at' => 'string',
+        'seconds' => 'float'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'mode' => null,
+        'from' => null,
+        'to' => null,
+        'users' => null,
+        'pairs' => null,
+        'trigger' => null,
+        'operator' => null,
+        'ran_at' => null,
+        'seconds' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'mode' => false,
+        'from' => false,
+        'to' => false,
+        'users' => false,
+        'pairs' => true,
+        'trigger' => false,
+        'operator' => true,
+        'ran_at' => false,
+        'seconds' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'mode' => 'mode',
+        'from' => 'from',
+        'to' => 'to',
+        'users' => 'users',
+        'pairs' => 'pairs',
+        'trigger' => 'trigger',
+        'operator' => 'operator',
+        'ran_at' => 'ran_at',
+        'seconds' => 'seconds'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'mode' => 'setMode',
+        'from' => 'setFrom',
+        'to' => 'setTo',
+        'users' => 'setUsers',
+        'pairs' => 'setPairs',
+        'trigger' => 'setTrigger',
+        'operator' => 'setOperator',
+        'ran_at' => 'setRanAt',
+        'seconds' => 'setSeconds'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'mode' => 'getMode',
+        'from' => 'getFrom',
+        'to' => 'getTo',
+        'users' => 'getUsers',
+        'pairs' => 'getPairs',
+        'trigger' => 'getTrigger',
+        'operator' => 'getOperator',
+        'ran_at' => 'getRanAt',
+        'seconds' => 'getSeconds'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+    public const MODE_DAY = 'day';
+    public const MODE_MISSING = 'missing';
+    public const TRIGGER_CLI = 'cli';
+    public const TRIGGER_ADMIN = 'admin';
+
+    /**
+     * Gets allowable values of the enum
+     *
+     * @return string[]
+     */
+    public function getModeAllowableValues()
+    {
+        return [
+            self::MODE_DAY,
+            self::MODE_MISSING,
+        ];
+    }
+
+    /**
+     * Gets allowable values of the enum
+     *
+     * @return string[]
+     */
+    public function getTriggerAllowableValues()
+    {
+        return [
+            self::TRIGGER_CLI,
+            self::TRIGGER_ADMIN,
+        ];
+    }
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('mode', $data ?? [], null);
+        $this->setIfExists('from', $data ?? [], null);
+        $this->setIfExists('to', $data ?? [], null);
+        $this->setIfExists('users', $data ?? [], null);
+        $this->setIfExists('pairs', $data ?? [], null);
+        $this->setIfExists('trigger', $data ?? [], null);
+        $this->setIfExists('operator', $data ?? [], null);
+        $this->setIfExists('ran_at', $data ?? [], null);
+        $this->setIfExists('seconds', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        $allowedValues = $this->getModeAllowableValues();
+        if (!is_null($this->container['mode']) && !in_array($this->container['mode'], $allowedValues, true)) {
+            $invalidProperties[] = sprintf(
+                "invalid value '%s' for 'mode', must be one of '%s'",
+                $this->container['mode'],
+                implode("', '", $allowedValues)
+            );
+        }
+
+        $allowedValues = $this->getTriggerAllowableValues();
+        if (!is_null($this->container['trigger']) && !in_array($this->container['trigger'], $allowedValues, true)) {
+            $invalidProperties[] = sprintf(
+                "invalid value '%s' for 'trigger', must be one of '%s'",
+                $this->container['trigger'],
+                implode("', '", $allowedValues)
+            );
+        }
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets mode
+     *
+     * @return string|null
+     */
+    public function getMode()
+    {
+        return $this->container['mode'];
+    }
+
+    /**
+     * Sets mode
+     *
+     * @param string|null $mode mode
+     *
+     * @return self
+     */
+    public function setMode($mode)
+    {
+        if (is_null($mode)) {
+            throw new \InvalidArgumentException('non-nullable mode cannot be null');
+        }
+        $allowedValues = $this->getModeAllowableValues();
+        if (!in_array($mode, $allowedValues, true)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    "Invalid value '%s' for 'mode', must be one of '%s'",
+                    $mode,
+                    implode("', '", $allowedValues)
+                )
+            );
+        }
+        $this->container['mode'] = $mode;
+
+        return $this;
+    }
+
+    /**
+     * Gets from
+     *
+     * @return string|null
+     */
+    public function getFrom()
+    {
+        return $this->container['from'];
+    }
+
+    /**
+     * Sets from
+     *
+     * @param string|null $from from
+     *
+     * @return self
+     */
+    public function setFrom($from)
+    {
+        if (is_null($from)) {
+            throw new \InvalidArgumentException('non-nullable from cannot be null');
+        }
+        $this->container['from'] = $from;
+
+        return $this;
+    }
+
+    /**
+     * Gets to
+     *
+     * @return string|null
+     */
+    public function getTo()
+    {
+        return $this->container['to'];
+    }
+
+    /**
+     * Sets to
+     *
+     * @param string|null $to to
+     *
+     * @return self
+     */
+    public function setTo($to)
+    {
+        if (is_null($to)) {
+            throw new \InvalidArgumentException('non-nullable to cannot be null');
+        }
+        $this->container['to'] = $to;
+
+        return $this;
+    }
+
+    /**
+     * Gets users
+     *
+     * @return int|null
+     */
+    public function getUsers()
+    {
+        return $this->container['users'];
+    }
+
+    /**
+     * Sets users
+     *
+     * @param int|null $users users
+     *
+     * @return self
+     */
+    public function setUsers($users)
+    {
+        if (is_null($users)) {
+            throw new \InvalidArgumentException('non-nullable users cannot be null');
+        }
+        $this->container['users'] = $users;
+
+        return $this;
+    }
+
+    /**
+     * Gets pairs
+     *
+     * @return int|null
+     */
+    public function getPairs()
+    {
+        return $this->container['pairs'];
+    }
+
+    /**
+     * Sets pairs
+     *
+     * @param int|null $pairs pairs
+     *
+     * @return self
+     */
+    public function setPairs($pairs)
+    {
+        if (is_null($pairs)) {
+            array_push($this->openAPINullablesSetToNull, 'pairs');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('pairs', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['pairs'] = $pairs;
+
+        return $this;
+    }
+
+    /**
+     * Gets trigger
+     *
+     * @return string|null
+     */
+    public function getTrigger()
+    {
+        return $this->container['trigger'];
+    }
+
+    /**
+     * Sets trigger
+     *
+     * @param string|null $trigger trigger
+     *
+     * @return self
+     */
+    public function setTrigger($trigger)
+    {
+        if (is_null($trigger)) {
+            throw new \InvalidArgumentException('non-nullable trigger cannot be null');
+        }
+        $allowedValues = $this->getTriggerAllowableValues();
+        if (!in_array($trigger, $allowedValues, true)) {
+            throw new \InvalidArgumentException(
+                sprintf(
+                    "Invalid value '%s' for 'trigger', must be one of '%s'",
+                    $trigger,
+                    implode("', '", $allowedValues)
+                )
+            );
+        }
+        $this->container['trigger'] = $trigger;
+
+        return $this;
+    }
+
+    /**
+     * Gets operator
+     *
+     * @return string|null
+     */
+    public function getOperator()
+    {
+        return $this->container['operator'];
+    }
+
+    /**
+     * Sets operator
+     *
+     * @param string|null $operator operator
+     *
+     * @return self
+     */
+    public function setOperator($operator)
+    {
+        if (is_null($operator)) {
+            array_push($this->openAPINullablesSetToNull, 'operator');
+        } else {
+            $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+            $index = array_search('operator', $nullablesSetToNull);
+            if ($index !== FALSE) {
+                unset($nullablesSetToNull[$index]);
+                $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+            }
+        }
+        $this->container['operator'] = $operator;
+
+        return $this;
+    }
+
+    /**
+     * Gets ran_at
+     *
+     * @return string|null
+     */
+    public function getRanAt()
+    {
+        return $this->container['ran_at'];
+    }
+
+    /**
+     * Sets ran_at
+     *
+     * @param string|null $ran_at ran_at
+     *
+     * @return self
+     */
+    public function setRanAt($ran_at)
+    {
+        if (is_null($ran_at)) {
+            throw new \InvalidArgumentException('non-nullable ran_at cannot be null');
+        }
+        $this->container['ran_at'] = $ran_at;
+
+        return $this;
+    }
+
+    /**
+     * Gets seconds
+     *
+     * @return float|null
+     */
+    public function getSeconds()
+    {
+        return $this->container['seconds'];
+    }
+
+    /**
+     * Sets seconds
+     *
+     * @param float|null $seconds seconds
+     *
+     * @return self
+     */
+    public function setSeconds($seconds)
+    {
+        if (is_null($seconds)) {
+            throw new \InvalidArgumentException('non-nullable seconds cannot be null');
+        }
+        $this->container['seconds'] = $seconds;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 409 - 0
api-test/client/lib/Model/PostApiV3AdminCreditSettlementsRequest.php

@@ -0,0 +1,409 @@
+<?php
+/**
+ * PostApiV3AdminCreditSettlementsRequest
+ *
+ * PHP version 8.1
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ */
+
+/**
+ * MINT API
+ *
+ * International Academy Of Pali Tipitaka(国际巴利三藏学院)  由 `php openapi/scripts/generate.php` 依据 api-v13 的路由与控制器源码生成。 响应统一封装为 `{ok, message, data}`;`ok=false` 时 `message` 为错误信息。
+ *
+ * The version of the OpenAPI document: 1.0.0
+ * Generated by: https://openapi-generator.tech
+ * Generator version: 7.25.0
+ */
+
+/**
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+namespace WikipaliApi\Model;
+
+use \ArrayAccess;
+use \WikipaliApi\ObjectSerializer;
+
+/**
+ * PostApiV3AdminCreditSettlementsRequest Class Doc Comment
+ *
+ * @category Class
+ * @package  WikipaliApi
+ * @author   OpenAPI Generator team
+ * @link     https://openapi-generator.tech
+ * @implements \ArrayAccess<string, mixed>
+ */
+class PostApiV3AdminCreditSettlementsRequest implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+    public const DISCRIMINATOR = null;
+
+    /**
+     * The original name of the model.
+     *
+     * @var string
+     */
+    protected static $openAPIModelName = 'post_api_v3_admin_credit_settlements_request';
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @var string[]
+     */
+    protected static $openAPITypes = [
+        'date' => 'string'
+    ];
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @var string[]
+     * @phpstan-var array<string, string|null>
+     * @psalm-var array<string, string|null>
+     */
+    protected static $openAPIFormats = [
+        'date' => null
+    ];
+
+    /**
+     * Array of nullable properties. Used for (de)serialization
+     *
+     * @var boolean[]
+     */
+    protected static array $openAPINullables = [
+        'date' => false
+    ];
+
+    /**
+     * If a nullable field gets set to null, insert it here
+     *
+     * @var boolean[]
+     */
+    protected array $openAPINullablesSetToNull = [];
+
+    /**
+     * Array of property to type mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPITypes()
+    {
+        return self::$openAPITypes;
+    }
+
+    /**
+     * Array of property to format mappings. Used for (de)serialization
+     *
+     * @return array
+     */
+    public static function openAPIFormats()
+    {
+        return self::$openAPIFormats;
+    }
+
+    /**
+     * Array of nullable properties
+     *
+     * @return array
+     */
+    protected static function openAPINullables(): array
+    {
+        return self::$openAPINullables;
+    }
+
+    /**
+     * Array of nullable field names deliberately set to null
+     *
+     * @return boolean[]
+     */
+    private function getOpenAPINullablesSetToNull(): array
+    {
+        return $this->openAPINullablesSetToNull;
+    }
+
+    /**
+     * Setter - Array of nullable field names deliberately set to null
+     *
+     * @param boolean[] $openAPINullablesSetToNull
+     */
+    private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+    {
+        $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+    }
+
+    /**
+     * Checks if a property is nullable
+     *
+     * @param string $property
+     * @return bool
+     */
+    public static function isNullable(string $property): bool
+    {
+        return self::openAPINullables()[$property] ?? false;
+    }
+
+    /**
+     * Checks if a nullable property is set to null.
+     *
+     * @param string $property
+     * @return bool
+     */
+    public function isNullableSetToNull(string $property): bool
+    {
+        return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+    }
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @var string[]
+     */
+    protected static $attributeMap = [
+        'date' => 'date'
+    ];
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @var string[]
+     */
+    protected static $setters = [
+        'date' => 'setDate'
+    ];
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @var string[]
+     */
+    protected static $getters = [
+        'date' => 'getDate'
+    ];
+
+    /**
+     * Array of attributes where the key is the local name,
+     * and the value is the original name
+     *
+     * @return array
+     */
+    public static function attributeMap()
+    {
+        return self::$attributeMap;
+    }
+
+    /**
+     * Array of attributes to setter functions (for deserialization of responses)
+     *
+     * @return array
+     */
+    public static function setters()
+    {
+        return self::$setters;
+    }
+
+    /**
+     * Array of attributes to getter functions (for serialization of requests)
+     *
+     * @return array
+     */
+    public static function getters()
+    {
+        return self::$getters;
+    }
+
+    /**
+     * The original name of the model.
+     *
+     * @return string
+     */
+    public function getModelName()
+    {
+        return self::$openAPIModelName;
+    }
+
+
+    /**
+     * Associative array for storing property values
+     *
+     * @var mixed[]
+     */
+    protected $container = [];
+
+    /**
+     * Constructor
+     *
+     * @param mixed[]|null $data Associated array of property values
+     *                      initializing the model
+     */
+    public function __construct(?array $data = null)
+    {
+        $this->setIfExists('date', $data ?? [], null);
+    }
+
+    /**
+     * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+     * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+     * $this->openAPINullablesSetToNull array
+     *
+     * @param string $variableName
+     * @param array  $fields
+     * @param mixed  $defaultValue
+     */
+    private function setIfExists(string $variableName, array $fields, $defaultValue): void
+    {
+        if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+            $this->openAPINullablesSetToNull[] = $variableName;
+        }
+
+        $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+    }
+
+    /**
+     * Show all the invalid properties with reasons.
+     *
+     * @return array invalid properties with reasons
+     */
+    public function listInvalidProperties()
+    {
+        $invalidProperties = [];
+
+        return $invalidProperties;
+    }
+
+    /**
+     * Validate all the properties in the model
+     * return true if all passed
+     *
+     * @return bool True if all properties are valid
+     */
+    public function valid()
+    {
+        return count($this->listInvalidProperties()) === 0;
+    }
+
+
+    /**
+     * Gets date
+     *
+     * @return string|null
+     */
+    public function getDate()
+    {
+        return $this->container['date'];
+    }
+
+    /**
+     * Sets date
+     *
+     * @param string|null $date 只重算这一天(UTC,Y-m-d),不早于积分上线日、不晚于今天
+     *
+     * @return self
+     */
+    public function setDate($date)
+    {
+        if (is_null($date)) {
+            throw new \InvalidArgumentException('non-nullable date cannot be null');
+        }
+        $this->container['date'] = $date;
+
+        return $this;
+    }
+    /**
+     * Returns true if offset exists. False otherwise.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return boolean
+     */
+    public function offsetExists(mixed $offset): bool
+    {
+        return isset($this->container[$offset]);
+    }
+
+    /**
+     * Gets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return mixed|null
+     */
+    #[\ReturnTypeWillChange]
+    public function offsetGet(mixed $offset)
+    {
+        return $this->container[$offset] ?? null;
+    }
+
+    /**
+     * Sets value based on offset.
+     *
+     * @param int|null $offset Offset
+     * @param mixed    $value  Value to be set
+     *
+     * @return void
+     */
+    public function offsetSet($offset, $value): void
+    {
+        if (is_null($offset)) {
+            $this->container[] = $value;
+        } else {
+            $this->container[$offset] = $value;
+        }
+    }
+
+    /**
+     * Unsets offset.
+     *
+     * @param integer|string $offset Offset
+     *
+     * @return void
+     */
+    public function offsetUnset(mixed $offset): void
+    {
+        unset($this->container[$offset]);
+    }
+
+    /**
+     * Serializes the object to a value that can be serialized natively by json_encode().
+     * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+     *
+     * @return mixed Returns data which can be serialized by json_encode(), which is a value
+     * of any type other than a resource.
+     */
+    #[\ReturnTypeWillChange]
+    public function jsonSerialize()
+    {
+       return ObjectSerializer::sanitizeForSerialization($this);
+    }
+
+    /**
+     * Gets the string presentation of the object
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return json_encode(
+            ObjectSerializer::sanitizeForSerialization($this),
+            JSON_PRETTY_PRINT
+        );
+    }
+
+    /**
+     * Gets a header-safe presentation of the object
+     *
+     * @return string
+     */
+    public function toHeaderValue()
+    {
+        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+    }
+}
+
+

+ 8 - 13
api-v13/app/Console/Commands/SettleCreditActivity.php

@@ -2,7 +2,7 @@
 
 namespace App\Console\Commands;
 
-use App\Services\V3\CreditService;
+use App\Services\V3\CreditAdminService;
 use Illuminate\Console\Attributes\Description;
 use Illuminate\Console\Attributes\Signature;
 use Illuminate\Console\Command;
@@ -20,20 +20,15 @@ use Illuminate\Console\Command;
 #[Description('把读经、编辑时长结算成 AI 对话积分(默认补齐上线以来所有漏结算的日子)')]
 class SettleCreditActivity extends Command
 {
-    public function handle(CreditService $credits): int
+    public function handle(CreditAdminService $credits): int
     {
-        if ($this->option('date')) {
-            $day = now('UTC')->parse((string) $this->option('date'))->startOfDay();
-            $users = $credits->settleDay($day);
-            $this->info("{$day->toDateString()}:结算了 {$users} 位用户。");
+        // 与管理后台「手工结算」同一入口,最近一次运行记录也一起写(后台概览显示)
+        $day = $this->option('date') ? now('UTC')->parse((string) $this->option('date')) : null;
+        $result = $credits->settle($day);
 
-            return self::SUCCESS;
-        }
-
-        $since = now('UTC')->parse((string) config('mint.credits.earn_since'))->startOfDay();
-        $until = now('UTC')->subDay()->startOfDay();
-        ['pairs' => $pairs, 'users' => $users] = $credits->settleMissing($since, $until);
-        $this->info("{$since->toDateString()} ~ {$until->toDateString()}:补结算了 {$users} 位用户的 {$pairs} 个「用户 + 日」。");
+        $this->info($result['mode'] === 'day'
+            ? "{$result['from']}:结算了 {$result['users']} 位用户。"
+            : "{$result['from']} ~ {$result['to']}:补结算了 {$result['users']} 位用户的 {$result['pairs']} 个「用户 + 日」。");
 
         return self::SUCCESS;
     }

+ 35 - 0
api-v13/app/Http/Controllers/V3/AdminCreditAccountController.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\IndexAdminCreditAccountRequest;
+use App\Http\Resources\V3\AdminCreditAccountResource;
+use App\Services\V3\CreditAdminService;
+
+/**
+ * 管理后台:AI 对话积分账号一览(仅 root / administrator)。新资源,没有 v2 前身。
+ */
+class AdminCreditAccountController extends Controller
+{
+    public function __construct(private readonly CreditAdminService $credits) {}
+
+    /**
+     * 列出积分账号
+     *
+     * 有积分流水的账号(登录用户与游客设备),每行是该账号的汇总:积分余额、累计赚取、累计手工调整、
+     * 累计消耗、今天用掉的赠送额度。最近有动静的在前。没有任何流水的用户不在列表里,
+     * 但仍可以直接给他加积分(`POST /v3/admin/credit-adjustments`)。
+     *
+     * @queryParam filter[account_type] string 账号类型。Enum: user,guest
+     * @queryParam filter[q] string 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配
+     * @queryParam page integer 页码。Default: 1
+     * @queryParam per_page integer 每页数量,最大 100。Default: 20
+     */
+    public function index(IndexAdminCreditAccountRequest $request)
+    {
+        return AdminCreditAccountResource::collection(
+            $this->credits->accounts($request->validated(), $request->integer('per_page', 20))
+        );
+    }
+}

+ 52 - 0
api-v13/app/Http/Controllers/V3/AdminCreditAdjustmentController.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Concerns\ResolvesCurrentUser;
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\StoreAdminCreditAdjustmentRequest;
+use App\Http\Resources\V3\AdminCreditLedgerResource;
+use App\Services\V3\CreditAdminService;
+
+/**
+ * 管理后台:手工加减 AI 对话积分(仅 root / administrator)。新资源,没有 v2 前身。
+ * 与 `artisan credits:adjust` 同一套记账,后台这边另记操作人。
+ */
+class AdminCreditAdjustmentController extends Controller
+{
+    use ResolvesCurrentUser;
+
+    public function __construct(private readonly CreditAdminService $credits) {}
+
+    /**
+     * 手工加减积分
+     *
+     * 加到登录用户的积分余额(不过期)。负数为扣减,扣减后余额不能为负。
+     * 同一 `ref` 只入账一次:重复提交返回原来那条(200),新入账是 201。
+     *
+     * @bodyParam user string required 用户 uuid、用户名或邮箱
+     * @bodyParam delta integer required 加减多少积分,非零,绝对值最大 1000000
+     * @bodyParam note string required 原因(记进流水备注)
+     * @bodyParam ref string 调整单号(uuid),防重复提交;不给由服务端生成
+     *
+     * @responseStatus 201 新入账。响应体与 200 同形(200 是同一 ref 已经入账过,返回原来那条)
+     *
+     * @meta created boolean 这次是否新入账
+     * @meta earned_balance integer 该用户调整后的积分余额
+     */
+    public function store(StoreAdminCreditAdjustmentRequest $request)
+    {
+        $result = $this->credits->adjust(
+            $this->currentUser($request)['user_uid'],
+            $request->validated('user'),
+            $request->integer('delta'),
+            $request->validated('note'),
+            $request->validated('ref'),
+        );
+
+        return AdminCreditLedgerResource::make($result['entry'])->additional(['meta' => [
+            'created' => $result['created'],
+            'earned_balance' => $result['earned_balance'],
+        ]]);
+    }
+}

+ 38 - 0
api-v13/app/Http/Controllers/V3/AdminCreditLedgerController.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\IndexAdminCreditLedgerRequest;
+use App\Http\Resources\V3\AdminCreditLedgerResource;
+use App\Services\V3\CreditAdminService;
+
+/**
+ * 管理后台:AI 对话积分流水(仅 root / administrator)。新资源,没有 v2 前身。底层表 `credit_ledger`。
+ */
+class AdminCreditLedgerController extends Controller
+{
+    public function __construct(private readonly CreditAdminService $credits) {}
+
+    /**
+     * 列出积分流水
+     *
+     * 最新的在前。包括结算赚取(earn)、提问扣减(spend)、出错退回(refund)与手工调整(adjust)。
+     *
+     * @queryParam filter[account_type] string 账号类型;给 account_id 时必填。Enum: user,guest
+     * @queryParam filter[account_id] string 账号 id(用户 uuid 或游客设备 id)
+     * @queryParam filter[kind] string 流水类型。Enum: earn,spend,refund,adjust
+     * @queryParam filter[bucket] string 池子:free 每日赠送 / earned 积分余额。Enum: free,earned
+     * @queryParam filter[source] string 来源。Enum: reading,editing,agent_run,admin
+     * @queryParam filter[from] string 起始日(UTC,Y-m-d,按流水归属日)
+     * @queryParam filter[to] string 结束日(UTC,Y-m-d,含当天)
+     * @queryParam page integer 页码。Default: 1
+     * @queryParam per_page integer 每页数量,最大 100。Default: 20
+     */
+    public function index(IndexAdminCreditLedgerRequest $request)
+    {
+        return AdminCreditLedgerResource::collection(
+            $this->credits->ledger($request->validated(), $request->integer('per_page', 20))
+        );
+    }
+}

+ 26 - 0
api-v13/app/Http/Controllers/V3/AdminCreditOverviewController.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Controller;
+use App\Http\Resources\V3\AdminCreditOverviewResource;
+use App\Services\V3\CreditAdminService;
+
+/**
+ * 管理后台 AI 对话积分概览(单例资源,仅 root / administrator)。新资源,没有 v2 前身。
+ */
+class AdminCreditOverviewController extends Controller
+{
+    public function __construct(private readonly CreditAdminService $credits) {}
+
+    /**
+     * 积分概览
+     *
+     * 当前策略、全站合计(登录用户的积分余额总和、累计赚取、累计手工调整、今天的消耗)、
+     * 最近 14 天每天结算出的积分,以及最近一次结算任务(每日任务或后台手工触发)的结果。
+     */
+    public function __invoke()
+    {
+        return AdminCreditOverviewResource::make($this->credits->overview());
+    }
+}

+ 42 - 0
api-v13/app/Http/Controllers/V3/AdminCreditSettlementController.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Http\Controllers\V3;
+
+use App\Http\Controllers\Concerns\ResolvesCurrentUser;
+use App\Http\Controllers\Controller;
+use App\Http\Requests\V3\StoreAdminCreditSettlementRequest;
+use App\Http\Resources\V3\AdminCreditSettlementResource;
+use App\Services\V3\CreditAdminService;
+
+/**
+ * 管理后台:手工跑一次积分结算(仅 root / administrator)。新资源,没有 v2 前身。
+ *
+ * 每日任务 `artisan credits:settle-activity` 出问题时用。两者同一套逻辑(CreditAdminService::settle)。
+ */
+class AdminCreditSettlementController extends Controller
+{
+    use ResolvesCurrentUser;
+
+    public function __construct(private readonly CreditAdminService $credits) {}
+
+    /**
+     * 手工结算积分
+     *
+     * 把登录用户的读经、编辑时长结算成积分。可重复执行:同一用户同一天的积分是覆盖不是累加,不会重复入账。
+     * 不给 `date`:从积分上线日到昨天,补齐所有漏结算的「用户 + 日」(与每日任务相同);
+     * 给 `date`:按当前策略重算那一天的所有用户。同步执行。
+     *
+     * @responseStatus 201 结算完成。响应体与 200 同形
+     *
+     * @bodyParam date string 只重算这一天(UTC,Y-m-d),不早于积分上线日、不晚于今天
+     */
+    public function store(StoreAdminCreditSettlementRequest $request)
+    {
+        $date = $request->validated('date');
+
+        return AdminCreditSettlementResource::make($this->credits->settle(
+            $date === null ? null : now('UTC')->parse($date),
+            $this->currentUser($request)['user_uid'],
+        ))->response()->setStatusCode(201);
+    }
+}

+ 29 - 0
api-v13/app/Http/Requests/V3/IndexAdminCreditAccountRequest.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+/**
+ * `GET /v3/admin/credit-accounts` 的入参:有积分流水的账号一览。
+ */
+class IndexAdminCreditAccountRequest extends FormRequest
+{
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return [
+            'filter.account_type' => ['sometimes', 'in:user,guest'],
+            'filter.q' => ['sometimes', 'string', 'max:100'],
+            'page' => ['integer', 'min:1'],
+            'per_page' => ['integer', 'min:1', 'max:100'],
+        ];
+    }
+}

+ 37 - 0
api-v13/app/Http/Requests/V3/IndexAdminCreditLedgerRequest.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use App\Models\CreditLedgerEntry;
+use Illuminate\Foundation\Http\FormRequest;
+use Illuminate\Validation\Rule;
+
+/**
+ * `GET /v3/admin/credit-ledger` 的入参:积分流水。按账号查时 account_type 与 account_id 必须一起给
+ * (设备 id 由客户端填,可能与某个用户 uid 相同,只按 id 查会把两种账号混在一起)。
+ */
+class IndexAdminCreditLedgerRequest extends FormRequest
+{
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return [
+            'filter.account_type' => ['required_with:filter.account_id', 'in:user,guest'],
+            'filter.account_id' => ['sometimes', 'uuid'],
+            'filter.kind' => ['sometimes', Rule::in(CreditLedgerEntry::KINDS)],
+            'filter.bucket' => ['sometimes', Rule::in(CreditLedgerEntry::BUCKETS)],
+            'filter.source' => ['sometimes', 'in:reading,editing,agent_run,admin'],
+            'filter.from' => ['sometimes', 'date_format:Y-m-d'],
+            'filter.to' => ['sometimes', 'date_format:Y-m-d', 'after_or_equal:filter.from'],
+            'page' => ['integer', 'min:1'],
+            'per_page' => ['integer', 'min:1', 'max:100'],
+        ];
+    }
+}

+ 31 - 0
api-v13/app/Http/Requests/V3/StoreAdminCreditAdjustmentRequest.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+/**
+ * `POST /v3/admin/credit-adjustments` 的入参:管理员给登录用户加减积分。
+ */
+class StoreAdminCreditAdjustmentRequest extends FormRequest
+{
+    public const MAX_DELTA = 1_000_000;
+
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return [
+            'user' => ['required', 'string', 'max:255'],
+            'delta' => ['required', 'integer', 'not_in:0', 'between:-'.self::MAX_DELTA.','.self::MAX_DELTA],
+            'note' => ['required', 'string', 'max:255'],
+            'ref' => ['sometimes', 'uuid'],
+        ];
+    }
+}

+ 30 - 0
api-v13/app/Http/Requests/V3/StoreAdminCreditSettlementRequest.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Requests\V3;
+
+use Illuminate\Foundation\Http\FormRequest;
+
+/**
+ * `POST /v3/admin/credit-settlements` 的入参:手工跑一次积分结算。
+ */
+class StoreAdminCreditSettlementRequest extends FormRequest
+{
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * @return array<string, array<int, mixed>>
+     */
+    public function rules(): array
+    {
+        return [
+            'date' => [
+                'sometimes', 'date_format:Y-m-d',
+                'after_or_equal:'.config('mint.credits.earn_since'),
+                'before_or_equal:'.now('UTC')->toDateString(),
+            ],
+        ];
+    }
+}

+ 49 - 0
api-v13/app/Http/Resources/V3/AdminCreditAccountResource.php

@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use App\Http\Resources\Concerns\ResolvesActor;
+use App\Models\CreditLedgerEntry;
+use Illuminate\Http\Request;
+
+/**
+ * 一个账号的积分汇总(按账号聚合的流水,不是单条流水)。**本类不查库**:user 由 Service 预加载。
+ *
+ * @mixin CreditLedgerEntry
+ */
+class AdminCreditAccountResource extends BaseResource
+{
+    use ResolvesActor;
+
+    /**
+     * @param  Request  $request
+     * @return array{
+     *     account_type: 'user'|'guest',
+     *     account_id: string,
+     *     user: array{id: string, nickName: string, userName: string, realName: string, sn: int, avatar: string|null, roles: array|null}|null,
+     *     earned_balance: int,
+     *     earned_total: int,
+     *     adjusted_total: int,
+     *     spent_total: int,
+     *     free_used_today: int,
+     *     daily_free: int,
+     *     last_activity_at: string|null
+     * }
+     */
+    public function toArray($request): array
+    {
+        return [
+            'account_type' => $this->account_type,
+            'account_id' => $this->account_id,
+            // 游客的 account_id 是设备 id,不能拿去当用户 uid
+            'user' => $this->account_type === 'user' && $this->user ? $this->actor($this->user) : null,
+            'earned_balance' => (int) $this->earned_balance,
+            'earned_total' => (int) $this->earned_total,
+            'adjusted_total' => (int) $this->adjusted_total,
+            'spent_total' => (int) $this->spent_total,
+            'free_used_today' => (int) $this->free_used_today,
+            'daily_free' => (int) (config('mint.credits.policy.daily_free')[$this->account_type] ?? 0),
+            'last_activity_at' => $this->last_activity_at ? now('UTC')->parse($this->last_activity_at)->toIso8601ZuluString() : null,
+        ];
+    }
+}

+ 62 - 0
api-v13/app/Http/Resources/V3/AdminCreditLedgerResource.php

@@ -0,0 +1,62 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use App\Http\Resources\Concerns\ResolvesActor;
+use App\Models\CreditLedgerEntry;
+use Illuminate\Http\Request;
+
+/**
+ * 积分流水的一条(管理员视角)。不给自增 id:流水由 (账号, source, ref, kind, bucket) 唯一确定。
+ * **本类不查库**:user、operator 由 Service 预加载。
+ *
+ * ref 的含义随 source 变:agent_run 是提问的 run_id(可在 AI 对话统计里打开研究过程),
+ * reading / editing 是结算的日期,admin 是调整单号。
+ *
+ * @mixin CreditLedgerEntry
+ */
+class AdminCreditLedgerResource extends BaseResource
+{
+    use ResolvesActor;
+
+    /**
+     * @param  Request  $request
+     * @return array{
+     *     account_type: 'user'|'guest',
+     *     account_id: string,
+     *     user: array{id: string, nickName: string, userName: string, realName: string, sn: int, avatar: string|null, roles: array|null}|null,
+     *     delta: int,
+     *     kind: 'earn'|'spend'|'refund'|'adjust',
+     *     bucket: 'free'|'earned',
+     *     source: 'reading'|'editing'|'agent_run'|'admin',
+     *     ref: string,
+     *     day: string,
+     *     policy_version: int,
+     *     client_ip: string|null,
+     *     note: string|null,
+     *     operator: array{id: string, nickName: string, userName: string, realName: string, sn: int, avatar: string|null, roles: array|null}|null,
+     *     created_at: string,
+     *     updated_at: string
+     * }
+     */
+    public function toArray($request): array
+    {
+        return [
+            'account_type' => $this->account_type,
+            'account_id' => $this->account_id,
+            'user' => $this->account_type === 'user' && $this->user ? $this->actor($this->user) : null,
+            'delta' => $this->delta,
+            'kind' => $this->kind,
+            'bucket' => $this->bucket,
+            'source' => $this->source,
+            'ref' => $this->ref,
+            'day' => $this->day->toDateString(),
+            'policy_version' => (int) $this->policy_version,
+            'client_ip' => $this->client_ip,
+            'note' => $this->note,
+            'operator' => $this->operator ? $this->actor($this->operator) : null,
+            'created_at' => $this->created_at->toIso8601ZuluString(),
+            'updated_at' => $this->updated_at->toIso8601ZuluString(),
+        ];
+    }
+}

+ 32 - 0
api-v13/app/Http/Resources/V3/AdminCreditOverviewResource.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use Illuminate\Http\Request;
+
+/**
+ * 管理后台 AI 对话积分概览(载荷来自 CreditAdminService::overview())。
+ *
+ * recent_days:最近 14 个 UTC 日(今天在前)每天结算出的读经 / 编辑积分与获得积分的人数;
+ * 某天之后整片为 0 而用户又在读经,多半是每日结算任务没跑。
+ * last_settlement:最近一次结算运行(每日任务或后台手工触发),没有记录为 null。
+ */
+class AdminCreditOverviewResource extends BaseResource
+{
+    /**
+     * @param  Request  $request
+     * @return array{
+     *     today: string,
+     *     earn_since: string,
+     *     policy_version: int,
+     *     policy: object,
+     *     totals: array{user_accounts: int, guest_accounts: int, outstanding_balance: int, earned_total: int, adjusted_total: int, spent_today: int},
+     *     recent_days: array<int, array{day: string, users: int, reading: int, editing: int}>,
+     *     last_settlement: array{mode: 'day'|'missing', from: string, to: string, users: int, pairs: int|null, trigger: 'cli'|'admin', operator: string|null, ran_at: string, seconds: float}|null
+     * }
+     */
+    public function toArray($request): array
+    {
+        return $this->resource;
+    }
+}

+ 23 - 0
api-v13/app/Http/Resources/V3/AdminCreditSettlementResource.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Http\Resources\V3;
+
+use Illuminate\Http\Request;
+
+/**
+ * 一次积分结算的结果(载荷来自 CreditAdminService::settle())。
+ *
+ * mode=day:只重算了 from 那一天的所有用户,pairs 为 null;
+ * mode=missing:补齐了 from ~ to 之间漏结算的「用户 + 日」,pairs 是补了多少个。
+ */
+class AdminCreditSettlementResource extends BaseResource
+{
+    /**
+     * @param  Request  $request
+     * @return array{mode: 'day'|'missing', from: string, to: string, users: int, pairs: int|null, trigger: 'cli'|'admin', operator: string|null, ran_at: string, seconds: float}
+     */
+    public function toArray($request): array
+    {
+        return $this->resource;
+    }
+}

+ 17 - 0
api-v13/app/Models/CreditLedgerEntry.php

@@ -5,6 +5,7 @@ namespace App\Models;
 use App\Models\Concerns\OwnedByAgentAccount;
 use App\Services\V3\CreditService;
 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 /**
  * 积分流水的一条。余额 = 流水汇总,见 {@see CreditService}。
@@ -25,4 +26,20 @@ class CreditLedgerEntry extends Model
         'day' => 'date:Y-m-d',
         'delta' => 'integer',
     ];
+
+    /**
+     * 账号对应的用户。只对 account_type = user 有意义:游客的 account_id 是设备 id,碰巧与某个用户 uid 相同也不能当成他。
+     */
+    public function user(): BelongsTo
+    {
+        return $this->belongsTo(UserInfo::class, 'account_id', 'userid');
+    }
+
+    /**
+     * 手工调整的操作人(管理员);系统产生的流水为空。
+     */
+    public function operator(): BelongsTo
+    {
+        return $this->belongsTo(UserInfo::class, 'operator_uid', 'userid');
+    }
 }

+ 234 - 0
api-v13/app/Services/V3/CreditAdminService.php

@@ -0,0 +1,234 @@
+<?php
+
+namespace App\Services\V3;
+
+use App\Facades\RedisCache;
+use App\Models\CreditLedgerEntry;
+use App\Models\UserInfo;
+use App\Services\UserService;
+use Carbon\CarbonInterface;
+use Illuminate\Contracts\Pagination\LengthAwarePaginator;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Str;
+use Illuminate\Validation\ValidationException;
+
+/**
+ * 管理后台的 AI 对话积分管理:账号余额一览、流水、手工加减、手工触发结算。
+ *
+ * 余额口径与 {@see CreditService} 一致:积分余额 = bucket=earned 的流水合计;
+ * 每日赠送池不入账,只看当天 free 流水的消耗。
+ */
+class CreditAdminService
+{
+    /** 最近一次结算的记录(命令行与管理后台都写),只用于显示,丢了不影响结算本身。 */
+    public const LAST_SETTLEMENT_KEY = '/credits/settlement/last';
+
+    /** 概览里按日列出最近多少天的结算结果。 */
+    public const RECENT_DAYS = 14;
+
+    public function __construct(private readonly CreditService $credits) {}
+
+    /**
+     * 概览:策略、全站合计、最近 14 天每天结算出的积分、最近一次结算任务。
+     *
+     * @return array{today: string, earn_since: string, policy_version: int, policy: array<string, mixed>, totals: array{user_accounts: int, guest_accounts: int, outstanding_balance: int, earned_total: int, adjusted_total: int, spent_today: int}, recent_days: list<array{day: string, users: int, reading: int, editing: int}>, last_settlement: array<string, mixed>|null}
+     */
+    public function overview(): array
+    {
+        ['version' => $version, 'rules' => $rules] = $this->credits->policy();
+        $today = now('UTC')->startOfDay();
+        $since = $today->copy()->subDays(self::RECENT_DAYS - 1);
+
+        $accounts = CreditLedgerEntry::query()
+            ->selectRaw('account_type, count(distinct account_id) as n')
+            ->groupBy('account_type')
+            ->pluck('n', 'account_type');
+        $byKind = CreditLedgerEntry::query()
+            ->where('account_type', 'user')->where('bucket', 'earned')
+            ->selectRaw('kind, sum(delta) as total')
+            ->groupBy('kind')
+            ->pluck('total', 'kind');
+        $spentToday = -(int) CreditLedgerEntry::query()
+            ->where('day', $today->toDateString())->whereIn('kind', ['spend', 'refund'])
+            ->sum('delta');
+
+        $earned = CreditLedgerEntry::query()
+            ->where('kind', 'earn')->whereBetween('day', [$since->toDateString(), $today->toDateString()])
+            ->selectRaw('day, source, count(distinct account_id) as users, sum(delta) as total')
+            ->groupBy('day', 'source')
+            ->get();
+        // 一个人同一天可能读经、编辑都有,人数要按天单独去重
+        $usersByDay = CreditLedgerEntry::query()
+            ->where('kind', 'earn')->where('delta', '>', 0)
+            ->whereBetween('day', [$since->toDateString(), $today->toDateString()])
+            ->selectRaw('day, count(distinct account_id) as users')
+            ->groupBy('day')
+            ->get()
+            ->mapWithKeys(fn ($row) => [$row->day->toDateString() => (int) $row->users]);
+        $recent = [];
+        for ($day = $today->copy(); $day->gte($since); $day = $day->copy()->subDay()) {
+            $date = $day->toDateString();
+            $rows = $earned->filter(fn ($row) => $row->day->toDateString() === $date);
+            $recent[] = [
+                'day' => $date,
+                'users' => $usersByDay[$date] ?? 0,
+                'reading' => (int) $rows->where('source', 'reading')->sum('total'),
+                'editing' => (int) $rows->where('source', 'editing')->sum('total'),
+            ];
+        }
+
+        return [
+            'today' => $today->toDateString(),
+            'earn_since' => (string) config('mint.credits.earn_since'),
+            'policy_version' => $version,
+            'policy' => $rules,
+            'totals' => [
+                'user_accounts' => (int) ($accounts['user'] ?? 0),
+                'guest_accounts' => (int) ($accounts['guest'] ?? 0),
+                'outstanding_balance' => (int) $byKind->sum(),
+                'earned_total' => (int) ($byKind['earn'] ?? 0),
+                'adjusted_total' => (int) ($byKind['adjust'] ?? 0),
+                'spent_today' => $spentToday,
+            ],
+            'recent_days' => $recent,
+            'last_settlement' => RedisCache::get(self::LAST_SETTLEMENT_KEY),
+        ];
+    }
+
+    /**
+     * 有积分流水的账号,最近有动静的在前。每行是一个账号的汇总(不是模型行)。
+     *
+     * @param  array{filter?: array{account_type?: string, q?: string}}  $filters
+     * @return LengthAwarePaginator<int, CreditLedgerEntry>
+     */
+    public function accounts(array $filters, int $perPage): LengthAwarePaginator
+    {
+        $f = $filters['filter'] ?? [];
+        $today = now('UTC')->toDateString();
+
+        return CreditLedgerEntry::query()
+            ->with(UserService::eagerLoadActor()[0])
+            ->select(['account_type', 'account_id'])
+            ->selectRaw("sum(case when bucket = 'earned' then delta else 0 end) as earned_balance")
+            ->selectRaw("sum(case when kind = 'earn' then delta else 0 end) as earned_total")
+            ->selectRaw("sum(case when kind = 'adjust' then delta else 0 end) as adjusted_total")
+            ->selectRaw("-sum(case when kind in ('spend', 'refund') then delta else 0 end) as spent_total")
+            ->selectRaw("-sum(case when bucket = 'free' and day = ? then delta else 0 end) as free_used_today", [$today])
+            ->selectRaw('max(updated_at) as last_activity_at')
+            ->when($f['account_type'] ?? null, fn ($q, $v) => $q->where('account_type', $v))
+            ->when($f['q'] ?? null, function ($q, string $v) {
+                $like = '%'.addcslashes($v, '%_\\').'%';
+                $users = UserInfo::query()
+                    ->where(fn ($u) => $u->where('username', 'ilike', $like)
+                        ->orWhere('nickname', 'ilike', $like)
+                        ->orWhere('email', 'ilike', $like))
+                    ->limit(200)
+                    ->pluck('userid');
+                $q->where(fn ($w) => $w
+                    ->where(fn ($u) => $u->where('account_type', 'user')->whereIn('account_id', $users))
+                    ->orWhere(fn ($g) => $g->where('account_type', 'guest')->where('account_id', 'ilike', addcslashes($v, '%_\\').'%')));
+            })
+            ->groupBy('account_type', 'account_id')
+            ->orderByDesc('last_activity_at')
+            ->orderBy('account_id')
+            ->paginate($perPage);
+    }
+
+    /**
+     * 积分流水,最新的在前。
+     *
+     * @param  array{filter?: array{account_type?: string, account_id?: string, kind?: string, bucket?: string, source?: string, from?: string, to?: string}}  $filters
+     * @return LengthAwarePaginator<int, CreditLedgerEntry>
+     */
+    public function ledger(array $filters, int $perPage): LengthAwarePaginator
+    {
+        $f = $filters['filter'] ?? [];
+
+        return CreditLedgerEntry::query()
+            ->with([UserService::eagerLoadActor()[0], UserService::eagerLoadActor('operator')[0]])
+            ->when($f['account_type'] ?? null, fn ($q, $v) => $q->where('account_type', $v))
+            ->when($f['account_id'] ?? null, fn ($q, $v) => $q->where('account_id', $v))
+            ->when($f['kind'] ?? null, fn ($q, $v) => $q->where('kind', $v))
+            ->when($f['bucket'] ?? null, fn ($q, $v) => $q->where('bucket', $v))
+            ->when($f['source'] ?? null, fn ($q, $v) => $q->where('source', $v))
+            ->when($f['from'] ?? null, fn ($q, $v) => $q->where('day', '>=', $v))
+            ->when($f['to'] ?? null, fn ($q, $v) => $q->where('day', '<=', $v))
+            ->orderByDesc('id')
+            ->paginate($perPage);
+    }
+
+    /**
+     * 管理员给某个登录用户加减积分(积分余额池)。同一 ref 只生效一次:重复提交返回原来那条,created=false。
+     *
+     * @param  string  $user  用户 uuid、用户名或邮箱
+     * @return array{entry: CreditLedgerEntry, created: bool, earned_balance: int}
+     *
+     * @throws ValidationException 用户不存在;扣减后余额为负
+     */
+    public function adjust(string $operatorUid, string $user, int $delta, string $note, ?string $ref): array
+    {
+        $userUid = UserInfo::query()
+            ->when(Str::isUuid($user),
+                fn ($q) => $q->where('userid', $user),
+                fn ($q) => $q->where('username', $user)->orWhereRaw('lower(email) = lower(?)', [$user]))
+            ->value('userid');
+        if ($userUid === null) {
+            throw ValidationException::withMessages(['user' => __('messages.credit_user_not_found')]);
+        }
+        $account = AgentAccount::user($userUid);
+        $ref ??= (string) Str::uuid();
+
+        return DB::transaction(function () use ($account, $operatorUid, $delta, $note, $ref) {
+            // 与扣费同一把锁:扣减时的余额检查不能和并发的提问扣费交错
+            DB::select('select pg_advisory_xact_lock(hashtext(?))', [$account->key()]);
+
+            $balance = (int) CreditLedgerEntry::ownedBy($account)->where('bucket', 'earned')->sum('delta');
+            $existing = CreditLedgerEntry::ownedBy($account)
+                ->where(['source' => 'admin', 'ref' => $ref, 'kind' => 'adjust', 'bucket' => 'earned'])->first();
+            if ($existing === null && $balance + $delta < 0) {
+                throw ValidationException::withMessages(['delta' => __('messages.credit_balance_negative', ['balance' => $balance])]);
+            }
+            $entry = $existing ?? $this->credits->adjust($account, $delta, $ref, $note, $operatorUid);
+
+            return [
+                'entry' => $entry->load([UserService::eagerLoadActor()[0], UserService::eagerLoadActor('operator')[0]]),
+                'created' => $existing === null,
+                'earned_balance' => $existing === null ? $balance + $delta : $balance,
+            ];
+        });
+    }
+
+    /**
+     * 手工跑一次结算,与每日任务 `credits:settle-activity` 同一套逻辑,可重复执行、不会重复入账。
+     *
+     * - 给 $day:只重算那一天的所有用户(结果覆盖那天的积分);
+     * - 不给:从积分上线日到昨天,补齐所有漏结算的「用户 + 日」。
+     *
+     * @param  string|null  $operatorUid  管理后台触发时的管理员;命令行(每日任务)为 null
+     * @return array{mode: string, from: string, to: string, users: int, pairs: int|null, trigger: string, operator: string|null, ran_at: string, seconds: float}
+     */
+    public function settle(?CarbonInterface $day, ?string $operatorUid = null): array
+    {
+        $started = microtime(true);
+        if ($day !== null) {
+            $day = $day->copy()->startOfDay();
+            $users = $this->credits->settleDay($day);
+            $result = ['mode' => 'day', 'from' => $day->toDateString(), 'to' => $day->toDateString(), 'users' => $users, 'pairs' => null];
+        } else {
+            $since = now('UTC')->parse((string) config('mint.credits.earn_since'))->startOfDay();
+            $until = now('UTC')->subDay()->startOfDay();
+            ['pairs' => $pairs, 'users' => $users] = $this->credits->settleMissing($since, $until);
+            $result = ['mode' => 'missing', 'from' => $since->toDateString(), 'to' => $until->toDateString(), 'users' => $users, 'pairs' => $pairs];
+        }
+
+        $result += [
+            'trigger' => $operatorUid === null ? 'cli' : 'admin',
+            'operator' => $operatorUid === null ? null : UserInfo::where('userid', $operatorUid)->value('nickname'),
+            'ran_at' => now('UTC')->toIso8601ZuluString(),
+            'seconds' => round(microtime(true) - $started, 2),
+        ];
+        RedisCache::put(self::LAST_SETTLEMENT_KEY, $result, now()->addDays(30));
+
+        return $result;
+    }
+}

+ 4 - 1
api-v13/app/Services/V3/CreditService.php

@@ -289,8 +289,10 @@ class CreditService
 
     /**
      * 手工加减积分(积分余额池)。ref 由调用方给,同一 ref 只生效一次。
+     *
+     * @param  string|null  $operatorUid  操作的管理员(管理后台调整时给;命令行为 null)
      */
-    public function adjust(AgentAccount $account, int $delta, string $ref, ?string $note): CreditLedgerEntry
+    public function adjust(AgentAccount $account, int $delta, string $ref, ?string $note, ?string $operatorUid = null): CreditLedgerEntry
     {
         return CreditLedgerEntry::createOrFirst([
             ...$account->columns(),
@@ -303,6 +305,7 @@ class CreditService
             'day' => $this->today()->toDateString(),
             'policy_version' => $this->policy()['version'],
             'note' => $note,
+            'operator_uid' => $operatorUid,
         ]);
     }
 

+ 28 - 0
api-v13/database/migrations/2026_11_19_100000_add_operator_uid_to_credit_ledger.php

@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+/**
+ * 积分流水的操作人:管理后台手工加减积分(kind=adjust、source=admin)时记下是哪位管理员。
+ *
+ * 其余流水(结算、扣费、退回)由系统产生,留空;artisan credits:adjust 在命令行执行,也留空。
+ */
+return new class extends Migration
+{
+    public function up(): void
+    {
+        Schema::table('credit_ledger', function (Blueprint $table) {
+            $table->uuid('operator_uid')->nullable()
+                ->comment('操作人用户 uuid(user_infos.userid):管理后台手工调整时填写;系统产生或命令行调整的流水为空');
+        });
+    }
+
+    public function down(): void
+    {
+        Schema::table('credit_ledger', function (Blueprint $table) {
+            $table->dropColumn('operator_uid');
+        });
+    }
+};

+ 3 - 1
api-v13/documents/tasks.md

@@ -60,7 +60,9 @@ php artisan upgrade:community.term zh-Hans
 php artisan export:offline lzma
 
 # AI 对话积分:把读经、编辑时长结算成积分。补齐上线以来所有漏结算的日子,
-# 漏跑几天都没关系,下次跑会补上;可重复执行,不会重复入账
+# 漏跑几天都没关系,下次跑会补上;可重复执行,不会重复入账。
+# 任务出问题时管理员可在 dashboard-v6 /admin/credits 手工「补齐漏结算」或「重算某一天」(同一套逻辑);
+# 最近一次运行(任务或手工)也显示在那里
 php artisan credits:settle-activity
 
 ```

+ 2 - 0
api-v13/resources/lang/en/messages.php

@@ -49,6 +49,8 @@ return [
     'agent_quota_insufficient_user' => 'Not enough credits for this question today. Reading the texts earns more credits.',
     'agent_quota_insufficient_guest' => 'You have used today\'s free questions. Sign in to get more each day.',
     'agent_quota_ip_cap' => 'Too many questions from this network today. Please sign in to continue.',
+    'credit_user_not_found' => 'No user with this ID, username or email.',
+    'credit_balance_negative' => 'The balance would drop below zero (current balance: :balance).',
     'reading_time_day_out_of_range' => 'Reading time can only be reported for today or the past 2 days.',
     'stats_range_too_long' => 'The date range can be at most :days days.',
     'agent_feedback_tags' => 'These tags do not match the rating.',

+ 2 - 0
api-v13/resources/lang/zh-Hans/messages.php

@@ -49,6 +49,8 @@ return [
     'agent_quota_insufficient_user' => '今天的积分不够这次提问了。读经可以赚取积分。',
     'agent_quota_insufficient_guest' => '今天的免费提问次数用完了。登录后每天有更多次数。',
     'agent_quota_ip_cap' => '今天同一网络下的提问太多了,请登录后继续。',
+    'credit_user_not_found' => '找不到这个用户(可填用户 ID、用户名或邮箱)。',
+    'credit_balance_negative' => '扣减后余额会变成负数(当前余额 :balance)。',
     'reading_time_day_out_of_range' => '读经时长只能上报今天或 2 天内的。',
     'stats_range_too_long' => '时间范围最多 :days 天。',
     'agent_feedback_tags' => '标签和评价不配套。',

+ 12 - 0
api-v13/routes/v3/admin.php

@@ -13,6 +13,11 @@
 use App\Http\Controllers\V3\AdminAgentFeedbackController;
 use App\Http\Controllers\V3\AdminAgentRunController;
 use App\Http\Controllers\V3\AdminAgentStatsController;
+use App\Http\Controllers\V3\AdminCreditAccountController;
+use App\Http\Controllers\V3\AdminCreditAdjustmentController;
+use App\Http\Controllers\V3\AdminCreditLedgerController;
+use App\Http\Controllers\V3\AdminCreditOverviewController;
+use App\Http\Controllers\V3\AdminCreditSettlementController;
 use App\Http\Controllers\V3\AdminReadingStatsController;
 use Illuminate\Support\Facades\Route;
 
@@ -26,4 +31,11 @@ Route::prefix('admin')->as('admin.')->middleware(['auth.v3', 'auth.v3.admin'])->
     Route::get('agent-runs/digest', [AdminAgentRunController::class, 'digest'])->name('agent-runs.digest');
     Route::get('agent-runs', [AdminAgentRunController::class, 'index'])->name('agent-runs.index');
     Route::get('agent-runs/{run}', [AdminAgentRunController::class, 'show'])->name('agent-runs.show')->whereUuid('run');
+
+    // AI 对话积分管理:概览(单例)、账号一览、流水、手工加减、手工结算(每日任务出问题时用)
+    Route::get('credit-overview', AdminCreditOverviewController::class)->name('credit-overview');
+    Route::get('credit-accounts', [AdminCreditAccountController::class, 'index'])->name('credit-accounts.index');
+    Route::get('credit-ledger', [AdminCreditLedgerController::class, 'index'])->name('credit-ledger.index');
+    Route::post('credit-adjustments', [AdminCreditAdjustmentController::class, 'store'])->name('credit-adjustments.store');
+    Route::post('credit-settlements', [AdminCreditSettlementController::class, 'store'])->name('credit-settlements.store');
 });

+ 239 - 0
api-v13/tests/Feature/AdminCreditV3Test.php

@@ -0,0 +1,239 @@
+<?php
+
+use App\Facades\RedisCache;
+use App\Models\CreditLedgerEntry;
+use App\Models\ReadingDaily;
+use App\Models\UserInfo;
+use App\Services\V3\AgentAccount;
+use App\Services\V3\CreditAdminService;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Str;
+
+uses(RefreshDatabase::class);
+
+/**
+ * v3 管理后台 AI 对话积分管理(仅 root / administrator):
+ *
+ *   GET  /api/v3/admin/credit-overview     概览
+ *   GET  /api/v3/admin/credit-accounts     账号一览
+ *   GET  /api/v3/admin/credit-ledger       流水
+ *   POST /api/v3/admin/credit-adjustments  手工加减
+ *   POST /api/v3/admin/credit-settlements  手工结算
+ *
+ * 这里断言的是形状而非契约(spectator 尚未安装,见 v3-resource skill 第 3 步)。
+ */
+function creditAdmin(): string
+{
+    $uid = makeStudio('cadmin-'.Str::random(6));
+    UserInfo::where('userid', $uid)->update(['role' => json_encode(['administrator'])]);
+
+    return $uid;
+}
+
+function ledgerRow(AgentAccount $account, int $delta, array $extra = []): CreditLedgerEntry
+{
+    return CreditLedgerEntry::create([
+        ...$account->columns(), 'delta' => $delta, 'kind' => 'earn', 'bucket' => 'earned', 'source' => 'reading',
+        'ref' => (string) Str::uuid(), 'day' => now('UTC')->toDateString(), 'policy_version' => 1, ...$extra,
+    ]);
+}
+
+/* ------------------------------------------------------------------ 权限 */
+
+it('requires login', function (string $method, string $path) {
+    $this->json($method, "/api/v3/admin/{$path}")->assertUnauthorized();
+})->with([
+    ['GET', 'credit-overview'], ['GET', 'credit-accounts'], ['GET', 'credit-ledger'],
+    ['POST', 'credit-adjustments'], ['POST', 'credit-settlements'],
+]);
+
+it('forbids non-admin users', function (string $method, string $path) {
+    $this->json($method, "/api/v3/admin/{$path}", [], authHeader(makeStudio('plain-'.Str::random(5))))->assertForbidden();
+})->with([
+    ['GET', 'credit-overview'], ['GET', 'credit-accounts'], ['GET', 'credit-ledger'],
+    ['POST', 'credit-adjustments'], ['POST', 'credit-settlements'],
+]);
+
+/* ------------------------------------------------------------------ 概览 */
+
+it('summarises balances and recent settlements', function () {
+    $user = AgentAccount::user(makeStudio('reader-'.Str::random(5)));
+    ledgerRow($user, 40);
+    ledgerRow($user, -10, ['kind' => 'spend', 'source' => 'agent_run']);
+    ledgerRow(AgentAccount::guest((string) Str::uuid()), -10, ['kind' => 'spend', 'bucket' => 'free', 'source' => 'agent_run']);
+
+    $data = $this->getJson('/api/v3/admin/credit-overview', authHeader(creditAdmin()))->assertOk()->json('data');
+
+    expect($data['totals'])->toMatchArray([
+        'user_accounts' => 1, 'guest_accounts' => 1, 'outstanding_balance' => 30, 'earned_total' => 40, 'spent_today' => 20,
+    ])
+        ->and($data['recent_days'])->toHaveCount(CreditAdminService::RECENT_DAYS)
+        ->and($data['recent_days'][0])->toMatchArray(['day' => now('UTC')->toDateString(), 'users' => 1, 'reading' => 40])
+        ->and($data['last_settlement'])->toBeNull()
+        ->and($data['policy'])->toHaveKeys(['daily_free', 'cost', 'earn']);
+});
+
+/* ------------------------------------------------------------------ 账号一览 */
+
+it('lists accounts with their balances, searchable by user name', function () {
+    $alice = makeStudio('alice-'.Str::random(5));
+    $bob = makeStudio('bob-'.Str::random(5));
+    ledgerRow(AgentAccount::user($alice), 50);
+    ledgerRow(AgentAccount::user($alice), -10, ['kind' => 'spend', 'source' => 'agent_run']);
+    ledgerRow(AgentAccount::user($alice), -30, ['kind' => 'spend', 'bucket' => 'free', 'source' => 'agent_run']);
+    ledgerRow(AgentAccount::user($bob), 5);
+    $admin = creditAdmin();
+
+    $rows = $this->getJson('/api/v3/admin/credit-accounts?filter[q]=alice', authHeader($admin))->assertOk()->json('data');
+
+    expect($rows)->toHaveCount(1)
+        ->and($rows[0])->toMatchArray([
+            'account_type' => 'user', 'account_id' => $alice, 'earned_balance' => 40, 'earned_total' => 50,
+            'spent_total' => 40, 'free_used_today' => 30,
+        ])
+        ->and($rows[0]['user']['id'])->toBe($alice);
+
+    expect($this->getJson('/api/v3/admin/credit-accounts', authHeader($admin))->json('meta.total'))->toBe(2);
+});
+
+it('never treats a guest device id as the user with the same uuid', function () {
+    $alice = makeStudio('alice-'.Str::random(5));
+    ledgerRow(AgentAccount::guest($alice), -10, ['kind' => 'spend', 'bucket' => 'free', 'source' => 'agent_run']);
+
+    $rows = $this->getJson('/api/v3/admin/credit-accounts?filter[account_type]=guest', authHeader(creditAdmin()))->json('data');
+
+    expect($rows)->toHaveCount(1)->and($rows[0]['user'])->toBeNull();
+});
+
+it('rejects an unknown account type', function () {
+    $this->getJson('/api/v3/admin/credit-accounts?filter[account_type]=robot', authHeader(creditAdmin()))->assertUnprocessable();
+});
+
+/* ------------------------------------------------------------------ 流水 */
+
+it('lists ledger entries of one account without exposing ids', function () {
+    $alice = makeStudio('alice-'.Str::random(5));
+    ledgerRow(AgentAccount::user($alice), 7);
+    ledgerRow(AgentAccount::guest($alice), -10, ['kind' => 'spend', 'bucket' => 'free', 'source' => 'agent_run']);
+    ledgerRow(AgentAccount::user(makeStudio('other-'.Str::random(5))), 3);
+
+    $res = $this->getJson("/api/v3/admin/credit-ledger?filter[account_type]=user&filter[account_id]={$alice}", authHeader(creditAdmin()))
+        ->assertOk();
+
+    expect($res->json('data'))->toHaveCount(1)
+        ->and($res->json('data.0'))->toMatchArray(['delta' => 7, 'kind' => 'earn', 'source' => 'reading', 'operator' => null])
+        ->and($res->json('data.0'))->not->toHaveKey('id');
+});
+
+it('requires the account type together with the account id', function () {
+    $this->getJson('/api/v3/admin/credit-ledger?filter[account_id]='.Str::uuid(), authHeader(creditAdmin()))
+        ->assertUnprocessable()->assertJsonValidationErrors('filter.account_type');
+});
+
+it('keeps the ledger query count independent of the number of rows', function () {
+    $admin = creditAdmin();
+    $count = function () use ($admin) {
+        DB::flushQueryLog();
+        DB::enableQueryLog();
+        $this->getJson('/api/v3/admin/credit-ledger', authHeader($admin))->assertOk();
+
+        return count(DB::getQueryLog());
+    };
+    ledgerRow(AgentAccount::user(makeStudio('u-'.Str::random(5))), 1);
+    $few = $count();
+    foreach (range(1, 8) as $i) {
+        ledgerRow(AgentAccount::user(makeStudio("u{$i}-".Str::random(5))), 1);
+    }
+
+    expect($count())->toBe($few);
+});
+
+/* ------------------------------------------------------------------ 手工加减 */
+
+it('grants credits by username and records the operator', function () {
+    $username = 'alice-'.Str::random(5);
+    $alice = makeStudio($username);
+    $admin = creditAdmin();
+
+    $res = $this->postJson('/api/v3/admin/credit-adjustments', ['user' => $username, 'delta' => 200, 'note' => '补发'], authHeader($admin))
+        ->assertCreated();
+
+    expect($res->json('data'))->toMatchArray(['account_id' => $alice, 'delta' => 200, 'kind' => 'adjust', 'source' => 'admin', 'note' => '补发'])
+        ->and($res->json('data.operator.id'))->toBe($admin)
+        ->and($res->json('meta'))->toBe(['created' => true, 'earned_balance' => 200]);
+    expect(CreditLedgerEntry::where('account_id', $alice)->value('operator_uid'))->toBe($admin);
+});
+
+it('applies the same ref only once', function () {
+    $alice = makeStudio('alice-'.Str::random(5));
+    $body = ['user' => $alice, 'delta' => 50, 'note' => 'x', 'ref' => (string) Str::uuid()];
+    $admin = authHeader(creditAdmin());
+
+    $this->postJson('/api/v3/admin/credit-adjustments', $body, $admin)->assertCreated();
+    $this->postJson('/api/v3/admin/credit-adjustments', $body, $admin)->assertOk()->assertJsonPath('meta.created', false);
+
+    expect((int) CreditLedgerEntry::where('account_id', $alice)->sum('delta'))->toBe(50);
+});
+
+it('refuses a deduction that would make the balance negative', function () {
+    $alice = makeStudio('alice-'.Str::random(5));
+    ledgerRow(AgentAccount::user($alice), 30);
+
+    $this->postJson('/api/v3/admin/credit-adjustments', ['user' => $alice, 'delta' => -31, 'note' => 'x'], authHeader(creditAdmin()))
+        ->assertUnprocessable()->assertJsonValidationErrors('delta');
+    $this->postJson('/api/v3/admin/credit-adjustments', ['user' => $alice, 'delta' => -30, 'note' => 'x'], authHeader(creditAdmin()))
+        ->assertCreated()->assertJsonPath('meta.earned_balance', 0);
+});
+
+it('rejects an unknown user, a zero delta and a missing note', function () {
+    $admin = authHeader(creditAdmin());
+
+    $this->postJson('/api/v3/admin/credit-adjustments', ['user' => 'nobody-'.Str::random(8), 'delta' => 1, 'note' => 'x'], $admin)
+        ->assertUnprocessable()->assertJsonValidationErrors('user');
+    $this->postJson('/api/v3/admin/credit-adjustments', ['user' => 'x', 'delta' => 0], $admin)
+        ->assertUnprocessable()->assertJsonValidationErrors(['delta', 'note']);
+});
+
+/* ------------------------------------------------------------------ 手工结算 */
+
+it('settles missing days, is idempotent and records the last run', function () {
+    $alice = makeStudio('alice-'.Str::random(5));
+    ReadingDaily::create(['user_uid' => $alice, 'day' => now('UTC')->subDays(2)->toDateString(), 'seconds' => 600, 'seconds_reported' => 600]);
+    $admin = creditAdmin();
+
+    $first = $this->postJson('/api/v3/admin/credit-settlements', [], authHeader($admin))->assertCreated()->json('data');
+    $this->postJson('/api/v3/admin/credit-settlements', [], authHeader($admin))->assertCreated();
+
+    expect($first)->toMatchArray(['mode' => 'missing', 'users' => 1, 'pairs' => 1, 'trigger' => 'admin'])
+        ->and((int) CreditLedgerEntry::where('account_id', $alice)->sum('delta'))->toBe(10)
+        ->and(RedisCache::get(CreditAdminService::LAST_SETTLEMENT_KEY)['trigger'])->toBe('admin');
+});
+
+it('re-settles one day on demand without double counting', function () {
+    $alice = makeStudio('alice-'.Str::random(5));
+    $day = now('UTC')->subDay()->toDateString();
+    ReadingDaily::create(['user_uid' => $alice, 'day' => $day, 'seconds' => 300, 'seconds_reported' => 300]);
+    $admin = authHeader(creditAdmin());
+
+    $this->postJson('/api/v3/admin/credit-settlements', ['date' => $day], $admin)->assertCreated()
+        ->assertJsonPath('data.mode', 'day')->assertJsonPath('data.users', 1);
+    $this->postJson('/api/v3/admin/credit-settlements', ['date' => $day], $admin)->assertCreated();
+
+    expect((int) CreditLedgerEntry::where('account_id', $alice)->sum('delta'))->toBe(5);
+});
+
+it('rejects a settlement date before credits went live or in the future', function (string $date) {
+    $this->postJson('/api/v3/admin/credit-settlements', ['date' => $date], authHeader(creditAdmin()))
+        ->assertUnprocessable()->assertJsonValidationErrors('date');
+})->with([
+    'before launch' => ['2020-01-01'],
+    'future' => [fn () => now('UTC')->addDay()->toDateString()],
+    'malformed' => ['yesterday'],
+]);
+
+it('records the daily command as the last run too', function () {
+    $this->artisan('credits:settle-activity')->assertSuccessful();
+
+    expect(RedisCache::get(CreditAdminService::LAST_SETTLEMENT_KEY))->toMatchArray(['trigger' => 'cli', 'operator' => null]);
+});

+ 4 - 0
dashboard-test/.env.example

@@ -28,6 +28,10 @@ E2E_ARTICLE=f24cfd88-5e0c-486d-844b-8d237b5b80d7
 # E2E_ASSISTANT_USER=
 # E2E_ASSISTANT_PASS=
 
+# ── 管理后台测试(admin-credits.spec)── 管理员账号(role 含 administrator),没配就跳过
+# E2E_ADMIN_USER=
+# E2E_ADMIN_PASS=
+
 # Laravel 端 library 页面(/library/course)的根地址。本机 dev 在 8000 端口,不在 dashboard 的 4000 上;
 # staging / 线上与 dashboard 同域,不用设
 # E2E_LIBRARY=http://127.0.0.1:8000/library/

+ 1 - 1
dashboard-test/src/lib/api.ts

@@ -13,7 +13,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
  * 登录态缓存。`user` 是 E2E_USER(auth.setup 必登),
  * `student` / `assistant` 是可选的第二、第三个账号(配了 E2E_STUDENT_* / E2E_ASSISTANT_* 才会登录)。
  */
-export type Account = 'user' | 'student' | 'assistant';
+export type Account = 'user' | 'student' | 'assistant' | 'admin';
 
 export const authFile = (who: Account = 'user') =>
   path.join(__dirname, `../../playwright/.auth/${who}.json`);

+ 7 - 0
dashboard-test/src/lib/env.ts

@@ -37,6 +37,13 @@ export const ASSISTANT_PASS = process.env.E2E_ASSISTANT_PASS || '';
 export const HAS_STUDENT = !!(STUDENT_USER && STUDENT_PASS);
 export const HAS_ASSISTANT = !!(ASSISTANT_USER && ASSISTANT_PASS);
 
+/**
+ * 管理后台测试(admin-credits.spec)用的管理员账号(user_infos.role 含 administrator)。可选——没配就跳过。
+ */
+export const ADMIN_USER = process.env.E2E_ADMIN_USER || '';
+export const ADMIN_PASS = process.env.E2E_ADMIN_PASS || '';
+export const HAS_ADMIN = !!(ADMIN_USER && ADMIN_PASS);
+
 /**
  * 课程用的教材与标准答案。默认是本机开发库里的「初级班课本范例」文集(公开),
  * 其中「练习一」一篇只有一个句子 168-916-2-9;标准答案 channel 在这一段上有逐词解析与译文。

+ 167 - 0
dashboard-test/src/tests/admin-credits.spec.ts

@@ -0,0 +1,167 @@
+import { test, expect, type Browser, type Page } from '@playwright/test';
+import { collect } from '../lib/collect.js';
+import { authFile } from '../lib/api.js';
+import { BASE, DESTRUCTIVE, HAS_ADMIN, USER, shotDir } from '../lib/env.js';
+
+/**
+ * 管理后台 · AI 积分:/admin/credits
+ *
+ * 后端是 v3:admin/credit-overview、credit-accounts、credit-ledger、credit-adjustments、credit-settlements。
+ * 管理员账号由 E2E_ADMIN_USER / E2E_ADMIN_PASS 配置(没配就跳过管理员用例);E2E_USER 是普通用户,
+ * 用来验证 403 页面,也是被加减积分的那个人。
+ *
+ * 写操作全是真实后端,且不留净额:
+ * - 结算可重复执行(同一用户同一天的积分覆盖,不累加);
+ * - 给 E2E_USER 先加 100 再扣 100,备注 `e2e-tmp-<时间戳>`,流水留着看(流水本来就不能删)。
+ *
+ * 截图输出目录由 E2E_SHOT 指定,默认 testlog/assets/admin-credits_latest。
+ */
+const SHOT = shotDir('admin-credits');
+const shot = (page: Page, name: string) => page.screenshot({ path: `${SHOT}/${name}.png`, fullPage: true });
+
+async function openAdmin(browser: Browser) {
+  const ctx = await browser.newContext({ baseURL: BASE, storageState: authFile('admin') });
+  const page = await ctx.newPage();
+  const log = collect(page);
+  await page.goto('admin/credits');
+  await expect(page.getByRole('heading', { name: 'AI 积分' })).toBeVisible();
+  return { ctx, page, log };
+}
+
+/** 用户选择框(UserSelect,按用户名 / 昵称搜索)里搜 E2E_USER 并选第一项 */
+async function pickUser(page: Page, dialog: ReturnType<Page['getByRole']>) {
+  await dialog.getByLabel('用户').fill(USER);
+  const option = page.locator('.ant-select-dropdown:visible .ant-select-item-option').first();
+  await expect(option).toBeVisible();
+  await option.click();
+}
+
+/** antd message 弹出的提示 */
+const toast = (page: Page, text: string | RegExp) => page.locator('.ant-message').getByText(text);
+
+test('普通用户打开 /admin/credits 看到 403', async ({ page }) => {
+  const log = collect(page);
+  await page.goto('admin/credits');
+  await expect(page.getByText('只有管理员可以访问这个页面。')).toBeVisible();
+  await shot(page, '01-forbidden');
+  log.dump('普通用户 403');
+});
+
+test.describe('管理员', () => {
+  test.skip(!HAS_ADMIN, '未配置 E2E_ADMIN_USER / E2E_ADMIN_PASS');
+
+  test('概览:合计、结算面板、最近 14 天', async ({ browser }) => {
+    const { ctx, page, log } = await openAdmin(browser);
+
+    // 菜单项高亮
+    await expect(page.locator('.ant-menu-item-selected')).toContainText('AI 积分');
+    for (const label of ['用户积分余额合计', '累计结算赚取', '累计手工调整', '今日消耗', '有积分的用户', '游客设备']) {
+      await expect(page.locator('.ant-statistic-title', { hasText: label })).toBeVisible();
+    }
+    await expect(page.getByText('每日积分结算')).toBeVisible();
+    await expect(page.getByText(/^策略 \d{8}:/)).toBeVisible();
+    // 最近 14 天表:14 行,第一行是今天
+    const days = page.locator('.ant-table-tbody').first().locator('tr.ant-table-row');
+    await expect(days).toHaveCount(14);
+    await expect(days.first()).toContainText('今天');
+    await shot(page, '02-overview');
+    expect(log.all, '控制台与 HTTP 错误').toEqual([]);
+    log.dump('概览');
+    await ctx.close();
+  });
+
+  test('补齐漏结算、重算某一天:可重复执行,最近一次结算记为后台手工', async ({ browser }) => {
+    test.skip(!DESTRUCTIVE, 'E2E_DESTRUCTIVE=0');
+    const { ctx, page, log } = await openAdmin(browser);
+
+    for (const round of [1, 2]) {
+      await page.getByRole('button', { name: '补齐漏结算' }).click();
+      await page.locator('.ant-popconfirm').getByRole('button', { name: /确 ?定|OK/ }).click();
+      await expect(toast(page, /补结算了 \d+ 位用户的 \d+ 个「用户 \+ 日」/)).toBeVisible();
+      if (round === 1) await shot(page, '03-settle-missing');
+      // 第二次重复执行:已经全部结清,补 0 个
+      if (round === 2) await expect(toast(page, '补结算了 0 位用户的 0 个「用户 + 日」')).toBeVisible();
+    }
+    await expect(page.getByText(/后台手工(/)).toBeVisible();
+
+    // 重算前天
+    const day = new Date(Date.now() - 2 * 86400_000).toISOString().slice(0, 10);
+    const picker = page.getByPlaceholder('选一天(UTC)');
+    await picker.click();
+    await picker.fill(day);
+    await picker.press('Enter');
+    await page.getByRole('button', { name: '重算这一天' }).click();
+    await page.locator('.ant-popconfirm').getByRole('button', { name: /确 ?定|OK/ }).click();
+    await expect(toast(page, new RegExp(`${day}:结算了 \\d+ 位用户`))).toBeVisible();
+    await shot(page, '04-settle-day');
+
+    expect(log.all, '控制台与 HTTP 错误').toEqual([]);
+    log.dump('手工结算');
+    await ctx.close();
+  });
+
+  test('手工加 100 再扣 100:入账、流水里看得到操作人与备注', async ({ browser }) => {
+    test.skip(!DESTRUCTIVE, 'E2E_DESTRUCTIVE=0');
+    const { ctx, page, log } = await openAdmin(browser);
+    const note = `e2e-tmp-${Date.now()}`;
+
+    for (const delta of [100, -100]) {
+      await page.getByRole('button', { name: '手工加减积分' }).click();
+      const dialog = page.getByRole('dialog', { name: '手工加减积分' });
+      await pickUser(page, dialog);
+      await dialog.getByLabel('积分').fill(String(delta));
+      if (delta < 0) await expect(dialog.getByText('这是扣减。扣减后余额不能为负。')).toBeVisible();
+      await dialog.getByLabel('原因').fill(`${note} ${delta > 0 ? '加' : '扣'}`);
+      if (delta > 0) await shot(page, '05-adjust-dialog');
+      await dialog.getByRole('button', { name: /确 ?定/ }).click();
+      await expect(toast(page, /已入账,当前余额 \d+/)).toBeVisible();
+      await expect(dialog).toBeHidden();
+    }
+
+    // 全部流水:两条都在,带操作人标签
+    await page.getByRole('tab', { name: '全部流水' }).click();
+    const ledger = page.getByRole('tabpanel', { name: '全部流水' });
+    await expect(ledger.getByText(`${note} 加`)).toBeVisible();
+    await expect(ledger.getByText(`${note} 扣`)).toBeVisible();
+    await expect(ledger.locator('tr', { hasText: `${note} 加` })).toContainText('+100');
+    await expect(ledger.locator('tr', { hasText: `${note} 扣` })).toContainText('-100');
+    // 操作人标签(带用户图标)
+    await expect(ledger.locator('tr', { hasText: `${note} 加` }).locator('.ant-tag', { has: page.locator('.anticon-user') })).toBeVisible();
+    await shot(page, '06-ledger');
+
+    // 账号表:搜 E2E_USER,点开看他的流水抽屉
+    await page.getByRole('tab', { name: '账号' }).click();
+    await page.getByPlaceholder('用户名 / 昵称 / 邮箱,或设备 ID').fill(USER);
+    await page.getByPlaceholder('用户名 / 昵称 / 邮箱,或设备 ID').press('Enter');
+    const row = page.getByRole('tabpanel', { name: '账号' }).locator('tr.ant-table-row', { hasText: `@${USER}` });
+    await expect(row).toBeVisible();
+    await row.click();
+    const drawer = page.getByRole('dialog', { name: /的积分流水$/ });
+    await expect(drawer).toBeVisible();
+    await expect(drawer.getByText(`${note} 扣`)).toBeVisible();
+    await shot(page, '07-account-drawer');
+
+    expect(log.all, '控制台与 HTTP 错误').toEqual([]);
+    log.dump('手工加减');
+    await ctx.close();
+  });
+
+  test('扣成负数:表单项下显示后端的字段错误', async ({ browser }) => {
+    const { ctx, page, log } = await openAdmin(browser);
+
+    await page.getByRole('button', { name: '手工加减积分' }).click();
+    const dialog = page.getByRole('dialog', { name: '手工加减积分' });
+    // 用户是搜索选择的,选不到不存在的人;找不到用户的 422 由 Pest / api-test 覆盖
+    await pickUser(page, dialog);
+    await dialog.getByLabel('积分').fill('-1000000');
+    await dialog.getByLabel('原因').fill('e2e-tmp 扣成负数');
+    await dialog.getByRole('button', { name: /确 ?定/ }).click();
+    await expect(dialog.getByText(/扣减后余额会变成负数(当前余额 \d+)。/)).toBeVisible();
+    await shot(page, '08-field-errors');
+
+    // 422 是预期内的
+    expect(log.all.filter((l) => !l.includes('[HTTP 422]') && !l.includes('status of 422')), '控制台与 HTTP 错误').toEqual([]);
+    log.dump('字段错误');
+    await ctx.close();
+  });
+});

+ 8 - 0
dashboard-test/src/tests/auth.setup.ts

@@ -7,6 +7,8 @@ import {
   STUDENT_PASS,
   ASSISTANT_USER,
   ASSISTANT_PASS,
+  ADMIN_USER,
+  ADMIN_PASS,
 } from "../lib/env.js";
 
 export const AUTH_FILE = authFile("user");
@@ -40,3 +42,9 @@ setup("登录助教账号(E2E_ASSISTANT_USER)", async ({ page }) => {
   setup.skip(!ASSISTANT_USER || !ASSISTANT_PASS, "未配置 E2E_ASSISTANT_USER / E2E_ASSISTANT_PASS");
   await signIn(page, ASSISTANT_USER, ASSISTANT_PASS, "assistant");
 });
+
+/* 管理后台测试(admin-credits.spec)用的管理员账号:可选 */
+setup("登录管理员账号(E2E_ADMIN_USER)", async ({ page }) => {
+  setup.skip(!ADMIN_USER || !ADMIN_PASS, "未配置 E2E_ADMIN_USER / E2E_ADMIN_PASS");
+  await signIn(page, ADMIN_USER, ADMIN_PASS, "admin");
+});

+ 45 - 0
dashboard-v6/src/api/adminCredits.ts

@@ -0,0 +1,45 @@
+// src/api/adminCredits.ts
+//
+// 管理后台 · AI 对话积分(v3,仅 root / administrator):概览、账号一览、流水、手工加减、手工结算。
+// 类型全部从 OpenAPI 规格生成(schema.d.ts),这里不手写字段。
+import { api, unwrap } from "./client";
+import type { paths } from "./schema";
+
+type Json<P extends keyof paths, M extends "get" | "post", S extends 200 | 201 = 200> = paths[P][M] extends {
+  responses: { [K in S]: { content: { "application/json": infer B } } };
+}
+  ? B
+  : never;
+
+export type CreditOverview = NonNullable<Json<"/v3/admin/credit-overview", "get">["data"]>;
+export type CreditSettlement = NonNullable<CreditOverview["last_settlement"]>;
+export type CreditAccountList = Json<"/v3/admin/credit-accounts", "get">;
+export type CreditAccount = NonNullable<CreditAccountList["data"]>[number];
+export type CreditLedgerList = Json<"/v3/admin/credit-ledger", "get">;
+export type CreditLedgerEntry = NonNullable<CreditLedgerList["data"]>[number];
+export type CreditAdjustment = Json<"/v3/admin/credit-adjustments", "post", 201>;
+
+export type CreditAccountQuery = NonNullable<paths["/v3/admin/credit-accounts"]["get"]["parameters"]["query"]>;
+export type CreditLedgerQuery = NonNullable<paths["/v3/admin/credit-ledger"]["get"]["parameters"]["query"]>;
+export type CreditAdjustmentBody = NonNullable<
+  paths["/v3/admin/credit-adjustments"]["post"]["requestBody"]
+>["content"]["application/json"];
+export type CreditSettlementBody = NonNullable<
+  paths["/v3/admin/credit-settlements"]["post"]["requestBody"]
+>["content"]["application/json"];
+
+export const getCreditOverview = async (): Promise<CreditOverview> =>
+  unwrap(await api.GET("/v3/admin/credit-overview")).data as CreditOverview;
+
+export const getCreditAccounts = async (query: CreditAccountQuery): Promise<CreditAccountList> =>
+  unwrap(await api.GET("/v3/admin/credit-accounts", { params: { query } }));
+
+export const getCreditLedger = async (query: CreditLedgerQuery): Promise<CreditLedgerList> =>
+  unwrap(await api.GET("/v3/admin/credit-ledger", { params: { query } }));
+
+/** 手工加减积分。表单要字段级错误(用户不存在、余额不够扣),调用方 catch 后用 fieldErrorsOf。 */
+export const adjustCredits = async (body: CreditAdjustmentBody): Promise<CreditAdjustment> =>
+  unwrap(await api.POST("/v3/admin/credit-adjustments", { body })) as CreditAdjustment;
+
+export const settleCredits = async (body: CreditSettlementBody): Promise<CreditSettlement> =>
+  unwrap(await api.POST("/v3/admin/credit-settlements", { body })).data as CreditSettlement;

+ 501 - 0
dashboard-v6/src/api/schema.d.ts

@@ -7838,6 +7838,122 @@ export interface paths {
         patch?: never;
         trace?: never;
     };
+    "/v3/admin/credit-accounts": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 列出积分账号
+         * @description 有积分流水的账号(登录用户与游客设备),每行是该账号的汇总:积分余额、累计赚取、累计手工调整、
+         *     累计消耗、今天用掉的赠送额度。最近有动静的在前。没有任何流水的用户不在列表里,
+         *     但仍可以直接给他加积分(`POST /v3/admin/credit-adjustments`)。
+         *
+         *     实现:`V3\AdminCreditAccountController@index`
+         */
+        get: operations["get_api_v3_admin_credit_accounts"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
+    "/v3/admin/credit-adjustments": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        get?: never;
+        put?: never;
+        /**
+         * 手工加减积分
+         * @description 加到登录用户的积分余额(不过期)。负数为扣减,扣减后余额不能为负。
+         *     同一 `ref` 只入账一次:重复提交返回原来那条(200),新入账是 201。
+         *
+         *     实现:`V3\AdminCreditAdjustmentController@store`
+         */
+        post: operations["post_api_v3_admin_credit_adjustments"];
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
+    "/v3/admin/credit-ledger": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 列出积分流水
+         * @description 最新的在前。包括结算赚取(earn)、提问扣减(spend)、出错退回(refund)与手工调整(adjust)。
+         *
+         *     实现:`V3\AdminCreditLedgerController@index`
+         */
+        get: operations["get_api_v3_admin_credit_ledger"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
+    "/v3/admin/credit-overview": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        /**
+         * 积分概览
+         * @description 当前策略、全站合计(登录用户的积分余额总和、累计赚取、累计手工调整、今天的消耗)、
+         *     最近 14 天每天结算出的积分,以及最近一次结算任务(每日任务或后台手工触发)的结果。
+         *
+         *     实现:`V3\AdminCreditOverviewController@__invoke`
+         */
+        get: operations["get_api_v3_admin_credit_overview"];
+        put?: never;
+        post?: never;
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
+    "/v3/admin/credit-settlements": {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        get?: never;
+        put?: never;
+        /**
+         * 手工结算积分
+         * @description 把登录用户的读经、编辑时长结算成积分。可重复执行:同一用户同一天的积分是覆盖不是累加,不会重复入账。
+         *     不给 `date`:从积分上线日到昨天,补齐所有漏结算的「用户 + 日」(与每日任务相同);
+         *     给 `date`:按当前策略重算那一天的所有用户。同步执行。
+         *
+         *     实现:`V3\AdminCreditSettlementController@store`
+         */
+        post: operations["post_api_v3_admin_credit_settlements"];
+        delete?: never;
+        options?: never;
+        head?: never;
+        patch?: never;
+        trace?: never;
+    };
     "/v3/admin/reading-stats": {
         parameters: {
             query?: never;
@@ -36108,6 +36224,391 @@ export interface operations {
             422: components["responses"]["ProblemValidation"];
         };
     };
+    get_api_v3_admin_credit_accounts: {
+        parameters: {
+            query?: {
+                /** @description 每页数量,最大 100 */
+                per_page?: number;
+                /** @description 账号类型 */
+                "filter[account_type]"?: "user" | "guest";
+                /** @description 登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配 */
+                "filter[q]"?: string;
+                /** @description 页码 */
+                page?: number;
+            };
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
+                            account_id?: string;
+                            user?: {
+                                id?: string;
+                                nickName?: string;
+                                userName?: string;
+                                realName?: string;
+                                sn?: number;
+                                avatar?: string;
+                                roles?: string[];
+                            } | null;
+                            earned_balance?: number;
+                            earned_total?: number;
+                            adjusted_total?: number;
+                            spent_total?: number;
+                            free_used_today?: number;
+                            daily_free?: number;
+                            last_activity_at?: string | null;
+                        }[];
+                        meta?: components["schemas"]["PaginationMeta"];
+                    };
+                };
+            };
+            401: components["responses"]["ProblemUnauthorized"];
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
+    post_api_v3_admin_credit_adjustments: {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody: {
+            content: {
+                "application/json": {
+                    /** @description 加减多少积分,非零,绝对值最大 1000000 */
+                    delta: number;
+                    /** @description 用户 uuid、用户名或邮箱 */
+                    user: string;
+                    /** @description 原因(记进流水备注) */
+                    note: string;
+                    /** @description 调整单号(uuid),防重复提交;不给由服务端生成 */
+                    ref?: string;
+                };
+            };
+        };
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
+                            account_id?: string;
+                            user?: {
+                                id?: string;
+                                nickName?: string;
+                                userName?: string;
+                                realName?: string;
+                                sn?: number;
+                                avatar?: string;
+                                roles?: string[];
+                            } | null;
+                            delta?: number;
+                            /** @enum {string} */
+                            kind?: "earn" | "spend" | "refund" | "adjust";
+                            /** @enum {string} */
+                            bucket?: "free" | "earned";
+                            /** @enum {string} */
+                            source?: "reading" | "editing" | "agent_run" | "admin";
+                            ref?: string;
+                            day?: string;
+                            policy_version?: number;
+                            client_ip?: string | null;
+                            note?: string | null;
+                            operator?: {
+                                id?: string;
+                                nickName?: string;
+                                userName?: string;
+                                realName?: string;
+                                sn?: number;
+                                avatar?: string;
+                                roles?: string[];
+                            } | null;
+                            created_at?: string;
+                            updated_at?: string;
+                        };
+                        meta?: {
+                            /** @description 这次是否新入账 */
+                            created?: boolean;
+                            /** @description 该用户调整后的积分余额 */
+                            earned_balance?: number;
+                        };
+                    };
+                };
+            };
+            /** @description 新入账。响应体与 200 同形(200 是同一 ref 已经入账过,返回原来那条) */
+            201: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
+                            account_id?: string;
+                            user?: {
+                                id?: string;
+                                nickName?: string;
+                                userName?: string;
+                                realName?: string;
+                                sn?: number;
+                                avatar?: string;
+                                roles?: string[];
+                            } | null;
+                            delta?: number;
+                            /** @enum {string} */
+                            kind?: "earn" | "spend" | "refund" | "adjust";
+                            /** @enum {string} */
+                            bucket?: "free" | "earned";
+                            /** @enum {string} */
+                            source?: "reading" | "editing" | "agent_run" | "admin";
+                            ref?: string;
+                            day?: string;
+                            policy_version?: number;
+                            client_ip?: string | null;
+                            note?: string | null;
+                            operator?: {
+                                id?: string;
+                                nickName?: string;
+                                userName?: string;
+                                realName?: string;
+                                sn?: number;
+                                avatar?: string;
+                                roles?: string[];
+                            } | null;
+                            created_at?: string;
+                            updated_at?: string;
+                        };
+                        meta?: {
+                            /** @description 这次是否新入账 */
+                            created?: boolean;
+                            /** @description 该用户调整后的积分余额 */
+                            earned_balance?: number;
+                        };
+                    };
+                };
+            };
+            401: components["responses"]["ProblemUnauthorized"];
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
+    get_api_v3_admin_credit_ledger: {
+        parameters: {
+            query?: {
+                /** @description 每页数量,最大 100 */
+                per_page?: number;
+                /** @description 账号类型;给 account_id 时必填 */
+                "filter[account_type]"?: "user" | "guest";
+                /** @description 账号 id(用户 uuid 或游客设备 id) */
+                "filter[account_id]"?: string;
+                /** @description 流水类型 */
+                "filter[kind]"?: "earn" | "spend" | "refund" | "adjust";
+                /** @description 池子:free 每日赠送 / earned 积分余额 */
+                "filter[bucket]"?: "free" | "earned";
+                /** @description 来源 */
+                "filter[source]"?: "reading" | "editing" | "agent_run" | "admin";
+                /** @description 起始日(UTC,Y-m-d,按流水归属日) */
+                "filter[from]"?: string;
+                /** @description 结束日(UTC,Y-m-d,含当天) */
+                "filter[to]"?: string;
+                /** @description 页码 */
+                page?: number;
+            };
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
+                            account_id?: string;
+                            user?: {
+                                id?: string;
+                                nickName?: string;
+                                userName?: string;
+                                realName?: string;
+                                sn?: number;
+                                avatar?: string;
+                                roles?: string[];
+                            } | null;
+                            delta?: number;
+                            /** @enum {string} */
+                            kind?: "earn" | "spend" | "refund" | "adjust";
+                            /** @enum {string} */
+                            bucket?: "free" | "earned";
+                            /** @enum {string} */
+                            source?: "reading" | "editing" | "agent_run" | "admin";
+                            ref?: string;
+                            day?: string;
+                            policy_version?: number;
+                            client_ip?: string | null;
+                            note?: string | null;
+                            operator?: {
+                                id?: string;
+                                nickName?: string;
+                                userName?: string;
+                                realName?: string;
+                                sn?: number;
+                                avatar?: string;
+                                roles?: string[];
+                            } | null;
+                            created_at?: string;
+                            updated_at?: string;
+                        }[];
+                        meta?: components["schemas"]["PaginationMeta"];
+                    };
+                };
+            };
+            401: components["responses"]["ProblemUnauthorized"];
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
+    get_api_v3_admin_credit_overview: {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody?: never;
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            today?: string;
+                            earn_since?: string;
+                            policy_version?: number;
+                            policy?: Record<string, never>;
+                            totals?: {
+                                user_accounts?: number;
+                                guest_accounts?: number;
+                                outstanding_balance?: number;
+                                earned_total?: number;
+                                adjusted_total?: number;
+                                spent_today?: number;
+                            };
+                            recent_days?: {
+                                day?: string;
+                                users?: number;
+                                reading?: number;
+                                editing?: number;
+                            }[];
+                            last_settlement?: {
+                                mode?: string;
+                                from?: string;
+                                to?: string;
+                                users?: number;
+                                pairs?: number;
+                                trigger?: string;
+                                operator?: string;
+                                ran_at?: string;
+                                seconds?: number;
+                            } | null;
+                        };
+                    };
+                };
+            };
+            401: components["responses"]["ProblemUnauthorized"];
+        };
+    };
+    post_api_v3_admin_credit_settlements: {
+        parameters: {
+            query?: never;
+            header?: never;
+            path?: never;
+            cookie?: never;
+        };
+        requestBody?: {
+            content: {
+                "application/json": {
+                    /** @description 只重算这一天(UTC,Y-m-d),不早于积分上线日、不晚于今天 */
+                    date?: string;
+                };
+            };
+        };
+        responses: {
+            /** @description 成功 */
+            200: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            /** @enum {string} */
+                            mode?: "day" | "missing";
+                            from?: string;
+                            to?: string;
+                            users?: number;
+                            pairs?: number | null;
+                            /** @enum {string} */
+                            trigger?: "cli" | "admin";
+                            operator?: string | null;
+                            ran_at?: string;
+                            seconds?: number;
+                        };
+                    };
+                };
+            };
+            /** @description 结算完成。响应体与 200 同形 */
+            201: {
+                headers: {
+                    [name: string]: unknown;
+                };
+                content: {
+                    "application/json": {
+                        data?: {
+                            /** @enum {string} */
+                            mode?: "day" | "missing";
+                            from?: string;
+                            to?: string;
+                            users?: number;
+                            pairs?: number | null;
+                            /** @enum {string} */
+                            trigger?: "cli" | "admin";
+                            operator?: string | null;
+                            ran_at?: string;
+                            seconds?: number;
+                        };
+                    };
+                };
+            };
+            401: components["responses"]["ProblemUnauthorized"];
+            422: components["responses"]["ProblemValidation"];
+        };
+    };
     get_api_v3_admin_reading_stats: {
         parameters: {
             query?: {

+ 154 - 0
dashboard-v6/src/features/admin-credits/CreditAccountTable.tsx

@@ -0,0 +1,154 @@
+// src/features/admin-credits/CreditAccountTable.tsx
+/**
+ * 有积分流水的账号一览:余额、累计赚取 / 调整 / 消耗、今天用掉的赠送额度。
+ * 点一行看这个账号的流水;登录用户可直接加减积分。
+ */
+import { useState } from "react";
+import { Button, Drawer, Input, Table, Tag, Tooltip, Typography } from "antd";
+import type { ColumnsType } from "antd/es/table";
+import dayjs from "dayjs";
+import type { CreditAccount } from "../../api/adminCredits";
+import { useCreditAccounts } from "../../hooks/useAdminCredits";
+import { useT } from "../admin-stats/helpers";
+import CreditLedgerTable from "./CreditLedgerTable";
+
+interface Props {
+  version: number;
+  onAdjust: (account: CreditAccount) => void;
+}
+
+const accountName = (r: CreditAccount) => r.user?.nickName ?? (r.account_id ?? "").slice(0, 8);
+
+const CreditAccountTable = ({ version, onAdjust }: Props) => {
+  const t = useT();
+  const [page, setPage] = useState(1);
+  const [q, setQ] = useState("");
+  const [type, setType] = useState<"user" | "guest">();
+  const [selected, setSelected] = useState<CreditAccount | null>(null);
+  const { data, loading } = useCreditAccounts(
+    {
+      page,
+      per_page: 20,
+      ...(q ? { "filter[q]": q } : {}),
+      ...(type ? { "filter[account_type]": type } : {}),
+    },
+    version,
+  );
+
+  const columns: ColumnsType<CreditAccount> = [
+    {
+      title: t("admin.credits.account"),
+      dataIndex: "account_id",
+      filters: (["user", "guest"] as const).map((v) => ({ value: v, text: t(`admin.stats.account.${v}`) })),
+      filterMultiple: false,
+      render: (_: string, r) =>
+        r.user ? (
+          <span>
+            <Tag color="blue">{r.user.nickName}</Tag>
+            <Typography.Text type="secondary">@{r.user.userName}</Typography.Text>
+          </span>
+        ) : (
+          <Tooltip title={r.account_id}>
+            <Tag>{t("admin.stats.runs.guest")}</Tag>
+            <Typography.Text type="secondary" code>
+              {(r.account_id ?? "").slice(0, 8)}
+            </Typography.Text>
+          </Tooltip>
+        ),
+    },
+    {
+      title: <Tooltip title={t("admin.credits.balance.tip")}>{t("admin.credits.balance")}</Tooltip>,
+      dataIndex: "earned_balance",
+      width: 100,
+      align: "right",
+      render: (v: number, r) => (r.account_type === "user" ? <Typography.Text strong>{v}</Typography.Text> : "—"),
+    },
+    { title: t("admin.credits.earned"), dataIndex: "earned_total", width: 100, align: "right" },
+    { title: t("admin.credits.adjusted"), dataIndex: "adjusted_total", width: 100, align: "right" },
+    { title: t("admin.credits.spent"), dataIndex: "spent_total", width: 100, align: "right" },
+    {
+      title: <Tooltip title={t("admin.credits.free_today.tip")}>{t("admin.credits.free_today")}</Tooltip>,
+      dataIndex: "free_used_today",
+      width: 120,
+      align: "right",
+      render: (v: number, r) => `${v} / ${r.daily_free}`,
+    },
+    {
+      title: t("admin.credits.last_activity"),
+      dataIndex: "last_activity_at",
+      width: 120,
+      render: (v?: string | null) => (v ? dayjs(v).format("MM-DD HH:mm") : "—"),
+    },
+    {
+      title: "",
+      key: "actions",
+      width: 90,
+      render: (_, r) =>
+        r.account_type === "user" ? (
+          <Button
+            size="small"
+            onClick={(e) => {
+              e.stopPropagation();
+              onAdjust(r);
+            }}
+          >
+            {t("admin.credits.adjust.short")}
+          </Button>
+        ) : null,
+    },
+  ];
+
+  return (
+    <>
+      <Input.Search
+        allowClear
+        placeholder={t("admin.credits.search")}
+        onSearch={(v) => {
+          setQ(v.trim());
+          setPage(1);
+        }}
+        style={{ width: 280, maxWidth: "100%", marginBottom: 8 }}
+      />
+      <Table<CreditAccount>
+        size="small"
+        rowKey={(r) => `${r.account_type}:${r.account_id}`}
+        columns={columns}
+        dataSource={data?.data ?? []}
+        loading={loading}
+        scroll={{ x: 900 }}
+        pagination={{
+          current: page,
+          pageSize: 20,
+          total: data?.meta?.total ?? 0,
+          showSizeChanger: false,
+          onChange: setPage,
+        }}
+        onChange={(_, f, __, extra) => {
+          if (extra.action !== "filter") return;
+          setType((f.account_id?.[0] as "user" | "guest") ?? undefined);
+          setPage(1);
+        }}
+        onRow={(r) => ({ onClick: () => setSelected(r), style: { cursor: "pointer" } })}
+      />
+      <Drawer
+        title={selected ? t("admin.credits.ledger.of", { name: accountName(selected) }) : ""}
+        open={!!selected}
+        onClose={() => setSelected(null)}
+        size={1040}
+        extra={
+          selected?.account_type === "user" && (
+            <Button type="primary" onClick={() => onAdjust(selected)}>
+              {t("admin.credits.adjust.short")}
+            </Button>
+          )
+        }
+      >
+        {selected?.account_type && selected.account_id && (
+          <CreditLedgerTable account={{ type: selected.account_type, id: selected.account_id }} version={version} />
+        )}
+      </Drawer>
+    </>
+  );
+};
+
+export default CreditAccountTable;

+ 101 - 0
dashboard-v6/src/features/admin-credits/CreditAdjustModal.tsx

@@ -0,0 +1,101 @@
+// src/features/admin-credits/CreditAdjustModal.tsx
+/**
+ * 手工加减积分。用户用 UserSelect 按用户名 / 昵称搜索选择(从账号表里点「加积分」会预填、不可改)。
+ * 每次打开生成一个 ref:网络重试或连点提交只入账一次(后端按 ref 幂等)。
+ */
+import { useEffect, useState } from "react";
+import { Alert, Form, Input, InputNumber, Modal, message } from "antd";
+import { adjustCredits } from "../../api/adminCredits";
+import { fieldErrorsOf } from "../../api/error";
+import { useT } from "../admin-stats/helpers";
+import UserSelect from "../../components/users/UserSelect";
+
+interface Values {
+  user: string;
+  delta: number;
+  note: string;
+}
+
+interface Props {
+  open: boolean;
+  /** 预填的用户(uuid);为空时手填 */
+  user?: string;
+  /** 预填时显示的名字 */
+  userLabel?: string;
+  onClose: () => void;
+  onDone: () => void;
+}
+
+const CreditAdjustModal = ({ open, user, userLabel, onClose, onDone }: Props) => {
+  const t = useT();
+  const [form] = Form.useForm<Values>();
+  const [saving, setSaving] = useState(false);
+  const [ref, setRef] = useState(() => crypto.randomUUID());
+  const delta = Form.useWatch("delta", form);
+  // 每次打开换一个 ref。表单随弹窗销毁重建,初值走 initialValues——不要在 afterOpenChange 里重置,
+  // 那要等打开动画结束,期间已经输入的内容会被清掉
+  useEffect(() => {
+    if (open) setRef(crypto.randomUUID());
+  }, [open]);
+
+  const submit = async () => {
+    const values = await form.validateFields();
+    setSaving(true);
+    try {
+      const res = await adjustCredits({ ...values, ref });
+      message.success(
+        res.meta?.created
+          ? t("admin.credits.adjust.done", { balance: res.meta?.earned_balance ?? 0 })
+          : t("admin.credits.adjust.duplicate"),
+      );
+      onDone();
+      onClose();
+    } catch (e) {
+      const fields = fieldErrorsOf(e);
+      if (fields) {
+        form.setFields(Object.entries(fields).map(([name, errors]) => ({ name: name as keyof Values, errors })));
+      }
+    } finally {
+      setSaving(false);
+    }
+  };
+
+  return (
+    <Modal
+      open={open}
+      title={t("admin.credits.adjust.title")}
+      okText={t("admin.credits.adjust.submit")}
+      confirmLoading={saving}
+      onOk={submit}
+      onCancel={onClose}
+      destroyOnHidden
+    >
+      <Form form={form} layout="vertical" preserve={false} initialValues={user ? { user } : undefined}>
+        {user ? (
+          <Form.Item name="user" label={t("admin.credits.adjust.user")} extra={userLabel} rules={[{ required: true }]}>
+            <Input disabled />
+          </Form.Item>
+        ) : (
+          <UserSelect name="user" width="xl" />
+        )}
+        <Form.Item
+          name="delta"
+          label={t("admin.credits.adjust.delta")}
+          extra={t("admin.credits.adjust.delta.tip")}
+          rules={[
+            { required: true },
+            { validator: (_, v) => (v === 0 ? Promise.reject(new Error(t("admin.credits.adjust.delta.zero"))) : Promise.resolve()) },
+          ]}
+        >
+          <InputNumber precision={0} min={-1000000} max={1000000} style={{ width: "100%" }} />
+        </Form.Item>
+        <Form.Item name="note" label={t("admin.credits.adjust.note")} rules={[{ required: true, whitespace: true, max: 255 }]}>
+          <Input.TextArea rows={2} placeholder={t("admin.credits.adjust.note.placeholder")} />
+        </Form.Item>
+        {delta != null && delta < 0 && <Alert type="warning" showIcon message={t("admin.credits.adjust.negative")} />}
+      </Form>
+    </Modal>
+  );
+};
+
+export default CreditAdjustModal;

+ 61 - 0
dashboard-v6/src/features/admin-credits/CreditAdmin.tsx

@@ -0,0 +1,61 @@
+// src/features/admin-credits/CreditAdmin.tsx
+/**
+ * 管理后台 · AI 对话积分:概览与结算任务、账号一览、全站流水,右上角手工加减积分。
+ * 数据来自 /v3/admin/credit-*(仅 root / administrator)。加减或结算之后 version + 1,各块一起重取。
+ */
+import { useState } from "react";
+import { Button, Card, Space, Tabs, Typography } from "antd";
+import { PlusOutlined } from "@ant-design/icons";
+import type { CreditAccount } from "../../api/adminCredits";
+import { useCreditOverview } from "../../hooks/useAdminCredits";
+import { useT } from "../admin-stats/helpers";
+import CreditAccountTable from "./CreditAccountTable";
+import CreditAdjustModal from "./CreditAdjustModal";
+import CreditLedgerTable from "./CreditLedgerTable";
+import CreditOverview from "./CreditOverview";
+
+const CreditAdmin = () => {
+  const t = useT();
+  const [version, setVersion] = useState(0);
+  const [adjusting, setAdjusting] = useState<{ open: boolean; account?: CreditAccount }>({ open: false });
+  const overview = useCreditOverview(version);
+  const bump = () => setVersion((v) => v + 1);
+
+  return (
+    <Space orientation="vertical" size="middle" style={{ width: "100%" }}>
+      <Space style={{ width: "100%", justifyContent: "space-between" }} wrap>
+        <Typography.Title level={4} style={{ margin: 0 }}>
+          {t("admin.menu.credits")}
+        </Typography.Title>
+        <Button type="primary" icon={<PlusOutlined />} onClick={() => setAdjusting({ open: true })}>
+          {t("admin.credits.adjust.title")}
+        </Button>
+      </Space>
+
+      <CreditOverview data={overview.data} loading={overview.loading} onSettled={bump} />
+
+      <Card size="small">
+        <Tabs
+          items={[
+            {
+              key: "accounts",
+              label: t("admin.credits.tab.accounts"),
+              children: <CreditAccountTable version={version} onAdjust={(account) => setAdjusting({ open: true, account })} />,
+            },
+            { key: "ledger", label: t("admin.credits.tab.ledger"), children: <CreditLedgerTable version={version} /> },
+          ]}
+        />
+      </Card>
+
+      <CreditAdjustModal
+        open={adjusting.open}
+        user={adjusting.account?.account_id}
+        userLabel={adjusting.account?.user ? `${adjusting.account.user.nickName} @${adjusting.account.user.userName}` : undefined}
+        onClose={() => setAdjusting({ open: false })}
+        onDone={bump}
+      />
+    </Space>
+  );
+};
+
+export default CreditAdmin;

+ 164 - 0
dashboard-v6/src/features/admin-credits/CreditLedgerTable.tsx

@@ -0,0 +1,164 @@
+// src/features/admin-credits/CreditLedgerTable.tsx
+/**
+ * 积分流水:最新的在前。给了 account 就只看这个账号(账号抽屉里用),否则是全站流水,可按类型 / 来源 / 日期筛选。
+ * 提问扣费那几行点「查看」打开研究过程(复用 AI 对话统计的抽屉)。
+ */
+import { useState } from "react";
+import { Button, DatePicker, Space, Table, Tag, Tooltip, Typography } from "antd";
+import type { ColumnsType } from "antd/es/table";
+import { UserOutlined } from "@ant-design/icons";
+import dayjs, { type Dayjs } from "dayjs";
+import type { CreditLedgerEntry, CreditLedgerQuery } from "../../api/adminCredits";
+import { useCreditLedger } from "../../hooks/useAdminCredits";
+import AgentRunDrawer from "../admin-stats/AgentRunDrawer";
+import { useT } from "../admin-stats/helpers";
+
+const KIND_COLOR: Record<string, string> = { earn: "green", spend: "orange", refund: "blue", adjust: "purple" };
+const KINDS = ["earn", "spend", "refund", "adjust"] as const;
+const SOURCES = ["reading", "editing", "agent_run", "admin"] as const;
+
+interface Props {
+  account?: { type: "user" | "guest"; id: string };
+  version: number;
+}
+
+const CreditLedgerTable = ({ account, version }: Props) => {
+  const t = useT();
+  const [page, setPage] = useState(1);
+  const [kind, setKind] = useState<(typeof KINDS)[number]>();
+  const [source, setSource] = useState<(typeof SOURCES)[number]>();
+  const [range, setRange] = useState<[Dayjs, Dayjs] | null>(null);
+  const [runId, setRunId] = useState<string | null>(null);
+  const query: CreditLedgerQuery = {
+    page,
+    per_page: 20,
+    ...(account ? { "filter[account_type]": account.type, "filter[account_id]": account.id } : {}),
+    ...(kind ? { "filter[kind]": kind } : {}),
+    ...(source ? { "filter[source]": source } : {}),
+    ...(range ? { "filter[from]": range[0].format("YYYY-MM-DD"), "filter[to]": range[1].format("YYYY-MM-DD") } : {}),
+  };
+  const { data, loading } = useCreditLedger(query, version);
+
+  const columns: ColumnsType<CreditLedgerEntry> = [
+    {
+      title: t("admin.credits.ledger.time"),
+      dataIndex: "created_at",
+      width: 130,
+      render: (v: string, r) => (
+        <Tooltip title={`${t("admin.credits.ledger.day")} ${r.day} (UTC)`}>{dayjs(v).format("MM-DD HH:mm")}</Tooltip>
+      ),
+    },
+    ...(account
+      ? []
+      : [
+          {
+            title: t("admin.credits.account"),
+            dataIndex: "account_id",
+            width: 150,
+            render: (_: string, r: CreditLedgerEntry) =>
+              r.user ? (
+                <Tag color="blue">{r.user.nickName}</Tag>
+              ) : (
+                <Tooltip title={`${r.account_id} · ${r.client_ip ?? ""}`}>
+                  <Tag>{t("admin.stats.runs.guest")}</Tag>
+                </Tooltip>
+              ),
+          },
+        ]),
+    {
+      title: t("admin.credits.ledger.delta"),
+      dataIndex: "delta",
+      width: 90,
+      align: "right",
+      render: (v: number) => (
+        <Typography.Text type={v < 0 ? "danger" : "success"} strong>
+          {v > 0 ? `+${v}` : v}
+        </Typography.Text>
+      ),
+    },
+    {
+      title: t("admin.credits.ledger.kind"),
+      dataIndex: "kind",
+      width: 90,
+      filters: KINDS.map((v) => ({ value: v, text: t(`admin.credits.kind.${v}`) })),
+      filterMultiple: false,
+      render: (v: string) => <Tag color={KIND_COLOR[v]}>{t(`admin.credits.kind.${v}`)}</Tag>,
+    },
+    {
+      title: t("admin.credits.ledger.bucket"),
+      dataIndex: "bucket",
+      width: 100,
+      render: (v: string) => t(`admin.credits.bucket.${v}`),
+    },
+    {
+      title: t("admin.credits.ledger.source"),
+      dataIndex: "source",
+      width: 110,
+      filters: SOURCES.map((v) => ({ value: v, text: t(`admin.credits.source.${v}`) })),
+      filterMultiple: false,
+      render: (v: string) => t(`admin.credits.source.${v}`),
+    },
+    {
+      title: t("admin.credits.ledger.note"),
+      dataIndex: "note",
+      ellipsis: true,
+      render: (_: string, r) => (
+        <Space size={4} wrap>
+          {r.operator && (
+            <Tooltip title={t("admin.credits.ledger.operator")}>
+              <Tag icon={<UserOutlined />}>{r.operator.nickName}</Tag>
+            </Tooltip>
+          )}
+          {r.note && <span>{r.note === "deep" ? t("admin.credits.ledger.deep") : r.note}</span>}
+          {r.source === "agent_run" && (
+            <Button size="small" type="link" onClick={() => setRunId(r.ref ?? null)}>
+              {t("admin.credits.ledger.run")}
+            </Button>
+          )}
+        </Space>
+      ),
+    },
+  ];
+
+  return (
+    <>
+      <Space style={{ marginBottom: 8 }} wrap>
+        <DatePicker.RangePicker
+          value={range}
+          allowClear
+          onChange={(v) => {
+            setRange(v && v[0] && v[1] ? [v[0], v[1]] : null);
+            setPage(1);
+          }}
+        />
+        <Typography.Text type="secondary" style={{ fontSize: 12 }}>
+          {t("admin.credits.ledger.utc")}
+        </Typography.Text>
+      </Space>
+      <Table<CreditLedgerEntry>
+        size="small"
+        rowKey={(r) => `${r.account_type}:${r.account_id}:${r.source}:${r.ref}:${r.kind}:${r.bucket}`}
+        columns={columns}
+        dataSource={data?.data ?? []}
+        loading={loading}
+        scroll={{ x: 800 }}
+        pagination={{
+          current: page,
+          pageSize: 20,
+          total: data?.meta?.total ?? 0,
+          showSizeChanger: false,
+          onChange: setPage,
+        }}
+        onChange={(_, f, __, extra) => {
+          if (extra.action !== "filter") return;
+          setKind((f.kind?.[0] as (typeof KINDS)[number]) ?? undefined);
+          setSource((f.source?.[0] as (typeof SOURCES)[number]) ?? undefined);
+          setPage(1);
+        }}
+      />
+      <AgentRunDrawer runId={runId} onClose={() => setRunId(null)} />
+    </>
+  );
+};
+
+export default CreditLedgerTable;

+ 189 - 0
dashboard-v6/src/features/admin-credits/CreditOverview.tsx

@@ -0,0 +1,189 @@
+// src/features/admin-credits/CreditOverview.tsx
+/**
+ * 积分概览 + 结算任务面板。
+ *
+ * 每日任务 `credits:settle-activity` 出问题时,在这里手工补:
+ * - 「补齐漏结算」与每日任务完全相同:从积分上线日到昨天,找出有活动却没结清的「用户 + 日」重新结算;
+ * - 「重算某一天」按当前策略重算那天所有用户。
+ * 两者都可以重复执行:同一用户同一天的积分是覆盖不是累加,不会重复入账。
+ */
+import { useState } from "react";
+import { Alert, Button, Card, Col, DatePicker, Descriptions, Popconfirm, Row, Space, Statistic, Table, Tag, Typography, message } from "antd";
+import { SyncOutlined } from "@ant-design/icons";
+import dayjs, { type Dayjs } from "dayjs";
+import { settleCredits, type CreditOverview as Overview, type CreditSettlement } from "../../api/adminCredits";
+import { useT } from "../admin-stats/helpers";
+
+interface Props {
+  data: Overview | null;
+  loading: boolean;
+  onSettled: () => void;
+}
+
+type Day = NonNullable<Overview["recent_days"]>[number];
+
+const CreditOverview = ({ data, loading, onSettled }: Props) => {
+  const t = useT();
+  const [running, setRunning] = useState<"missing" | "day" | null>(null);
+  const [day, setDay] = useState<Dayjs | null>(null);
+
+  const run = async (mode: "missing" | "day") => {
+    setRunning(mode);
+    try {
+      const r = await settleCredits(mode === "day" && day ? { date: day.format("YYYY-MM-DD") } : {});
+      message.success(
+        r.mode === "day"
+          ? t("admin.credits.settle.done.day", { day: r.from, users: r.users })
+          : t("admin.credits.settle.done.missing", { users: r.users, pairs: r.pairs ?? 0 }),
+      );
+      onSettled();
+    } finally {
+      setRunning(null);
+    }
+  };
+
+  const last = data?.last_settlement as CreditSettlement | null | undefined;
+  const totals = data?.totals;
+  const policy = data?.policy as
+    | { daily_free?: { user?: number; guest?: number }; cost?: { normal?: number; deep?: number } }
+    | undefined;
+  // 今天之前、某天没有任何人拿到积分:每日任务可能没跑(也可能那天确实没人读经,自己判断)
+  const today = data?.today;
+  const empty = (r: Day) => r.day !== today && r.users === 0;
+
+  return (
+    <Space orientation="vertical" size="middle" style={{ width: "100%" }}>
+      <Row gutter={[12, 12]}>
+        {(
+          [
+            ["outstanding_balance", "admin.credits.total.balance"],
+            ["earned_total", "admin.credits.total.earned"],
+            ["adjusted_total", "admin.credits.total.adjusted"],
+            ["spent_today", "admin.credits.total.spent_today"],
+            ["user_accounts", "admin.credits.total.users"],
+            ["guest_accounts", "admin.credits.total.guests"],
+          ] as const
+        ).map(([key, label]) => (
+          <Col key={key} xs={12} sm={8} lg={4}>
+            <Card size="small" loading={loading}>
+              <Statistic title={t(label)} value={totals?.[key] ?? 0} />
+            </Card>
+          </Col>
+        ))}
+      </Row>
+
+      <Card
+        size="small"
+        title={t("admin.credits.settle.title")}
+        loading={loading && !data}
+        extra={
+          policy && (
+            <Typography.Text type="secondary" style={{ fontSize: 12 }}>
+              {t("admin.credits.policy", {
+                version: data?.policy_version ?? "",
+                user: policy.daily_free?.user ?? 0,
+                guest: policy.daily_free?.guest ?? 0,
+                normal: policy.cost?.normal ?? 0,
+                deep: policy.cost?.deep ?? 0,
+              })}
+            </Typography.Text>
+          )
+        }
+      >
+        <Row gutter={[24, 16]}>
+          <Col xs={24} lg={10}>
+            <Descriptions size="small" column={1} title={t("admin.credits.settle.last")}>
+              {last ? (
+                <>
+                  <Descriptions.Item label={t("admin.credits.settle.ran_at")}>
+                    {dayjs(last.ran_at).format("YYYY-MM-DD HH:mm:ss")}
+                  </Descriptions.Item>
+                  <Descriptions.Item label={t("admin.credits.settle.trigger")}>
+                    {last.trigger === "cli" ? (
+                      <Tag>{t("admin.credits.settle.trigger.cli")}</Tag>
+                    ) : (
+                      <Tag color="purple">{t("admin.credits.settle.trigger.admin", { name: last.operator ?? "" })}</Tag>
+                    )}
+                  </Descriptions.Item>
+                  <Descriptions.Item label={t("admin.credits.settle.result")}>
+                    {last.mode === "day"
+                      ? t("admin.credits.settle.done.day", { day: last.from, users: last.users })
+                      : t("admin.credits.settle.done.missing", { users: last.users, pairs: last.pairs ?? 0 })}
+                    <Typography.Text type="secondary"> · {last.seconds}s</Typography.Text>
+                  </Descriptions.Item>
+                </>
+              ) : (
+                <Descriptions.Item>
+                  <Typography.Text type="secondary">{t("admin.credits.settle.never")}</Typography.Text>
+                </Descriptions.Item>
+              )}
+            </Descriptions>
+
+            <Alert type="info" showIcon style={{ margin: "12px 0" }} message={t("admin.credits.settle.safe")} />
+
+            <Space orientation="vertical" style={{ width: "100%" }}>
+              <Popconfirm
+                title={t("admin.credits.settle.missing")}
+                description={t("admin.credits.settle.missing.tip", { since: data?.earn_since ?? "" })}
+                onConfirm={() => run("missing")}
+              >
+                <Button type="primary" icon={<SyncOutlined spin={running === "missing"} />} loading={running === "missing"} block>
+                  {t("admin.credits.settle.missing")}
+                </Button>
+              </Popconfirm>
+              <Space.Compact style={{ width: "100%" }}>
+                <DatePicker
+                  value={day}
+                  onChange={setDay}
+                  style={{ flex: 1 }}
+                  placeholder={t("admin.credits.settle.day.placeholder")}
+                  disabledDate={(d) =>
+                    d.isAfter(dayjs().endOf("day")) || (!!data?.earn_since && d.isBefore(dayjs(data.earn_since), "day"))
+                  }
+                />
+                <Popconfirm
+                  title={t("admin.credits.settle.day")}
+                  description={t("admin.credits.settle.day.tip")}
+                  disabled={!day}
+                  onConfirm={() => run("day")}
+                >
+                  <Button disabled={!day} loading={running === "day"}>
+                    {t("admin.credits.settle.day")}
+                  </Button>
+                </Popconfirm>
+              </Space.Compact>
+            </Space>
+          </Col>
+          <Col xs={24} lg={14}>
+            <Typography.Text strong>{t("admin.credits.recent.title")}</Typography.Text>
+            <Table<Day>
+              size="small"
+              rowKey="day"
+              style={{ marginTop: 8 }}
+              pagination={false}
+              dataSource={data?.recent_days ?? []}
+              columns={[
+                {
+                  title: t("admin.credits.recent.day"),
+                  dataIndex: "day",
+                  render: (v: string, r) => (
+                    <Space size={4}>
+                      {v}
+                      {v === today && <Tag>{t("admin.credits.recent.today")}</Tag>}
+                      {empty(r) && <Tag color="warning">{t("admin.credits.recent.empty")}</Tag>}
+                    </Space>
+                  ),
+                },
+                { title: t("admin.credits.recent.users"), dataIndex: "users", align: "right" },
+                { title: t("admin.credits.source.reading"), dataIndex: "reading", align: "right" },
+                { title: t("admin.credits.source.editing"), dataIndex: "editing", align: "right" },
+              ]}
+            />
+          </Col>
+        </Row>
+      </Card>
+    </Space>
+  );
+};
+
+export default CreditOverview;

+ 27 - 0
dashboard-v6/src/hooks/useAdminCredits.ts

@@ -0,0 +1,27 @@
+// src/hooks/useAdminCredits.ts
+/**
+ * 管理后台积分页的数据 hook。参数变了或调了 refresh() 就重新请求,后到的旧结果丢弃
+ * (同 useAdminStats,共用它的 useAsync)。
+ */
+import {
+  getCreditAccounts,
+  getCreditLedger,
+  getCreditOverview,
+  type CreditAccountList,
+  type CreditAccountQuery,
+  type CreditLedgerList,
+  type CreditLedgerQuery,
+  type CreditOverview,
+} from "../api/adminCredits";
+import { useAsync, type AsyncState } from "./useAdminStats";
+
+/** version 变了就重取(加减积分、结算之后由页面递增)。 */
+export const useCreditOverview = (version: number): AsyncState<CreditOverview> =>
+  useAsync(() => getCreditOverview(), String(version));
+
+export const useCreditAccounts = (query: CreditAccountQuery, version: number): AsyncState<CreditAccountList> =>
+  useAsync(() => getCreditAccounts(query), JSON.stringify(query) + version);
+
+/** query 为 null 时不请求(抽屉关着)。 */
+export const useCreditLedger = (query: CreditLedgerQuery | null, version: number): AsyncState<CreditLedgerList> =>
+  useAsync(query ? () => getCreditLedger(query) : null, query ? JSON.stringify(query) + version : "");

+ 2 - 2
dashboard-v6/src/hooks/useAdminStats.ts

@@ -26,14 +26,14 @@ import {
   type ReadingStatsQuery,
 } from "../api/adminStats";
 
-interface AsyncState<T> {
+export interface AsyncState<T> {
   data: T | null;
   loading: boolean;
   error: unknown;
   refresh: () => void;
 }
 
-const useAsync = <T>(load: (() => Promise<T>) | null, key: string): AsyncState<T> => {
+export const useAsync = <T>(load: (() => Promise<T>) | null, key: string): AsyncState<T> => {
   const [data, setData] = useState<T | null>(null);
   const [loading, setLoading] = useState(false);
   const [error, setError] = useState<unknown>(null);

+ 3 - 0
dashboard-v6/src/layouts/admin/index.tsx

@@ -8,6 +8,7 @@ import {
   BarChartOutlined,
   BookOutlined,
   DashboardOutlined,
+  DollarOutlined,
   FontSizeOutlined,
   MailOutlined,
   MenuFoldOutlined,
@@ -39,6 +40,7 @@ const MENU_PATHS = [
   "/admin/users",
   "/admin/invite",
   "/admin/ai-models",
+  "/admin/credits",
 ];
 
 /**
@@ -99,6 +101,7 @@ const AdminLayout = () => {
         { key: "/admin/users", icon: <TeamOutlined />, label: link("/admin/users", "admin.menu.users") },
         { key: "/admin/invite", icon: <MailOutlined />, label: link("/admin/invite", "admin.menu.invite") },
         { key: "/admin/ai-models", icon: <ApiOutlined />, label: link("/admin/ai-models", "admin.menu.ai-models") },
+        { key: "/admin/credits", icon: <DollarOutlined />, label: link("/admin/credits", "admin.menu.credits") },
       ],
     },
   ];

+ 75 - 0
dashboard-v6/src/locales/en-US/admin.ts

@@ -32,6 +32,81 @@ const items = {
   "admin.export": "Export",
   "admin.models.all": "All",
   "admin.models.selected": "Selected",
+  "admin.menu.credits": "AI credits",
+  "admin.credits.tab.accounts": "Accounts",
+  "admin.credits.tab.ledger": "All entries",
+  "admin.credits.account": "Account",
+  "admin.credits.search": "Username / nickname / email, or device ID",
+  "admin.credits.balance": "Balance",
+  "admin.credits.balance.tip": "Credits earned by reading and editing plus manual adjustments, minus questions asked. Never expires. Guests have no balance.",
+  "admin.credits.earned": "Earned",
+  "admin.credits.adjusted": "Adjusted",
+  "admin.credits.spent": "Spent",
+  "admin.credits.free_today": "Free today",
+  "admin.credits.free_today.tip": "Used today (UTC) / daily free allowance; resets at 00:00 UTC",
+  "admin.credits.last_activity": "Last change",
+  "admin.credits.total.balance": "Total user balance",
+  "admin.credits.total.earned": "Earned by settlement",
+  "admin.credits.total.adjusted": "Manually adjusted",
+  "admin.credits.total.spent_today": "Spent today",
+  "admin.credits.total.users": "Users with credits",
+  "admin.credits.total.guests": "Guest devices",
+  "admin.credits.policy": "Policy {version}: daily free user {user} / guest {guest}; {normal} per question, {deep} for deep thinking",
+  "admin.credits.settle.title": "Daily credit settlement",
+  "admin.credits.settle.last": "Last settlement",
+  "admin.credits.settle.ran_at": "Time",
+  "admin.credits.settle.trigger": "Triggered by",
+  "admin.credits.settle.trigger.cli": "Daily task",
+  "admin.credits.settle.trigger.admin": "Manual ({name})",
+  "admin.credits.settle.result": "Result",
+  "admin.credits.settle.never": "No record yet (kept for 30 days)",
+  "admin.credits.settle.safe": "Settlement is safe to repeat: a user's credits for a day are overwritten, never added twice.",
+  "admin.credits.settle.missing": "Settle missing days",
+  "admin.credits.settle.missing.tip": "Same as the daily task: from {since} to yesterday, re-settle every day with reading or editing that was not settled.",
+  "admin.credits.settle.day": "Re-settle this day",
+  "admin.credits.settle.day.tip": "Recompute reading and editing credits of all users for this day (UTC) under the current policy.",
+  "admin.credits.settle.day.placeholder": "Pick a day (UTC)",
+  "admin.credits.settle.done.missing": "Settled {pairs} user-days for {users} users",
+  "admin.credits.settle.done.day": "{day}: settled {users} users",
+  "admin.credits.recent.title": "Credits settled in the last 14 days",
+  "admin.credits.recent.day": "Day (UTC)",
+  "admin.credits.recent.users": "Users credited",
+  "admin.credits.recent.today": "Today",
+  "admin.credits.recent.empty": "Nobody credited",
+  "admin.credits.ledger.of": "Ledger of {name}",
+  "admin.credits.ledger.time": "Time",
+  "admin.credits.ledger.day": "Day",
+  "admin.credits.ledger.delta": "Change",
+  "admin.credits.ledger.kind": "Kind",
+  "admin.credits.ledger.bucket": "Pool",
+  "admin.credits.ledger.source": "Source",
+  "admin.credits.ledger.operator": "Operator",
+  "admin.credits.ledger.note": "Note",
+  "admin.credits.ledger.deep": "Deep thinking",
+  "admin.credits.ledger.run": "View question",
+  "admin.credits.ledger.utc": "Dates filter by the entry's UTC day",
+  "admin.credits.kind.earn": "Earn",
+  "admin.credits.kind.spend": "Spend",
+  "admin.credits.kind.refund": "Refund",
+  "admin.credits.kind.adjust": "Adjust",
+  "admin.credits.bucket.free": "Daily free",
+  "admin.credits.bucket.earned": "Balance",
+  "admin.credits.source.reading": "Reading",
+  "admin.credits.source.editing": "Editing",
+  "admin.credits.source.agent_run": "AI question",
+  "admin.credits.source.admin": "Manual",
+  "admin.credits.adjust.title": "Adjust credits",
+  "admin.credits.adjust.short": "Adjust",
+  "admin.credits.adjust.submit": "Confirm",
+  "admin.credits.adjust.user": "User",
+  "admin.credits.adjust.delta": "Credits",
+  "admin.credits.adjust.delta.tip": "Positive adds, negative deducts; goes to the balance, never expires",
+  "admin.credits.adjust.delta.zero": "Cannot be 0",
+  "admin.credits.adjust.note": "Reason",
+  "admin.credits.adjust.note.placeholder": "e.g. settlement task failed on 11-18, re-issuing editing credits",
+  "admin.credits.adjust.negative": "This is a deduction. The balance cannot go below zero.",
+  "admin.credits.adjust.done": "Done. Balance is now {balance}",
+  "admin.credits.adjust.duplicate": "This submission was already recorded; nothing was added twice",
 };
 
 export default items;

+ 75 - 0
dashboard-v6/src/locales/zh-Hans/admin.ts

@@ -32,6 +32,81 @@ const items = {
   "admin.export": "导出",
   "admin.models.all": "全部",
   "admin.models.selected": "已选",
+  "admin.menu.credits": "AI 积分",
+  "admin.credits.tab.accounts": "账号",
+  "admin.credits.tab.ledger": "全部流水",
+  "admin.credits.account": "账号",
+  "admin.credits.search": "用户名 / 昵称 / 邮箱,或设备 ID",
+  "admin.credits.balance": "积分余额",
+  "admin.credits.balance.tip": "读经、编辑赚来的积分加手工调整,减去提问消耗;不过期。游客没有积分余额。",
+  "admin.credits.earned": "累计赚取",
+  "admin.credits.adjusted": "手工调整",
+  "admin.credits.spent": "累计消耗",
+  "admin.credits.free_today": "今日赠送",
+  "admin.credits.free_today.tip": "今天(UTC)已用 / 每日赠送额度,每天 0 点(UTC)重置",
+  "admin.credits.last_activity": "最近变动",
+  "admin.credits.total.balance": "用户积分余额合计",
+  "admin.credits.total.earned": "累计结算赚取",
+  "admin.credits.total.adjusted": "累计手工调整",
+  "admin.credits.total.spent_today": "今日消耗",
+  "admin.credits.total.users": "有积分的用户",
+  "admin.credits.total.guests": "游客设备",
+  "admin.credits.policy": "策略 {version}:每日赠送 用户 {user} / 游客 {guest};每次提问 {normal},深度思考 {deep}",
+  "admin.credits.settle.title": "每日积分结算",
+  "admin.credits.settle.last": "最近一次结算",
+  "admin.credits.settle.ran_at": "时间",
+  "admin.credits.settle.trigger": "触发",
+  "admin.credits.settle.trigger.cli": "每日任务",
+  "admin.credits.settle.trigger.admin": "后台手工({name})",
+  "admin.credits.settle.result": "结果",
+  "admin.credits.settle.never": "还没有记录(记录保留 30 天)",
+  "admin.credits.settle.safe": "结算可以重复执行:同一用户同一天的积分是覆盖,不会重复入账。",
+  "admin.credits.settle.missing": "补齐漏结算",
+  "admin.credits.settle.missing.tip": "与每日任务相同:从 {since} 到昨天,找出有读经 / 编辑却没结清的日子重新结算。",
+  "admin.credits.settle.day": "重算这一天",
+  "admin.credits.settle.day.tip": "按当前策略重算这一天(UTC)所有用户的读经、编辑积分。",
+  "admin.credits.settle.day.placeholder": "选一天(UTC)",
+  "admin.credits.settle.done.missing": "补结算了 {users} 位用户的 {pairs} 个「用户 + 日」",
+  "admin.credits.settle.done.day": "{day}:结算了 {users} 位用户",
+  "admin.credits.recent.title": "最近 14 天结算出的积分",
+  "admin.credits.recent.day": "日期(UTC)",
+  "admin.credits.recent.users": "获得积分人数",
+  "admin.credits.recent.today": "今天",
+  "admin.credits.recent.empty": "无人到账",
+  "admin.credits.ledger.of": "{name} 的积分流水",
+  "admin.credits.ledger.time": "时间",
+  "admin.credits.ledger.day": "归属日",
+  "admin.credits.ledger.delta": "变动",
+  "admin.credits.ledger.kind": "类型",
+  "admin.credits.ledger.bucket": "池子",
+  "admin.credits.ledger.source": "来源",
+  "admin.credits.ledger.operator": "操作人",
+  "admin.credits.ledger.note": "备注",
+  "admin.credits.ledger.deep": "深度思考",
+  "admin.credits.ledger.run": "查看提问",
+  "admin.credits.ledger.utc": "日期按 UTC 的归属日筛选",
+  "admin.credits.kind.earn": "赚取",
+  "admin.credits.kind.spend": "消耗",
+  "admin.credits.kind.refund": "退回",
+  "admin.credits.kind.adjust": "调整",
+  "admin.credits.bucket.free": "每日赠送",
+  "admin.credits.bucket.earned": "积分余额",
+  "admin.credits.source.reading": "读经",
+  "admin.credits.source.editing": "编辑",
+  "admin.credits.source.agent_run": "AI 提问",
+  "admin.credits.source.admin": "手工",
+  "admin.credits.adjust.title": "手工加减积分",
+  "admin.credits.adjust.short": "加减积分",
+  "admin.credits.adjust.submit": "确定",
+  "admin.credits.adjust.user": "用户",
+  "admin.credits.adjust.delta": "积分",
+  "admin.credits.adjust.delta.tip": "正数为加,负数为扣;加到积分余额,不过期",
+  "admin.credits.adjust.delta.zero": "不能为 0",
+  "admin.credits.adjust.note": "原因",
+  "admin.credits.adjust.note.placeholder": "例如:11-18 结算任务故障,补发编辑积分",
+  "admin.credits.adjust.negative": "这是扣减。扣减后余额不能为负。",
+  "admin.credits.adjust.done": "已入账,当前余额 {balance}",
+  "admin.credits.adjust.duplicate": "这次提交已经入账过,没有重复入账",
 };
 
 export default items;

+ 75 - 0
dashboard-v6/src/locales/zh-Hant/admin.ts

@@ -32,6 +32,81 @@ const items = {
   "admin.export": "導出",
   "admin.models.all": "全部",
   "admin.models.selected": "已選",
+  "admin.menu.credits": "AI 積分",
+  "admin.credits.tab.accounts": "帳號",
+  "admin.credits.tab.ledger": "全部流水",
+  "admin.credits.account": "帳號",
+  "admin.credits.search": "用戶名 / 昵稱 / 郵箱,或設備 ID",
+  "admin.credits.balance": "積分餘額",
+  "admin.credits.balance.tip": "讀經、編輯賺來的積分加手工調整,減去提問消耗;不過期。遊客沒有積分餘額。",
+  "admin.credits.earned": "累計賺取",
+  "admin.credits.adjusted": "手工調整",
+  "admin.credits.spent": "累計消耗",
+  "admin.credits.free_today": "今日贈送",
+  "admin.credits.free_today.tip": "今天(UTC)已用 / 每日贈送額度,每天 0 點(UTC)重置",
+  "admin.credits.last_activity": "最近變動",
+  "admin.credits.total.balance": "用戶積分餘額合計",
+  "admin.credits.total.earned": "累計結算賺取",
+  "admin.credits.total.adjusted": "累計手工調整",
+  "admin.credits.total.spent_today": "今日消耗",
+  "admin.credits.total.users": "有積分的用戶",
+  "admin.credits.total.guests": "遊客設備",
+  "admin.credits.policy": "策略 {version}:每日贈送 用戶 {user} / 遊客 {guest};每次提問 {normal},深度思考 {deep}",
+  "admin.credits.settle.title": "每日積分結算",
+  "admin.credits.settle.last": "最近一次結算",
+  "admin.credits.settle.ran_at": "時間",
+  "admin.credits.settle.trigger": "觸發",
+  "admin.credits.settle.trigger.cli": "每日任務",
+  "admin.credits.settle.trigger.admin": "後臺手工({name})",
+  "admin.credits.settle.result": "結果",
+  "admin.credits.settle.never": "還沒有記錄(記錄保留 30 天)",
+  "admin.credits.settle.safe": "結算可以重複執行:同一用戶同一天的積分是覆蓋,不會重複入帳。",
+  "admin.credits.settle.missing": "補齊漏結算",
+  "admin.credits.settle.missing.tip": "與每日任務相同:從 {since} 到昨天,找出有讀經 / 編輯卻沒結清的日子重新結算。",
+  "admin.credits.settle.day": "重算這一天",
+  "admin.credits.settle.day.tip": "按當前策略重算這一天(UTC)所有用戶的讀經、編輯積分。",
+  "admin.credits.settle.day.placeholder": "選一天(UTC)",
+  "admin.credits.settle.done.missing": "補結算了 {users} 位用戶的 {pairs} 個「用戶 + 日」",
+  "admin.credits.settle.done.day": "{day}:結算了 {users} 位用戶",
+  "admin.credits.recent.title": "最近 14 天結算出的積分",
+  "admin.credits.recent.day": "日期(UTC)",
+  "admin.credits.recent.users": "獲得積分人數",
+  "admin.credits.recent.today": "今天",
+  "admin.credits.recent.empty": "無人到帳",
+  "admin.credits.ledger.of": "{name} 的積分流水",
+  "admin.credits.ledger.time": "時間",
+  "admin.credits.ledger.day": "歸屬日",
+  "admin.credits.ledger.delta": "變動",
+  "admin.credits.ledger.kind": "類型",
+  "admin.credits.ledger.bucket": "池子",
+  "admin.credits.ledger.source": "來源",
+  "admin.credits.ledger.operator": "操作人",
+  "admin.credits.ledger.note": "備註",
+  "admin.credits.ledger.deep": "深度思考",
+  "admin.credits.ledger.run": "查看提問",
+  "admin.credits.ledger.utc": "日期按 UTC 的歸屬日篩選",
+  "admin.credits.kind.earn": "賺取",
+  "admin.credits.kind.spend": "消耗",
+  "admin.credits.kind.refund": "退回",
+  "admin.credits.kind.adjust": "調整",
+  "admin.credits.bucket.free": "每日贈送",
+  "admin.credits.bucket.earned": "積分餘額",
+  "admin.credits.source.reading": "讀經",
+  "admin.credits.source.editing": "編輯",
+  "admin.credits.source.agent_run": "AI 提問",
+  "admin.credits.source.admin": "手工",
+  "admin.credits.adjust.title": "手工加減積分",
+  "admin.credits.adjust.short": "加減積分",
+  "admin.credits.adjust.submit": "確定",
+  "admin.credits.adjust.user": "用戶",
+  "admin.credits.adjust.delta": "積分",
+  "admin.credits.adjust.delta.tip": "正數為加,負數為扣;加到積分餘額,不過期",
+  "admin.credits.adjust.delta.zero": "不能為 0",
+  "admin.credits.adjust.note": "原因",
+  "admin.credits.adjust.note.placeholder": "例如:11-18 結算任務故障,補發編輯積分",
+  "admin.credits.adjust.negative": "這是扣減。扣減後餘額不能為負。",
+  "admin.credits.adjust.done": "已入帳,當前餘額 {balance}",
+  "admin.credits.adjust.duplicate": "這次提交已經入帳過,沒有重複入帳",
 };
 
 export default items;

+ 14 - 0
dashboard-v6/src/pages/admin/credits.tsx

@@ -0,0 +1,14 @@
+import { useIntl } from "react-intl";
+import CreditAdmin from "../../features/admin-credits/CreditAdmin";
+
+const Widget = () => {
+  const intl = useIntl();
+  return (
+    <>
+      <title>{intl.formatMessage({ id: "admin.menu.credits" })}</title>
+      <CreditAdmin />
+    </>
+  );
+};
+
+export default Widget;

+ 2 - 0
dashboard-v6/src/routes/adminRoutes.ts

@@ -16,6 +16,7 @@ const Users = lazy(() => import("../pages/admin/users/index"));
 const UsersShow = lazy(() => import("../pages/admin/users/show"));
 const Invite = lazy(() => import("../pages/admin/invite"));
 const AiModels = lazy(() => import("../pages/admin/ai-models"));
+const Credits = lazy(() => import("../pages/admin/credits"));
 
 const adminRoutes: RouteObject[] = [
   { index: true, loader: () => redirect("/admin/stats/reading") },
@@ -56,6 +57,7 @@ const adminRoutes: RouteObject[] = [
   },
   { path: "invite", Component: Invite, handle: { id: "admin.invite", crumb: "invite" } },
   { path: "ai-models", Component: AiModels, handle: { id: "admin.ai-models", crumb: "ai-models" } },
+  { path: "credits", Component: Credits, handle: { id: "admin.credits", crumb: "credits" } },
 ];
 
 export default adminRoutes;

+ 10 - 0
openapi/public/assets/protocol/main.yaml

@@ -759,6 +759,16 @@ paths:
     $ref: ./resources/auto/v3-admin-agent-runs-run.yaml
   /v3/admin/agent-stats:
     $ref: ./resources/auto/v3-admin-agent-stats.yaml
+  /v3/admin/credit-accounts:
+    $ref: ./resources/auto/v3-admin-credit-accounts.yaml
+  /v3/admin/credit-adjustments:
+    $ref: ./resources/auto/v3-admin-credit-adjustments.yaml
+  /v3/admin/credit-ledger:
+    $ref: ./resources/auto/v3-admin-credit-ledger.yaml
+  /v3/admin/credit-overview:
+    $ref: ./resources/auto/v3-admin-credit-overview.yaml
+  /v3/admin/credit-settlements:
+    $ref: ./resources/auto/v3-admin-credit-settlements.yaml
   /v3/admin/reading-stats:
     $ref: ./resources/auto/v3-admin-reading-stats.yaml
   /v3/agent-charges:

+ 88 - 0
openapi/public/assets/protocol/resources/auto/v3-admin-credit-accounts.yaml

@@ -0,0 +1,88 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-admin-credit-accounts.yaml
+get:
+  summary: 列出积分账号
+  tags:
+    - admin
+  operationId: get_api_v3_admin_credit_accounts
+  description: |-
+    有积分流水的账号(登录用户与游客设备),每行是该账号的汇总:积分余额、累计赚取、累计手工调整、
+    累计消耗、今天用掉的赠送额度。最近有动静的在前。没有任何流水的用户不在列表里,
+    但仍可以直接给他加积分(`POST /v3/admin/credit-adjustments`)。
+
+    实现:`V3\AdminCreditAccountController@index`
+  security:
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: per_page
+      in: query
+      schema:
+        type: integer
+        default: 20
+      description: '每页数量,最大 100'
+    -
+      name: 'filter[account_type]'
+      in: query
+      schema:
+        type: string
+        enum:
+          - user
+          - guest
+      description: 账号类型
+    -
+      name: 'filter[q]'
+      in: query
+      schema:
+        type: string
+      description: '登录用户按用户名 / 昵称 / 邮箱模糊匹配,游客按设备 id 前缀匹配'
+    -
+      name: page
+      in: query
+      schema:
+        type: integer
+        default: 1
+      description: 页码
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    account_type:
+                      type: string
+                      enum: [user, guest]
+                    account_id:
+                      type: string
+                    user:
+                      type: object
+                      properties: { id: { type: string }, nickName: { type: string }, userName: { type: string }, realName: { type: string }, sn: { type: integer }, avatar: { type: string }, roles: { type: array, items: { type: string } } }
+                      nullable: true
+                    earned_balance:
+                      type: integer
+                    earned_total:
+                      type: integer
+                    adjusted_total:
+                      type: integer
+                    spent_total:
+                      type: integer
+                    free_used_today:
+                      type: integer
+                    daily_free:
+                      type: integer
+                    last_activity_at:
+                      type: string
+                      nullable: true
+              meta:
+                $ref: '../../main.yaml#/components/schemas/PaginationMeta'
+    401:
+      $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 212 - 0
openapi/public/assets/protocol/resources/auto/v3-admin-credit-adjustments.yaml

@@ -0,0 +1,212 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-admin-credit-adjustments.yaml
+post:
+  summary: 手工加减积分
+  tags:
+    - admin
+  operationId: post_api_v3_admin_credit_adjustments
+  description: |-
+    加到登录用户的积分余额(不过期)。负数为扣减,扣减后余额不能为负。
+    同一 `ref` 只入账一次:重复提交返回原来那条(200),新入账是 201。
+
+    实现:`V3\AdminCreditAdjustmentController@store`
+  security:
+    -
+      bearerAuth: []
+  requestBody:
+    required: true
+    content:
+      application/json:
+        schema:
+          type: object
+          properties:
+            delta:
+              type: integer
+              description: '加减多少积分,非零,绝对值最大 1000000'
+            user:
+              type: string
+              description: '用户 uuid、用户名或邮箱'
+            note:
+              type: string
+              description: 原因(记进流水备注)
+            ref:
+              type: string
+              description: 调整单号(uuid),防重复提交;不给由服务端生成
+          required:
+            - user
+            - delta
+            - note
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: object
+                properties:
+                  account_type:
+                    type: string
+                    enum:
+                      - user
+                      - guest
+                  account_id:
+                    type: string
+                  user:
+                    type: object
+                    properties:
+                      id: { type: string }
+                      nickName: { type: string }
+                      userName: { type: string }
+                      realName: { type: string }
+                      sn: { type: integer }
+                      avatar: { type: string }
+                      roles: { type: array, items: { type: string } }
+                    nullable: true
+                  delta:
+                    type: integer
+                  kind:
+                    type: string
+                    enum:
+                      - earn
+                      - spend
+                      - refund
+                      - adjust
+                  bucket:
+                    type: string
+                    enum:
+                      - free
+                      - earned
+                  source:
+                    type: string
+                    enum:
+                      - reading
+                      - editing
+                      - agent_run
+                      - admin
+                  ref:
+                    type: string
+                  day:
+                    type: string
+                  policy_version:
+                    type: integer
+                  client_ip:
+                    type: string
+                    nullable: true
+                  note:
+                    type: string
+                    nullable: true
+                  operator:
+                    type: object
+                    properties:
+                      id: { type: string }
+                      nickName: { type: string }
+                      userName: { type: string }
+                      realName: { type: string }
+                      sn: { type: integer }
+                      avatar: { type: string }
+                      roles: { type: array, items: { type: string } }
+                    nullable: true
+                  created_at:
+                    type: string
+                  updated_at:
+                    type: string
+              meta:
+                type: object
+                properties:
+                  created:
+                    type: boolean
+                    description: 这次是否新入账
+                  earned_balance:
+                    type: integer
+                    description: 该用户调整后的积分余额
+    201:
+      description: '新入账。响应体与 200 同形(200 是同一 ref 已经入账过,返回原来那条)'
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: object
+                properties:
+                  account_type:
+                    type: string
+                    enum:
+                      - user
+                      - guest
+                  account_id:
+                    type: string
+                  user:
+                    type: object
+                    properties:
+                      id: { type: string }
+                      nickName: { type: string }
+                      userName: { type: string }
+                      realName: { type: string }
+                      sn: { type: integer }
+                      avatar: { type: string }
+                      roles: { type: array, items: { type: string } }
+                    nullable: true
+                  delta:
+                    type: integer
+                  kind:
+                    type: string
+                    enum:
+                      - earn
+                      - spend
+                      - refund
+                      - adjust
+                  bucket:
+                    type: string
+                    enum:
+                      - free
+                      - earned
+                  source:
+                    type: string
+                    enum:
+                      - reading
+                      - editing
+                      - agent_run
+                      - admin
+                  ref:
+                    type: string
+                  day:
+                    type: string
+                  policy_version:
+                    type: integer
+                  client_ip:
+                    type: string
+                    nullable: true
+                  note:
+                    type: string
+                    nullable: true
+                  operator:
+                    type: object
+                    properties:
+                      id: { type: string }
+                      nickName: { type: string }
+                      userName: { type: string }
+                      realName: { type: string }
+                      sn: { type: integer }
+                      avatar: { type: string }
+                      roles: { type: array, items: { type: string } }
+                    nullable: true
+                  created_at:
+                    type: string
+                  updated_at:
+                    type: string
+              meta:
+                type: object
+                properties:
+                  created:
+                    type: boolean
+                    description: 这次是否新入账
+                  earned_balance:
+                    type: integer
+                    description: 该用户调整后的积分余额
+    401:
+      $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 145 - 0
openapi/public/assets/protocol/resources/auto/v3-admin-credit-ledger.yaml

@@ -0,0 +1,145 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-admin-credit-ledger.yaml
+get:
+  summary: 列出积分流水
+  tags:
+    - admin
+  operationId: get_api_v3_admin_credit_ledger
+  description: |-
+    最新的在前。包括结算赚取(earn)、提问扣减(spend)、出错退回(refund)与手工调整(adjust)。
+
+    实现:`V3\AdminCreditLedgerController@index`
+  security:
+    -
+      bearerAuth: []
+  parameters:
+    -
+      name: per_page
+      in: query
+      schema:
+        type: integer
+        default: 20
+      description: '每页数量,最大 100'
+    -
+      name: 'filter[account_type]'
+      in: query
+      schema:
+        type: string
+        enum:
+          - user
+          - guest
+      description: '账号类型;给 account_id 时必填'
+    -
+      name: 'filter[account_id]'
+      in: query
+      schema:
+        type: string
+      description: '账号 id(用户 uuid 或游客设备 id)'
+    -
+      name: 'filter[kind]'
+      in: query
+      schema:
+        type: string
+        enum:
+          - earn
+          - spend
+          - refund
+          - adjust
+      description: 流水类型
+    -
+      name: 'filter[bucket]'
+      in: query
+      schema:
+        type: string
+        enum:
+          - free
+          - earned
+      description: '池子:free 每日赠送 / earned 积分余额'
+    -
+      name: 'filter[source]'
+      in: query
+      schema:
+        type: string
+        enum:
+          - reading
+          - editing
+          - agent_run
+          - admin
+      description: 来源
+    -
+      name: 'filter[from]'
+      in: query
+      schema:
+        type: string
+      description: 起始日(UTC,Y-m-d,按流水归属日)
+    -
+      name: 'filter[to]'
+      in: query
+      schema:
+        type: string
+      description: 结束日(UTC,Y-m-d,含当天)
+    -
+      name: page
+      in: query
+      schema:
+        type: integer
+        default: 1
+      description: 页码
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    account_type:
+                      type: string
+                      enum: [user, guest]
+                    account_id:
+                      type: string
+                    user:
+                      type: object
+                      properties: { id: { type: string }, nickName: { type: string }, userName: { type: string }, realName: { type: string }, sn: { type: integer }, avatar: { type: string }, roles: { type: array, items: { type: string } } }
+                      nullable: true
+                    delta:
+                      type: integer
+                    kind:
+                      type: string
+                      enum: [earn, spend, refund, adjust]
+                    bucket:
+                      type: string
+                      enum: [free, earned]
+                    source:
+                      type: string
+                      enum: [reading, editing, agent_run, admin]
+                    ref:
+                      type: string
+                    day:
+                      type: string
+                    policy_version:
+                      type: integer
+                    client_ip:
+                      type: string
+                      nullable: true
+                    note:
+                      type: string
+                      nullable: true
+                    operator:
+                      type: object
+                      properties: { id: { type: string }, nickName: { type: string }, userName: { type: string }, realName: { type: string }, sn: { type: integer }, avatar: { type: string }, roles: { type: array, items: { type: string } } }
+                      nullable: true
+                    created_at:
+                      type: string
+                    updated_at:
+                      type: string
+              meta:
+                $ref: '../../main.yaml#/components/schemas/PaginationMeta'
+    401:
+      $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 62 - 0
openapi/public/assets/protocol/resources/auto/v3-admin-credit-overview.yaml

@@ -0,0 +1,62 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-admin-credit-overview.yaml
+get:
+  summary: 积分概览
+  tags:
+    - admin
+  operationId: get_api_v3_admin_credit_overview
+  description: |-
+    当前策略、全站合计(登录用户的积分余额总和、累计赚取、累计手工调整、今天的消耗)、
+    最近 14 天每天结算出的积分,以及最近一次结算任务(每日任务或后台手工触发)的结果。
+
+    实现:`V3\AdminCreditOverviewController@__invoke`
+  security:
+    -
+      bearerAuth: []
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: object
+                properties:
+                  today:
+                    type: string
+                  earn_since:
+                    type: string
+                  policy_version:
+                    type: integer
+                  policy:
+                    type: object
+                  totals:
+                    type: object
+                    properties:
+                      user_accounts: { type: integer }
+                      guest_accounts: { type: integer }
+                      outstanding_balance: { type: integer }
+                      earned_total: { type: integer }
+                      adjusted_total: { type: integer }
+                      spent_today: { type: integer }
+                  recent_days:
+                    type: array
+                    items:
+                      type: object
+                      properties: { day: { type: string }, users: { type: integer }, reading: { type: integer }, editing: { type: integer } }
+                  last_settlement:
+                    type: object
+                    properties:
+                      mode: { type: string }
+                      from: { type: string }
+                      to: { type: string }
+                      users: { type: integer }
+                      pairs: { type: integer }
+                      trigger: { type: string }
+                      operator: { type: string }
+                      ran_at: { type: string }
+                      seconds: { type: number }
+                    nullable: true
+    401:
+      $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'

+ 102 - 0
openapi/public/assets/protocol/resources/auto/v3-admin-credit-settlements.yaml

@@ -0,0 +1,102 @@
+# 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-admin-credit-settlements.yaml
+post:
+  summary: 手工结算积分
+  tags:
+    - admin
+  operationId: post_api_v3_admin_credit_settlements
+  description: |-
+    把登录用户的读经、编辑时长结算成积分。可重复执行:同一用户同一天的积分是覆盖不是累加,不会重复入账。
+    不给 `date`:从积分上线日到昨天,补齐所有漏结算的「用户 + 日」(与每日任务相同);
+    给 `date`:按当前策略重算那一天的所有用户。同步执行。
+
+    实现:`V3\AdminCreditSettlementController@store`
+  security:
+    -
+      bearerAuth: []
+  requestBody:
+    required: false
+    content:
+      application/json:
+        schema:
+          type: object
+          properties:
+            date:
+              type: string
+              description: 只重算这一天(UTC,Y-m-d),不早于积分上线日、不晚于今天
+  responses:
+    200:
+      description: 成功
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: object
+                properties:
+                  mode:
+                    type: string
+                    enum:
+                      - day
+                      - missing
+                  from:
+                    type: string
+                  to:
+                    type: string
+                  users:
+                    type: integer
+                  pairs:
+                    type: integer
+                    nullable: true
+                  trigger:
+                    type: string
+                    enum:
+                      - cli
+                      - admin
+                  operator:
+                    type: string
+                    nullable: true
+                  ran_at:
+                    type: string
+                  seconds:
+                    type: number
+    201:
+      description: '结算完成。响应体与 200 同形'
+      content:
+        application/json:
+          schema:
+            type: object
+            properties:
+              data:
+                type: object
+                properties:
+                  mode:
+                    type: string
+                    enum:
+                      - day
+                      - missing
+                  from:
+                    type: string
+                  to:
+                    type: string
+                  users:
+                    type: integer
+                  pairs:
+                    type: integer
+                    nullable: true
+                  trigger:
+                    type: string
+                    enum:
+                      - cli
+                      - admin
+                  operator:
+                    type: string
+                    nullable: true
+                  ran_at:
+                    type: string
+                  seconds:
+                    type: number
+    401:
+      $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'
+    422:
+      $ref: '../../main.yaml#/components/responses/ProblemValidation'

+ 5 - 0
openapi/scripts/generate.php

@@ -986,6 +986,11 @@ function buildOperation(array $route, string $httpMethod): array
                 ],
             ]
             : ['type' => 'object', 'properties' => ['data' => $data]];
+        // 单个资源用 additional(['meta' => …]) 补了服务端才算得出的值(如调整后的余额)时,
+        // 控制器用 @meta 声明,这里才输出 meta;没声明就保持 {data} 一个键
+        if (! $isList && ! empty($info['tags']['meta'])) {
+            $success['properties']['meta'] = metaSchema($info);
+        }
 
         // 声明了 204 就不再输出默认的 200——控制器 return response()->noContent()
         // 的端点没有 200 这个口径,留着会让前端以为可以读 body