fix(core,ecommerce): Windows 확장 업데이트 파일 잠금 해소 + 통화 삭제 영속화

Windows 는 하위 트리에 열린 핸들이 하나라도 있으면 디렉토리 rename 을 막는다.
잠금 프로세스를 찾아 종료하던 기존 대응은 디렉토리 핸들을 감지하지 못했고
사용 중인 편집기를 예고 없이 죽였다. rename 이 막히면 파일 단위 연산으로
폴백해 어떤 프로세스도 건드리지 않고 교체를 끝낸다. 커밋 전 점검에서
pint.json 이 코어 업데이트 대상에 빠져 있던 것도 함께 등재했다.

이커머스는 기본 제공 통화 삭제가 저장 응답에서 즉시 부활했다. 항목 단위
보충 병합이 "소실" 과 "의도적 삭제" 를 구분하지 못한 탓이라, 삭제 의도를
서버가 도출해 저장본에 기록하고 병합이 그 기록을 존중하게 했다. 그 통화로
결제된 과거 주문의 표기가 흔들리지 않도록 소수 자릿수 해석도 스냅샷 우선으로
바꿨다 — 금액은 원래 스냅샷 환율을 써 안전했으나 자릿수만 현재 설정을 봤다.
This commit is contained in:
HeuJung committed 2026-08-12 10:10:01 +09:00
1 parent 5ae34002f3
commit c77ddee03b
39 files changed
+1886 -138

No files matched your search

@@ -39,6 +39,9 @@ class GuestOrderResource extends BaseApiResource
{
// 주문 시점 기준 통화 — 과거 주문의 *_formatted 는 설정 변경과 무관하게 이 통화로 고정 표기한다.
$orderCurrency = $this->resolveOrderBaseCurrencyCode($this->resource);
// 주문 시점 통화 스냅샷 — 소수 자릿수를 현재 설정이 아닌 주문 시점 값으로 고정 (공개 #91 후속).
$currencySnapshot = $this->resource->currency_snapshot ?? null;
$this->withCurrencySnapshot($currencySnapshot);
// 결제 통화(order_currency) — 현금영수증 금액 표기 기준(구매자가 실제 낸 통화).
$paymentCurrency = $this->currency
@@ -118,14 +121,14 @@ class GuestOrderResource extends BaseApiResource
// 주문 옵션 (품목) — 주문 시점 통화를 자식에 전파
'options' => $this->whenLoaded('options', fn () => OrderOptionResource::collection($this->options)->each(
fn ($r) => $r->withOrderCurrency($orderCurrency)
fn ($r) => $r->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)
)),
// 배송지/결제/배송 정보
'shipping_address' => new OrderAddressResource($this->whenLoaded('shippingAddress')),
'payment' => $this->whenLoaded('payment', fn () => (new OrderPaymentResource($this->payment))->withOrderCurrency($orderCurrency)),
'payment' => $this->whenLoaded('payment', fn () => (new OrderPaymentResource($this->payment))->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)),
'shippings' => $this->whenLoaded('shippings', fn () => OrderShippingResource::collection($this->shippings)->each(
fn ($r) => $r->withOrderCurrency($orderCurrency)
fn ($r) => $r->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)
)),
// 취소 이력 (취소 사유·상세 사유·취소일시 표시용) — 최근 취소가 먼저 오도록 정렬
@@ -141,13 +144,13 @@ class GuestOrderResource extends BaseApiResource
$active = OrderCashReceipt::filterActive($this->cashReceipts)[0] ?? null;
return $active
? (new CashReceiptResource($active))->withOrderCurrency($orderCurrency)->withReceiptCurrency($paymentCurrency)
? (new CashReceiptResource($active))->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)->withReceiptCurrency($paymentCurrency)
: null;
}),
// 발급/취소 전체 이력 — 카드의 "직전 발급이 실패했는가" 분기가 cash_receipts[0] 를 본다.
'cash_receipts' => $this->whenLoaded('cashReceipts', fn () => CashReceiptResource::collection(
$this->cashReceipts->sortByDesc('id')->values()
)->each(fn ($r) => $r->withOrderCurrency($orderCurrency)->withReceiptCurrency($paymentCurrency))),
)->each(fn ($r) => $r->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)->withReceiptCurrency($paymentCurrency))),
// 배송정책 — **표시용 필드만**. 비회원 주문 상세 화면은 회원 마이페이지와 같은
// partial 을 써서 상품별 정책명·개별 배송비를 그리는데, 이 필드를 통째로 빼면
@@ -30,6 +30,9 @@ class OrderListResource extends BaseApiResource
{
// 주문 시점 기준 통화 — 과거 주문의 *_formatted 는 설정 변경과 무관하게 이 통화로 고정 표기한다.
$orderCurrency = $this->resolveOrderBaseCurrencyCode($this->resource);
// 주문 시점 통화 스냅샷 — 소수 자릿수를 현재 설정이 아닌 주문 시점 값으로 고정 (공개 #91 후속).
$currencySnapshot = $this->resource->currency_snapshot ?? null;
$this->withCurrencySnapshot($currencySnapshot);
// 결제 통화(order_currency) — 유저가 선택·결제한 통화. base 통화와 다를 때 함께 표기.
$paymentCurrency = $this->currency
@@ -27,6 +27,9 @@ class OrderResource extends BaseApiResource
{
// 주문 시점 기준 통화 — 과거 주문의 *_formatted 는 설정 변경과 무관하게 이 통화로 고정 표기한다.
$orderCurrency = $this->resolveOrderBaseCurrencyCode($this->resource);
// 주문 시점 통화 스냅샷 — 소수 자릿수를 현재 설정이 아닌 주문 시점 값으로 고정 (공개 #91 후속).
$currencySnapshot = $this->resource->currency_snapshot ?? null;
$this->withCurrencySnapshot($currencySnapshot);
// 결제 통화(order_currency) — 유저가 선택·결제한 통화. base 통화와 다를 때 화면에 함께 표기한다.
$paymentCurrency = $this->currency
@@ -177,7 +180,7 @@ class OrderResource extends BaseApiResource
// 주문 옵션 (품목) — 주문 시점 통화를 자식에 전파
'options' => $this->whenLoaded('options', fn () => OrderOptionResource::collection($this->options)->each(
fn ($r) => $r->withOrderCurrency($orderCurrency)
fn ($r) => $r->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)
)),
// 배송지 정보
@@ -185,9 +188,9 @@ class OrderResource extends BaseApiResource
'billing_address' => new OrderAddressResource($this->whenLoaded('billingAddress')),
// 결제 정보
'payment' => $this->whenLoaded('payment', fn () => (new OrderPaymentResource($this->payment))->withOrderCurrency($orderCurrency)),
'payment' => $this->whenLoaded('payment', fn () => (new OrderPaymentResource($this->payment))->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)),
'payments' => $this->whenLoaded('payments', fn () => OrderPaymentResource::collection($this->payments)->each(
fn ($r) => $r->withOrderCurrency($orderCurrency)
fn ($r) => $r->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)
)),
// 현금영수증 — 현재 활성 영수증 1건(없으면 null). 발급 카드의 "발급완료" 상태 근거.
@@ -195,17 +198,17 @@ class OrderResource extends BaseApiResource
$active = OrderCashReceipt::filterActive($this->cashReceipts)[0] ?? null;
return $active
? (new CashReceiptResource($active))->withOrderCurrency($orderCurrency)->withReceiptCurrency($paymentCurrency)
? (new CashReceiptResource($active))->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)->withReceiptCurrency($paymentCurrency)
: null;
}),
// 발급/취소 전체 이력 — 관리자 화면의 "취소 성공 + 재발급 실패" 경고 배지 판정 근거.
'cash_receipts' => $this->whenLoaded('cashReceipts', fn () => CashReceiptResource::collection(
$this->cashReceipts->sortByDesc('id')->values()
)->each(fn ($r) => $r->withOrderCurrency($orderCurrency)->withReceiptCurrency($paymentCurrency))),
)->each(fn ($r) => $r->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)->withReceiptCurrency($paymentCurrency))),
// 배송 정보
'shippings' => $this->whenLoaded('shippings', fn () => OrderShippingResource::collection($this->shippings)->each(
fn ($r) => $r->withOrderCurrency($orderCurrency)
fn ($r) => $r->withOrderCurrency($orderCurrency)->withCurrencySnapshot($currencySnapshot)
)),
// 취소 이력 (취소 사유·상세 사유·취소일시 표시용) — 최근 취소가 먼저 오도록 정렬
@@ -20,6 +20,14 @@ trait HasMultiCurrencyPrices
*/
protected ?string $orderCurrencyCode = null;
/**
* 부모 주문 리소스가 주입한 주문 시점 통화 스냅샷 (공개 #91 후속).
*
* 소수 자릿수를 현재 설정이 아니라 주문 시점 값으로 고정하기 위해 전파한다.
* null 이면 현재 설정으로 폴백 — 상품 등 카탈로그 경로는 그것이 정답이다.
*/
protected ?array $currencySnapshot = null;
/**
* 주문 시점 기준 통화 코드를 주입합니다 (부모 → 자식 리소스 전파).
*
@@ -33,6 +41,23 @@ trait HasMultiCurrencyPrices
return $this;
}
/**
* 주문 시점 통화 스냅샷을 주입합니다 (부모 → 자식 리소스 전파).
*
* 관리자가 통화를 삭제하면 현재 설정에서 사라져 자릿수가 폴백 2자리로 바뀐다.
* 그러면 0자리 통화로 결제된 과거 주문의 표기가 `¥14,835` → `¥14,835.00` 이 되고,
* 3자리 이상 통화는 표시 금액이 절사된다. 스냅샷이 있으면 그것을 SSoT 로 삼는다.
*
* @param array|null $snapshot 주문의 `currency_snapshot`
* @return $this 메서드 체이닝을 위한 자기 자신
*/
public function withCurrencySnapshot(?array $snapshot): static
{
$this->currencySnapshot = $snapshot;
return $this;
}
/**
* 다중 통화 가격 정보를 생성합니다.
*
@@ -302,11 +327,20 @@ trait HasMultiCurrencyPrices
/**
* 통화의 소수 자릿수를 반환합니다.
*
* 주문 시점 스냅샷이 주입돼 있고 그 통화의 자릿수를 박제해 두었으면 그것이 SSoT 다
* (공개 #91 후속 — 삭제된 통화가 현재 설정에 없어 폴백 2자리로 바뀌는 것을 막는다).
* 스냅샷이 없으면(상품 등 카탈로그 경로) 현재 설정을 그대로 따른다.
*
* @param string $code 통화 코드
* @return int 소수 자릿수 (기본값: 2)
*/
protected function getDecimalPlacesForCurrency(string $code): int
{
$snapshotPlaces = $this->currencySnapshot['exchange_rates'][$code]['decimal_places'] ?? null;
if ($snapshotPlaces !== null) {
return (int) $snapshotPlaces;
}
$currencies = $this->getCurrencySettings();
foreach ($currencies as $currency) {
@@ -5,9 +5,11 @@ namespace Modules\Sirsoft\Ecommerce\Http\Resources;
use App\Helpers\PermissionHelper;
use App\Http\Resources\BaseApiResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\MissingValue;
use Modules\Sirsoft\Ecommerce\Http\Resources\Concerns\LocalizesCountryName;
use Modules\Sirsoft\Ecommerce\Http\Resources\Traits\HasMultiCurrencyPrices;
use Modules\Sirsoft\Ecommerce\Http\Resources\Traits\SummarizesAdditionalOptions;
use Modules\Sirsoft\Ecommerce\Models\OrderOption;
/**
* 사용자 주문 목록 리소스
@@ -31,6 +33,9 @@ class UserOrderListResource extends BaseApiResource
{
// 주문 시점 기준 통화 — 과거 주문의 *_formatted 는 설정 변경과 무관하게 이 통화로 고정 표기한다.
$orderCurrency = $this->resolveOrderBaseCurrencyCode($this->resource);
// 주문 시점 통화 스냅샷 — 소수 자릿수를 현재 설정이 아닌 주문 시점 값으로 고정 (공개 #91 후속).
$currencySnapshot = $this->resource->currency_snapshot ?? null;
$this->withCurrencySnapshot($currencySnapshot);
// 컬렉션(UserOrderCollection)이 이 배열을 그대로 응답에 실어 Laravel 의 MissingValue
// 제거 단계를 거치지 않는다 — 미충족 조건부 필드를 직접 걸러낸다. 걸러내지 않으면
@@ -98,7 +103,7 @@ class UserOrderListResource extends BaseApiResource
* 주문" 이라는 사실 아닌 단언이 된다.
*
* @param string|null $orderCurrency 주문 시점 기준 통화
* @return array<int, array<string, mixed>>|\Illuminate\Http\Resources\MissingValue 아이템 배열
* @return array<int, array<string, mixed>>|MissingValue 아이템 배열
*/
private function resolveItems(?string $orderCurrency)
{
@@ -117,13 +122,13 @@ class UserOrderListResource extends BaseApiResource
: [];
}
return new \Illuminate\Http\Resources\MissingValue;
return new MissingValue;
}
/**
* 주문 아이템 1건을 표시용 배열로 변환합니다.
*
* @param \Modules\Sirsoft\Ecommerce\Models\OrderOption $option 주문 옵션
* @param OrderOption $option 주문 옵션
* @param string|null $orderCurrency 주문 시점 기준 통화
* @return array<string, mixed> 표시용 아이템 배열
*/
@@ -157,7 +162,7 @@ class UserOrderListResource extends BaseApiResource
* 유무는 값이 아니라 속성 키로 판정한다 — 0건의 `0` 과 "집계 안 함" 은 값으로 구분되지
* 않는다.
*
* @return int|\Illuminate\Http\Resources\MissingValue 아이템 수
* @return int|MissingValue 아이템 수
*/
private function resolveItemCount()
{
@@ -169,7 +174,7 @@ class UserOrderListResource extends BaseApiResource
return $this->resource->options->count();
}
return new \Illuminate\Http\Resources\MissingValue;
return new MissingValue;
}
/**