# Mileage Transactions API 레퍼런스 > **소유**: module `sirsoft-ecommerce` · **생성**: `php artisan api:docgen` (실측 기반). @generated 블록은 재생성 시 갱신되며, 사람이 작성한 설명은 보존됩니다. --- ## TL;DR (5초 요약) ```text 1. 이 문서는 실제 API 호출로 실측한 Mileage Transactions 엔드포인트 레퍼런스입니다 2. 각 엔드포인트: 메서드/URI/권한 + 요청 파라미터 표 + 요청 예시(curl) + 실측 응답 필드 표 + 응답 예시(envelope) 3. 응답 필드의 예시값·응답 예시 JSON 은 실제 호출 응답에서 관측된 값입니다 4. 갱신: 코드 변경 후 php artisan api:docgen 재실행 5. 설명(TODO) 칸은 사람이 채웁니다 ``` --- ### GET /api/modules/sirsoft-ecommerce/admin/mileage-transactions - **라우트명**: `api.modules.sirsoft-ecommerce.admin.mileage-transactions.index` - **컨트롤러**: `Modules\Sirsoft\Ecommerce\Http\Controllers\Admin\MileageTransactionController@index` - **인증/권한**: `auth:sanctum` + `permission:sirsoft-ecommerce.mileage.read` **요청 파라미터** | 이름 | 위치 | 타입 | 필수 | 허용값 | 용도 | | --- | --- | --- | --- | --- | --- | | page | query | integer | 아니오 | min 1 | 조회할 페이지 번호 (1부터 시작) | | per_page | query | integer | 아니오 | min 1, max 100 | 페이지당 항목 수 | | sort | query | string | 아니오 | `created_at_desc`, `created_at_asc`, `amount_desc`, `amount_asc` | 정렬 기준 (필드명, `-` 접두 시 내림차순) | | search_field | query | string | 아니오 | `member`, `member_id`, `email`, `order` | 검색 대상 필드명 (검색어를 적용할 컬럼) | | search_keyword | query | string | 아니오 | max 100 | 검색 키워드 (부분 일치) | | type | query | string | 아니오 | `earn`, `use`, `expire`, `adjust` | 유형 필터 (해당 유형의 항목만 조회) | | currency | query | string | 아니오 | max 10 | 통화 코드 필터 (해당 통화로 기록된 거래만 조회) | | start_date | query | date | 아니오 | — | 조회 기간 시작일 (이 날짜 이후 데이터) | | end_date | query | date | 아니오 | — | 조회 기간 종료일 (이 날짜 이전 데이터) | **요청 예시** ```http GET /api/modules/sirsoft-ecommerce/admin/mileage-transactions?page=1&per_page=1&sort=created_at_desc&search_field=member&search_keyword=%EC%98%88%EC%8B%9C%EA%B0%92&type=earn¤cy=%EC%98%88%EC%8B%9C%EA%B0%92&start_date=2026-01-01&end_date=2026-01-01 HTTP/1.1 Host: api.example.com Accept: application/json Authorization: Bearer {YOUR_TOKEN} ``` **응답 필드** (`data` 내부) _목록 응답: `data.data[]` 배열 항목의 필드 + `data.pagination`._ | 필드 | 타입 | 실측 예시값 | 용도/설명 | | --- | --- | --- | --- | | number | integer | `21` | 목록에서의 순번 (페이지네이션 반영 행 번호 — HasRowNumber 파생) | | id | integer | `830` | 기본 키 (내부 식별자) | | user_id | integer | `1209` | user 식별자 (연관 리소스 참조) | | currency | string | `KRW` | 거래 기록 통화 코드 (주문 기준통화 스냅샷, 금액 표기·잔액 집계 단위) | | type | string | `admin_deduct` | 거래 유형 (MileageTransactionTypeEnum 8종: purchase_earn·admin_earn·order_use·admin_deduct·expired·refund_restore·order_cancel_restore·earn_cancel) | | type_label | string | `관리자 차감` | `type` 값의 사람이 읽는 라벨 (현지화/Enum 파생) | | admin_badge_group | string | `amber` | 관리자 내역 화면 배지 색상 그룹 (적립계=green·사용계=blue·소멸=gray·복원계=teal·수동/회수계=amber) | | user_display_category | string | `adjust` | 회원 마이페이지 표시용 4분류 (earn·use·expire·adjust — 복원·수동·회수는 adjust 로 통합) | | amount | integer | `-300` | 거래 금액 (양수=적립, 음수=차감) | | amount_formatted | string | `-300원` | `amount` 값의 표시용 포맷 문자열 (통화/용량/일시 등 로케일·단위 포맷) | | remaining_amount | integer | `0` | 잔여 금액 (적립건만 양수, FIFO 차감으로 소진 — 미만료 잔여 합이 잔액 SSoT) | | remaining_amount_formatted | string | `0원` | `remaining_amount` 값의 표시용 포맷 문자열 (통화/용량/일시 등 로케일·단위 포맷) | | balance_after | integer | `102200` | 거래 직후 잔액 (감사용 스냅샷, 베스트에포트) | | order_id | null | `null` | order 식별자 (연관 리소스 참조) | | order_option_id | null | `null` | order option 식별자 (연관 리소스 참조) | | order_cancel_id | null | `null` | order cancel 식별자 (연관 리소스 참조) | | source_transaction_id | integer | `802` | source transaction 식별자 (연관 리소스 참조) | | granted_by | integer | `1209` | 부여 주체 식별자 (NULL=시스템 자동, user ID=관리자 수동 부여) | | granted_by_name | string | `최고관리자` | 부여 관리자 이름 (grantedByUser 관계 eager load 시에만 노출) | | granted_by_uuid | string | `a26219fc-94a0-4f63-9404-04c2a6ac99e4` | 부여 관리자 UUID (grantedByUser 관계 eager load 시에만 노출) | | user_name | string | `최고관리자` | 거래 대상 회원 이름 (user 관계 eager load 시에만 노출) | | user_uuid | string | `a26219fc-94a0-4f63-9404-04c2a6ac99e4` | 거래 대상 회원 UUID (user 관계 eager load 시에만 노출) | | order_number | null | `null` | 연관 주문번호 (order 관계 eager load 시에만 노출) | | description | string | `관리자 마일리지 차감 (300원)` | 설명 (다국어 필드는 로케일별 값 객체) | | memo | string | `D-30 재실측` | 관리자 메모 (수동 지급/차감·적립건 편집 시 입력) | | expires_at | string | `2027-07-31T12:56:55+00:00` | expires 일시 | | expires_at_formatted | string | `2027-07-31 21:56:55` | `expires_at` 값의 표시용 포맷 문자열 (통화/용량/일시 등 로케일·단위 포맷) | | expires_at_date | string | `2027-07-31` | `expires_at` 의 사이트 타임존 기준 날짜 부분 (시각 제외) | | expired_at | null | `null` | expired 일시 | | expired_at_formatted | null | `null` | `expired_at` 값의 표시용 포맷 문자열 (통화/용량/일시 등 로케일·단위 포맷) | | created_at | string | `2026-07-31T13:36:05+00:00` | 생성 일시 | | created_at_formatted | string | `2026-07-31 22:36:05` | `created_at` 값의 표시용 포맷 문자열 (통화/용량/일시 등 로케일·단위 포맷) | | created_at_date | string | `2026-07-31` | `created_at` 의 사이트 타임존 기준 날짜 부분 (시각 제외) | | is_earning | boolean | `false` | earning 여부 | | can_edit_expiry | boolean | `false` | edit expiry 수행 가능 여부 (권한 기반) | | expired_amount | integer | `0` | 이 적립 lot 을 source 로 소멸(expired)된 금액 합계 (목록 조회 시 eager 집계, 단건 조회 시 0 폴백) | | expired_amount_formatted | string | `0원` | `expired_amount` 값의 표시용 포맷 문자열 (통화/용량/일시 등 로케일·단위 포맷) | | expiry_state | string | `active` | 적립건 소멸 상태 (active=미소멸, partial_expired=일부 소멸, fully_expired=전액 소멸 — 적립계만 의미) | | abilities | object | `{"can_manage":true,"can_edit":false}` | 현재 사용자가 이 리소스에 수행 가능한 작업 불리언 맵 (can_update, can_delete 등 — 권한 맵 기반) | **응답 예시** ```http HTTP/1.1 200 ``` ```json { "success": true, "message": "마일리지 내역을 조회했습니다.", "data": { "data": [ { "number": 21, "id": 830, "user_id": 1209, "currency": "KRW", "type": "admin_deduct", "type_label": "관리자 차감", "admin_badge_group": "amber", "user_display_category": "adjust", "amount": -300, "amount_formatted": "-300원", "remaining_amount": 0, "remaining_amount_formatted": "0원", "balance_after": 102200, "order_id": null, "order_option_id": null, "order_cancel_id": null, "source_transaction_id": 802, "granted_by": 1209, "granted_by_name": "최고관리자", "granted_by_uuid": "a26219fc-94a0-4f63-9404-04c2a6ac99e4", "user_name": "최고관리자", "user_uuid": "a26219fc-94a0-4f63-9404-04c2a6ac99e4", "order_number": null, "description": "관리자 마일리지 차감 (300원)", "memo": "D-30 재실측", "expires_at": null, "expires_at_formatted": null, "expires_at_date": null, "expired_at": null, "expired_at_formatted": null, "created_at": "2026-07-31T13:36:05+00:00", "created_at_formatted": "2026-07-31 22:36:05", "created_at_date": "2026-07-31", "is_earning": false, "can_edit_expiry": false, "expired_amount": 0, "expired_amount_formatted": "0원", "expiry_state": "active", "abilities": { "can_manage": true, "can_edit": false } }, { "number": 20, "id": 829, "user_id": 1209, "currency": "KRW", "type": "admin_deduct", "type_label": "관리자 차감", "admin_badge_group": "amber", "user_display_category": "adjust", "amount": -2500, "amount_formatted": "-2,500원", "remaining_amount": 0, "remaining_amount_formatted": "0원", "balance_after": 102500, "order_id": null, "order_option_id": null, "order_cancel_id": null, "source_transaction_id": 801, "granted_by": 1209, "granted_by_name": "최고관리자", "granted_by_uuid": "a26219fc-94a0-4f63-9404-04c2a6ac99e4", "user_name": "최고관리자", "user_uuid": "a26219fc-94a0-4f63-9404-04c2a6ac99e4", "order_number": null, "description": "관리자 마일리지 차감 (2500원)", "memo": "검수 차감 #5", "expires_at": null, "expires_at_formatted": null, "expires_at_date": null, "expired_at": null, "expired_at_formatted": null, "created_at": "2026-07-31T12:50:13+00:00", "created_at_formatted": "2026-07-31 21:50:13", "created_at_date": "2026-07-31", "is_earning": false, "can_edit_expiry": false, "expired_amount": 0, "expired_amount_formatted": "0원", "expiry_state": "active", "abilities": { "can_manage": true, "can_edit": false } }, "... (총 21건 중 2건 표시)" ], "abilities": { "can_manage": true }, "currencies": [ "KRW" ], "pagination": { "current_page": 1, "last_page": 1, "per_page": 25, "total": 21, "from": 1, "to": 21, "has_more_pages": false } } } ``` **에러 응답** | 상태코드 | 의미 | 발생 조건 | | --- | --- | --- | | 401 | Unauthenticated | 유효한 Bearer 토큰이 없거나 만료된 경우 | | 403 | Forbidden | 요구 권한(`sirsoft-ecommerce.mileage.read`)이 없는 경우 | | 422 | Unprocessable Entity | 요청 파라미터가 검증 규칙을 위반한 경우 (`error.errors` 에 필드별 메시지) | **설명** 관리자가 전체 회원의 마일리지 거래 원장을 검색·필터·페이지네이션으로 조회합니다. `permission:sirsoft-ecommerce.mileage.read` 권한이 필요하며, 회원(member·member_id·email)·주문번호 검색, type(earn·use·expire·adjust)·통화·기간 필터, 금액/생성일 정렬을 지원합니다. `UserMileageService::paginateAdminHistory()`가 조회하고 `MileageTransactionCollection`이 통화 필터 후보(`withCurrencies`)와 함께 직렬화합니다. 각 행은 원장 스냅샷(balance_after, remaining_amount 등)을 그대로 노출하며 원장은 불변입니다. ### POST /api/modules/sirsoft-ecommerce/admin/mileage-transactions - **라우트명**: `api.modules.sirsoft-ecommerce.admin.mileage-transactions.store` - **컨트롤러**: `Modules\Sirsoft\Ecommerce\Http\Controllers\Admin\MileageTransactionController@store` - **인증/권한**: `auth:sanctum` + `permission:sirsoft-ecommerce.mileage.manage` **요청 파라미터** | 이름 | 위치 | 타입 | 필수 | 허용값 | 용도 | | --- | --- | --- | --- | --- | --- | | user_id | body | uuid | 예 | — | user 식별자 | | action | body | string | 예 | `earn`, `deduct` | 처리 동작 (earn=수동 적립 → adminEarn, deduct=수동 차감 → adminDeduct FIFO 소진) | | amount | body | integer | 예 | min 1 | 지급/차감할 마일리지 금액 (양수) | | currency | body | string | 예 | max 10 | 대상 통화 코드 (해당 통화 잔액에 적용) | | memo | body | string | 아니오 | max 1000 | 관리자 메모 (거래에 기록) | | description | body | string | 아니오 | max 500 | 설명 | | expires_at | body | date | 아니오 | — | 만료일 직접 지정 (지급 시 `use_default_expiry`=false 인 경우 적용) | | use_default_expiry | body | boolean | 아니오 | — | 지급 시 정책 기본 만료일 적용 여부 (기본 true, false 면 `expires_at` 사용) | **요청 예시** ```http POST /api/modules/sirsoft-ecommerce/admin/mileage-transactions HTTP/1.1 Host: api.example.com Accept: application/json Authorization: Bearer {YOUR_TOKEN} Content-Type: application/json { "user_id": "9f8b2c1a-4d3e-4a2b-8c1d-0e1f2a3b4c5d", "action": "earn", "amount": 1, "currency": "예시값", "memo": "예시값", "description": "예시 내용입니다.", "expires_at": "2026-01-01", "use_default_expiry": true } ``` **응답 필드** (`data` 내부) _단건 응답: `data` 객체의 필드 (성공 시 HTTP 201). 생성 직후 모델을 그대로 직렬화하므로 관계 기반 필드(`user_name`·`user_uuid`·`granted_by_name`·`granted_by_uuid`·`order_number`)는 eager load 되지 않아 응답에서 생략됩니다._ | 필드 | 타입 | 실측 예시값 | 용도/설명 | | --- | --- | --- | --- | | id | integer | `529` | 생성된 거래의 기본 키 | | user_id | integer | `166` | 거래 대상 회원 ID (요청의 `user_id` uuid 를 내부 ID 로 해석한 값) | | currency | string | `KRW` | 거래 기록 통화 코드 (요청 `currency`) | | type | string | `admin_earn` | 거래 유형 (`action=earn` → `admin_earn`, `action=deduct` → `admin_deduct`) | | type_label | string | `관리자 지급` | `type` 값의 사람이 읽는 라벨 | | admin_badge_group | string | `amber` | 관리자 내역 화면 배지 색상 그룹 (수동/회수계=amber) | | user_display_category | string | `adjust` | 회원 마이페이지 표시용 4분류 (수동 지급/차감은 adjust) | | amount | integer | `1000` | 거래 금액 (지급=양수, 차감=음수) | | amount_formatted | string | `1,000원` | `amount` 의 표시용 포맷 문자열 | | remaining_amount | integer | `1000` | 잔여 금액 (지급 시 amount 와 동일, 차감 거래는 0) | | remaining_amount_formatted | string | `1,000원` | `remaining_amount` 의 표시용 포맷 문자열 | | balance_after | integer | `1000` | 거래 직후 해당 통화 잔액 스냅샷 | | order_id | null | `null` | 수동 거래이므로 연결 주문 없음 | | order_option_id | null | `null` | 수동 거래이므로 연결 주문 옵션 없음 | | order_cancel_id | null | `null` | 수동 거래이므로 연결 주문취소 없음 | | source_transaction_id | null | `null` | 수동 거래이므로 원본 거래 없음 | | granted_by | integer | `1` | 처리한 관리자 user ID (인증 사용자) | | description | string | `관리자 마일리지 지급 (1,000)` | 설명 (요청 `description` 미지정 시 활동로그 기본 문구) | | memo | string \| null | `수기 보상` | 관리자 메모 (요청 `memo`) | | expires_at | string \| null | `2027-07-02T15:29:30+00:00` | 만료 일시 (지급 시 정책 기본 또는 `expires_at`, 차감 거래는 null) | | expires_at_formatted | string \| null | `2027-07-03 00:29:30` | `expires_at` 의 표시용 포맷 문자열 | | expires_at_date | string \| null | `2027-07-03` | `expires_at` 의 사이트 타임존 기준 날짜 | | expired_at | null | `null` | 소멸 일시 (신규 거래는 항상 null) | | expired_at_formatted | null | `null` | `expired_at` 의 표시용 포맷 문자열 | | created_at | string | `2026-07-07T05:47:31+00:00` | 생성 일시 | | created_at_formatted | string | `2026-07-07 14:47:31` | `created_at` 의 표시용 포맷 문자열 | | created_at_date | string | `2026-07-07` | `created_at` 의 사이트 타임존 기준 날짜 | | is_earning | boolean | `true` | 적립계 여부 (`admin_earn`=true, `admin_deduct`=false) | | can_edit_expiry | boolean | `true` | 만료일 편집 가능 여부 (적립계 + 미소멸 + 잔여>0) | | expired_amount | integer | `0` | 이 적립 lot 을 source 로 소멸된 금액 합계 (단건 응답은 집계 미주입 → 0 폴백) | | expired_amount_formatted | string | `0원` | `expired_amount` 의 표시용 포맷 문자열 | | expiry_state | string | `active` | 적립건 소멸 상태 (신규 거래는 active) | | abilities | object | `{"can_manage":true,"can_edit":true}` | 현재 사용자가 이 거래에 수행 가능한 작업 불리언 맵 | **응답 예시** ```http HTTP/1.1 201 ``` ```json { "success": true, "message": "마일리지 거래가 처리되었습니다.", "data": { "id": 529, "user_id": 166, "currency": "KRW", "type": "admin_earn", "type_label": "관리자 지급", "admin_badge_group": "amber", "user_display_category": "adjust", "amount": 1000, "amount_formatted": "1,000원", "remaining_amount": 1000, "remaining_amount_formatted": "1,000원", "balance_after": 1000, "order_id": null, "order_option_id": null, "order_cancel_id": null, "source_transaction_id": null, "granted_by": 1, "description": "관리자 마일리지 지급 (1,000)", "memo": "수기 보상", "expires_at": "2027-07-02T15:29:30+00:00", "expires_at_formatted": "2027-07-03 00:29:30", "expires_at_date": "2027-07-03", "expired_at": null, "expired_at_formatted": null, "created_at": "2026-07-07T05:47:31+00:00", "created_at_formatted": "2026-07-07 14:47:31", "created_at_date": "2026-07-07", "is_earning": true, "can_edit_expiry": true, "expired_amount": 0, "expired_amount_formatted": "0원", "expiry_state": "active", "abilities": { "can_manage": true, "can_edit": true } } } ``` **에러 응답** | 상태코드 | 의미 | 발생 조건 | | --- | --- | --- | | 401 | Unauthenticated | 유효한 Bearer 토큰이 없거나 만료된 경우 | | 403 | Forbidden | 요구 권한(`sirsoft-ecommerce.mileage.manage`)이 없는 경우 | | 422 | Unprocessable Entity | 요청 파라미터가 검증 규칙을 위반했거나, 도메인 규칙 위반(`MileageValidationException` — 예: 차감액이 잔액 초과) 시. 후자는 `message`=`마일리지 처리에 실패했습니다.` + `error.errors.general[]` 에 사유 문장 | **설명** 관리자가 특정 회원에게 마일리지를 수동으로 지급하거나 차감합니다. `permission:sirsoft-ecommerce.mileage.manage` 권한이 필요하고 회원은 `user_id`(uuid)로 지정하며, `action`(earn/deduct)에 따라 `UserMileageService::adminEarn()` 또는 `adminDeduct()`를 호출합니다. 지급 시 `use_default_expiry`(기본 true)면 정책 기본 만료일을, 아니면 `expires_at`을 적용하고, 차감은 FIFO로 적립건에서 소진합니다. 잔액 부족 등 도메인 규칙 위반은 `MileageValidationException`으로 422를 반환합니다. ### POST /api/modules/sirsoft-ecommerce/admin/mileage-transactions/extend-expiry - **라우트명**: `api.modules.sirsoft-ecommerce.admin.mileage-transactions.extend-expiry` - **컨트롤러**: `Modules\Sirsoft\Ecommerce\Http\Controllers\Admin\MileageTransactionController@extendExpiry` - **인증/권한**: `auth:sanctum` + `permission:sirsoft-ecommerce.mileage.manage` **요청 파라미터** | 이름 | 위치 | 타입 | 필수 | 허용값 | 용도 | | --- | --- | --- | --- | --- | --- | | user_id | body | uuid | 예 | — | user 식별자 | | lot_ids | body | array | 예 | min 1 | lot 식별자 배열 | | days | body | integer | 예 | min 1, max 3650 | 각 lot 만료일을 연장할 일수 (최대 3650일) | **요청 예시** ```http POST /api/modules/sirsoft-ecommerce/admin/mileage-transactions/extend-expiry HTTP/1.1 Host: api.example.com Accept: application/json Authorization: Bearer {YOUR_TOKEN} Content-Type: application/json { "user_id": "9f8b2c1a-4d3e-4a2b-8c1d-0e1f2a3b4c5d", "lot_ids": [ "예시값" ], "days": 1 } ``` **응답 필드** (`data` 내부) _단건 응답: `data` 객체의 필드._ | 필드 | 타입 | 실측 예시값 | 용도/설명 | | --- | --- | --- | --- | | extended_count | integer | `2` | 실제로 만료일이 연장된 적립 lot 수 (잔여 없는/대상 외 lot 은 제외되므로 요청한 `lot_ids` 수보다 작을 수 있음) | **응답 예시** ```http HTTP/1.1 200 ``` ```json { "success": true, "message": "마일리지 유효기간이 연장되었습니다.", "data": { "extended_count": 2 } } ``` **에러 응답** | 상태코드 | 의미 | 발생 조건 | | --- | --- | --- | | 401 | Unauthenticated | 유효한 Bearer 토큰이 없거나 만료된 경우 | | 403 | Forbidden | 요구 권한(`sirsoft-ecommerce.mileage.manage`)이 없는 경우 | | 422 | Unprocessable Entity | 요청 파라미터가 검증 규칙을 위반한 경우 (`error.errors` 에 필드별 메시지) | **설명** 관리자가 특정 회원의 여러 적립 lot 의 유효기간을 한 번에 연장합니다. `permission:sirsoft-ecommerce.mileage.manage` 권한이 필요하며, 회원(`user_id` uuid)과 대상 적립건 배열(`lot_ids`), 연장 일수(`days`, 최대 3650)를 받아 `UserMileageService::extendLotExpiry()`가 각 lot 의 만료일을 연장하고 실제로 연장된 건수(`extended_count`)를 반환합니다. 이미 소멸/사용된 lot 등 대상 외 건은 서비스가 걸러내므로 반환 건수가 요청한 `lot_ids` 수보다 작을 수 있습니다. ### PATCH /api/modules/sirsoft-ecommerce/admin/mileage-transactions/{id} - **라우트명**: `api.modules.sirsoft-ecommerce.admin.mileage-transactions.update` - **컨트롤러**: `Modules\Sirsoft\Ecommerce\Http\Controllers\Admin\MileageTransactionController@update` - **인증/권한**: `auth:sanctum` + `permission:sirsoft-ecommerce.mileage.manage` **요청 파라미터** | 이름 | 위치 | 타입 | 필수 | 허용값 | 용도 | | --- | --- | --- | --- | --- | --- | | id | path | string | 예 | — | 대상 리소스의 식별자 | | memo | body | string | 아니오 | max 1000 | 관리자 메모 보정값 (요청에 포함된 경우만 갱신, 빈 값으로 비우기 허용) | | expires_at | body | date | 아니오 | — | expires 일시 | **요청 예시** ```http PATCH /api/modules/sirsoft-ecommerce/admin/mileage-transactions/{id} HTTP/1.1 Host: api.example.com Accept: application/json Authorization: Bearer {YOUR_TOKEN} Content-Type: application/json { "memo": "예시값", "expires_at": "2026-01-01" } ``` **응답 필드** (`data` 내부) _단건 응답: `data` 객체의 필드 (수정된 거래 전체). 관계 기반 필드(`user_name`·`user_uuid`·`granted_by_name`·`granted_by_uuid`·`order_number`)는 eager load 되지 않아 응답에서 생략됩니다._ | 필드 | 타입 | 실측 예시값 | 용도/설명 | | --- | --- | --- | --- | | id | integer | `528` | 수정한 거래의 기본 키 (path `{id}`) | | user_id | integer | `166` | 거래 대상 회원 ID | | currency | string | `KRW` | 거래 기록 통화 코드 | | type | string | `admin_earn` | 거래 유형 (적립계만 수정 가능 — purchase_earn·admin_earn) | | type_label | string | `관리자 지급` | `type` 값의 사람이 읽는 라벨 | | admin_badge_group | string | `amber` | 관리자 내역 화면 배지 색상 그룹 | | user_display_category | string | `adjust` | 회원 마이페이지 표시용 4분류 | | amount | integer | `1000` | 거래 금액 (원장 불변 — 수정 불가) | | amount_formatted | string | `1,000원` | `amount` 의 표시용 포맷 문자열 | | remaining_amount | integer | `1000` | 잔여 금액 (FIFO 차감으로 소진) | | remaining_amount_formatted | string | `1,000원` | `remaining_amount` 의 표시용 포맷 문자열 | | balance_after | integer | `1000` | 거래 직후 잔액 스냅샷 | | order_id | integer \| null | `null` | 연결 주문 ID | | order_option_id | integer \| null | `null` | 연결 주문 옵션 ID | | order_cancel_id | integer \| null | `null` | 연결 주문취소 ID | | source_transaction_id | integer \| null | `null` | 원본 거래 ID | | granted_by | integer \| null | `1` | 부여 주체 user ID (NULL=시스템 자동) | | description | string \| null | `관리자 마일리지 지급 (1,000)` | 설명 | | memo | string \| null | `사유 보정` | 갱신된 관리자 메모 (요청에 `memo` 를 포함한 경우 반영, 빈 값이면 null) | | expires_at | string \| null | `2027-08-01T15:00:00+00:00` | 갱신된 만료 일시 (요청에 `expires_at` 을 포함한 경우 반영) | | expires_at_formatted | string \| null | `2027-08-02 00:00:00` | `expires_at` 의 표시용 포맷 문자열 | | expires_at_date | string \| null | `2027-08-02` | `expires_at` 의 사이트 타임존 기준 날짜 | | expired_at | null | `null` | 소멸 일시 (소멸된 lot 은 만료일 수정 불가) | | expired_at_formatted | null | `null` | `expired_at` 의 표시용 포맷 문자열 | | created_at | string | `2026-07-07T05:47:31+00:00` | 생성 일시 | | created_at_formatted | string | `2026-07-07 14:47:31` | `created_at` 의 표시용 포맷 문자열 | | created_at_date | string | `2026-07-07` | `created_at` 의 사이트 타임존 기준 날짜 | | is_earning | boolean | `true` | 적립계 여부 (수정 대상은 항상 true) | | can_edit_expiry | boolean | `true` | 만료일 편집 가능 여부 (적립계 + 미소멸 + 잔여>0) | | expired_amount | integer | `0` | 소멸 금액 합계 (단건 응답은 집계 미주입 → 0 폴백) | | expired_amount_formatted | string | `0원` | `expired_amount` 의 표시용 포맷 문자열 | | expiry_state | string | `active` | 적립건 소멸 상태 (active·partial_expired·fully_expired) | | abilities | object | `{"can_manage":true,"can_edit":true}` | 현재 사용자가 이 거래에 수행 가능한 작업 불리언 맵 | **응답 예시** ```http HTTP/1.1 200 ``` ```json { "success": true, "message": "마일리지 거래가 수정되었습니다.", "data": { "id": 528, "user_id": 166, "currency": "KRW", "type": "admin_earn", "type_label": "관리자 지급", "admin_badge_group": "amber", "user_display_category": "adjust", "amount": 1000, "amount_formatted": "1,000원", "remaining_amount": 1000, "remaining_amount_formatted": "1,000원", "balance_after": 1000, "order_id": null, "order_option_id": null, "order_cancel_id": null, "source_transaction_id": null, "granted_by": 1, "description": "관리자 마일리지 지급 (1,000)", "memo": "사유 보정", "expires_at": "2027-08-01T15:00:00+00:00", "expires_at_formatted": "2027-08-02 00:00:00", "expires_at_date": "2027-08-02", "expired_at": null, "expired_at_formatted": null, "created_at": "2026-07-07T05:47:31+00:00", "created_at_formatted": "2026-07-07 14:47:31", "created_at_date": "2026-07-07", "is_earning": true, "can_edit_expiry": true, "expired_amount": 0, "expired_amount_formatted": "0원", "expiry_state": "active", "abilities": { "can_manage": true, "can_edit": true } } } ``` **에러 응답** | 상태코드 | 의미 | 발생 조건 | | --- | --- | --- | | 401 | Unauthenticated | 유효한 Bearer 토큰이 없거나 만료된 경우 | | 403 | Forbidden | 요구 권한(`sirsoft-ecommerce.mileage.manage`)이 없는 경우 | | 404 | Not Found | path 파라미터에 해당하는 리소스가 없는 경우 | | 422 | Unprocessable Entity | 요청 파라미터가 검증 규칙을 위반했거나, 도메인 규칙 위반(`MileageValidationException`) 시. `message`=`마일리지 처리에 실패했습니다.` + `error.errors.general[]` 에 사유 문장 — 거래 없음(`마일리지 거래를 찾을 수 없습니다.`), 적립계 아님(`적립 거래만 수정할 수 있습니다.`), 소멸/전액 사용된 적립건(`이미 소멸되었거나 모두 사용된 적립건은 유효기간을 변경할 수 없습니다.`), 만료일이 적립일시 이전(`유효기간은 적립일시보다 이전일 수 없습니다.`) | **설명** 관리자가 기존 적립 거래의 부가 필드(관리자 메모 `memo`, 만료일 `expires_at`)만 보정합니다. 마일리지 원장은 불변이므로 금액·유형 등 핵심 값은 수정할 수 없고, 요청에 실제로 포함된 키만 갱신합니다(`memo` 만 보내면 만료일은 유지). `UserMileageService::updateAdminTransaction()`가 적립계 거래인지·소멸/사용된 lot 이 아닌지 검증하며, 적립계 외 거래 등 규칙 위반은 `MileageValidationException`(422)으로 거부합니다. ### GET /api/modules/sirsoft-ecommerce/admin/mileage-transactions/{id}/linked - **라우트명**: `api.modules.sirsoft-ecommerce.admin.mileage-transactions.linked` - **컨트롤러**: `Modules\Sirsoft\Ecommerce\Http\Controllers\Admin\MileageTransactionController@linked` - **인증/권한**: `auth:sanctum` + `permission:sirsoft-ecommerce.mileage.read` **요청 파라미터** | 이름 | 위치 | 타입 | 필수 | 허용값 | 용도 | | --- | --- | --- | --- | --- | --- | | id | path | string | 예 | — | 대상 리소스의 식별자 | **요청 예시** ```http GET /api/modules/sirsoft-ecommerce/admin/mileage-transactions/{id}/linked HTTP/1.1 Host: api.example.com Accept: application/json Authorization: Bearer {YOUR_TOKEN} ``` **응답 필드** (`data` 내부) _목록 응답: `data.data[]` 배열 항목의 필드. 페이지네이션 없는 컬렉션이라 `data.pagination` 은 없고, 컬렉션 레벨 `data.abilities`(`can_manage`)와 통화 필터 후보 `data.currencies`(이 엔드포인트는 주입하지 않아 항상 `[]`)가 함께 내려옵니다._ | 필드 | 타입 | 실측 예시값 | 용도/설명 | | --- | --- | --- | --- | | number | integer | `1` | 목록에서의 순번 (HasRowNumber 파생) | | id | integer | `531` | 연결 거래의 기본 키 | | user_id | integer | `166` | 거래 대상 회원 ID | | currency | string | `KRW` | 거래 기록 통화 코드 | | type | string | `order_use` | 거래 유형 (적립건이면 이를 FIFO 로 소비한 차감 거래, 차감/복원건이면 원본 적립·취소 연결 거래) | | type_label | string | `주문 사용` | `type` 값의 사람이 읽는 라벨 | | admin_badge_group | string | `blue` | 관리자 내역 화면 배지 색상 그룹 | | user_display_category | string | `use` | 회원 마이페이지 표시용 4분류 | | amount | integer | `-500` | 거래 금액 (양수=적립, 음수=차감) | | amount_formatted | string | `-500원` | `amount` 의 표시용 포맷 문자열 | | remaining_amount | integer | `0` | 잔여 금액 (적립건만 양수) | | remaining_amount_formatted | string | `0원` | `remaining_amount` 의 표시용 포맷 문자열 | | balance_after | integer | `500` | 거래 직후 잔액 스냅샷 | | order_id | integer \| null | `436` | 연결 주문 ID | | order_option_id | integer \| null | `824` | 연결 주문 옵션 ID | | order_cancel_id | integer \| null | `null` | 연결 주문취소 ID | | source_transaction_id | integer \| null | `528` | 원본(source) 거래 ID — FIFO 소비된 적립 lot 또는 복원 원본 | | granted_by | integer \| null | `null` | 부여 주체 user ID (NULL=시스템 자동) | | description | string \| null | `주문 마일리지 사용` | 설명 | | memo | string \| null | `null` | 관리자 메모 | | expires_at | string \| null | `null` | 만료 일시 | | expires_at_formatted | string \| null | `null` | `expires_at` 의 표시용 포맷 문자열 | | expires_at_date | string \| null | `null` | `expires_at` 의 사이트 타임존 기준 날짜 | | expired_at | string \| null | `null` | 소멸 일시 | | expired_at_formatted | string \| null | `null` | `expired_at` 의 표시용 포맷 문자열 | | created_at | string | `2026-07-07T05:47:31+00:00` | 생성 일시 | | created_at_formatted | string | `2026-07-07 14:47:31` | `created_at` 의 표시용 포맷 문자열 | | created_at_date | string | `2026-07-07` | `created_at` 의 사이트 타임존 기준 날짜 | | is_earning | boolean | `false` | 적립계 여부 | | can_edit_expiry | boolean | `false` | 만료일 편집 가능 여부 | | expired_amount | integer | `0` | 소멸 금액 합계 (연결 거래 조회는 집계 미주입 → 0 폴백) | | expired_amount_formatted | string | `0원` | `expired_amount` 의 표시용 포맷 문자열 | | expiry_state | string | `active` | 적립건 소멸 상태 (적립계만 의미) | | abilities | object | `{"can_manage":true,"can_edit":false}` | 현재 사용자가 이 거래에 수행 가능한 작업 불리언 맵 | **응답 예시** ```http HTTP/1.1 200 ``` ```json { "success": true, "message": "연결 거래를 조회했습니다.", "data": { "data": [ { "number": 1, "id": 531, "user_id": 166, "currency": "KRW", "type": "order_use", "type_label": "주문 사용", "admin_badge_group": "blue", "user_display_category": "use", "amount": -500, "amount_formatted": "-500원", "remaining_amount": 0, "remaining_amount_formatted": "0원", "balance_after": 500, "order_id": 436, "order_option_id": 824, "order_cancel_id": null, "source_transaction_id": 528, "granted_by": null, "description": "주문 마일리지 사용", "memo": null, "expires_at": null, "expires_at_formatted": null, "expires_at_date": null, "expired_at": null, "expired_at_formatted": null, "created_at": "2026-07-07T05:47:31+00:00", "created_at_formatted": "2026-07-07 14:47:31", "created_at_date": "2026-07-07", "is_earning": false, "can_edit_expiry": false, "expired_amount": 0, "expired_amount_formatted": "0원", "expiry_state": "active", "abilities": { "can_manage": true, "can_edit": false } } ], "abilities": { "can_manage": true }, "currencies": [] } } ``` > 연결 거래가 없으면 `data.data` 가 빈 배열이다 (404 가 아니다 — 404 는 `{id}` 거래 자체가 없을 때뿐이다). 페이지네이션이 없는 컬렉션이라 `data.pagination` 키는 존재하지 않으며, `data.currencies` 는 이 엔드포인트가 주입하지 않아 항상 `[]` 다. **에러 응답** | 상태코드 | 의미 | 발생 조건 | | --- | --- | --- | | 401 | Unauthenticated | 유효한 Bearer 토큰이 없거나 만료된 경우 | | 403 | Forbidden | 요구 권한(`sirsoft-ecommerce.mileage.read`)이 없는 경우 | | 404 | Not Found | `{id}` 에 해당하는 마일리지 거래가 없는 경우 | **설명** 관리자가 마일리지 내역 한 행을 펼쳤을 때 그와 연결된 거래들을 조회합니다. `permission:sirsoft-ecommerce.mileage.read` 권한이 필요하며, `UserMileageService::getLinkedTransactions()`가 적립건이면 그 적립을 FIFO 로 소비한 차감 거래들을, 차감/복원건이면 원본 적립·취소 연결 거래를 찾아 `MileageTransactionCollection`으로 반환합니다. 해당 거래가 없으면 404 를 반환하며, 연결 거래가 없으면 빈 목록이 내려옵니다.