fix(ecommerce,basic): 배송정책 스냅샷 형태 정규화로 주문 상세 배송정보 누락 해소
마이페이지·비회원 주문 상세에서 상품별 배송정책명과 개별 배송비 줄이 아무 안내 없이 통째로 사라졌다. 주문에 보관하는 배송정책 스냅샷이 항목 목록과 배송지 메타를 한 배열에 섞어 담고 있어, PHP 배열이 non-sequential 이 되면서 json_encode 가 리스트가 아니라 객체로 직렬화했기 때문이다. 서버 소비자는 정수 키 판별로 관용 처리해 무사했고 배열을 전제한 화면만 죽었다. 한 컬럼에 두 의미를 담은 구조 자체를 items + address 로 분리했다. 이미 저장된 주문은 화면만 고쳐서는 낫지 않으므로 업그레이드 스텝으로 함께 정규화한다.
This commit is contained in:
1 parent
19789433df
commit
0ae3289c60
11 files changed
+462
-29
No files matched your search
@@ -36,6 +36,7 @@ use Modules\Sirsoft\Ecommerce\Repositories\Contracts\OrderRepositoryInterface;
|
||||
use Modules\Sirsoft\Ecommerce\Repositories\Contracts\ProductOptionRepositoryInterface;
|
||||
use Modules\Sirsoft\Ecommerce\Repositories\Contracts\ProductRepositoryInterface;
|
||||
use Modules\Sirsoft\Ecommerce\Repositories\Contracts\ShippingTypeRepositoryInterface;
|
||||
use Modules\Sirsoft\Ecommerce\Support\ShippingPolicySnapshot;
|
||||
use Modules\Sirsoft\Ecommerce\Support\VatCalculator;
|
||||
|
||||
/**
|
||||
@@ -1428,10 +1429,10 @@ class OrderProcessingService
|
||||
*/
|
||||
protected function buildShippingPolicyAppliedSnapshot(OrderCalculationResult $result, array $shippingInfo = []): array
|
||||
{
|
||||
$policies = [];
|
||||
$items = [];
|
||||
foreach ($result->items as $item) {
|
||||
if ($item->appliedShippingPolicy) {
|
||||
$policies[] = [
|
||||
$items[] = [
|
||||
'product_option_id' => $item->productOptionId,
|
||||
'policy' => $item->appliedShippingPolicy->toArray(),
|
||||
];
|
||||
@@ -1439,13 +1440,16 @@ class OrderProcessingService
|
||||
}
|
||||
|
||||
// 배송지(국가/우편번호) 스냅샷 보존 (B5 — 환불/취소 재계산 시 도서산간/국가별 정책 판단 복원).
|
||||
// OrderAdjustmentService::buildRecalcInput 가 'address' 키로 ShippingAddress 를 복원한다.
|
||||
$policies['address'] = [
|
||||
//
|
||||
// 항목 목록과 배송지 메타는 **별도 키**로 분리한다. 종전에는 `$policies[]` 리스트에
|
||||
// `$policies['address']` 를 덧붙여 한 배열에 섞었고, 그 결과 PHP 배열이
|
||||
// non-sequential 이 되어 `json_encode` 가 객체로 직렬화했다. 서버는 `is_int($key)` 로
|
||||
// 버텼지만 배열을 전제하는 프론트에서 `.find is not a function` 이 나며 마이페이지·
|
||||
// 비회원 주문 상세의 배송정책 블록이 조용히 사라졌다.
|
||||
return ShippingPolicySnapshot::make($items, [
|
||||
'country_code' => strtoupper((string) ($shippingInfo['country_code'] ?? 'KR')),
|
||||
'zipcode' => $shippingInfo['zipcode'] ?? $shippingInfo['intl_postal_code'] ?? null,
|
||||
];
|
||||
|
||||
return $policies;
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user