doge 9 godzin temu
rodzic
commit
fd2a7ba094

+ 1 - 0
app/Http/Controllers/admin/ManualAudit.php

@@ -20,6 +20,7 @@ class ManualAudit extends Controller
                 'page' => ['nullable', 'integer', 'min:1'],
                 'limit' => ['nullable', 'integer', 'min:1', 'max:200'],
                 'member_id' => ['nullable', 'string', 'max:64'],
+                'account' => ['nullable', 'string', 'max:64'],
                 'first_name' => ['nullable', 'string', 'max:100'],
                 'transaction_type' => ['nullable', 'string', 'in:credit,debit'],
                 'change_type' => ['nullable', 'string', 'in:' . implode(',', array_merge(

+ 4 - 0
app/Services/ManualAuditService.php

@@ -265,6 +265,10 @@ class ManualAuditService
         if (!empty($params['member_id'])) {
             $query->where('member_id', (string)$params['member_id']);
         }
+        if (!empty($params['account'])) {
+            $query->whereIn('member_id', User::select('member_id')
+                ->where('account', 'like', '%' . trim((string)$params['account']) . '%'));
+        }
         if (!empty($params['first_name'])) {
             $query->where('first_name', 'like', '%' . $params['first_name'] . '%');
         }

+ 1 - 0
docs/admin-finance-api.md

@@ -68,6 +68,7 @@ POST 请求使用 `Content-Type: application/json`。统一响应:`code = 0` 
 | `page` | 否 | 默认 `1` |
 | `limit` | 否 | 默认 `20`,最大 `200` |
 | `member_id` | 否 | 会员 ID |
+| `account` | 否 | 会员账号,模糊匹配 |
 | `first_name` | 否 | 会员昵称,模糊匹配 |
 | `transaction_type` | 否 | `credit` 人工上分;`debit` 人工下分 |
 | `change_type` | 否 | 上分类型或 `人工扣款` |

+ 2 - 0
tests/Integration/ManualAuditAccountTest.php

@@ -73,6 +73,8 @@ class ManualAuditAccountTest extends TestCase
         $rows = array_column(ManualAuditService::list([])['data'], 'account', 'member_id');
         $this->assertSame(['m9' => '', 'm1' => 'alice'], $rows);
         $this->assertSame('alice', ManualAuditService::detail(1)['account']);
+        $this->assertSame(['m1'], array_column(ManualAuditService::list(['account' => 'lic'])['data'], 'member_id'));
+        $this->assertSame(0, ManualAuditService::list(['account' => 'nobody'])['total']);
     }
 
     private function assertResolveFails(?string $memberId, ?string $account, string $message): void