shippingAmount + $this->extraShippingAmount; } /** * 실제 적용 배송비 (할인 후)를 반환합니다. * * @return int 실제 배송비 (총 배송비 - 할인) */ public function getNetShippingAmount(): int { return max(0, $this->totalShippingAmount - $this->shippingDiscountAmount); } /** * 배열로 변환합니다. */ public function toArray(): array { return [ 'policy_id' => $this->policyId, 'policy_name' => $this->policyName, 'country_code' => $this->countryCode, 'charge_policy' => $this->chargePolicy, 'shipping_amount' => $this->shippingAmount, 'shipping_amount_formatted' => ecommerce_format_price($this->shippingAmount), 'extra_shipping_amount' => $this->extraShippingAmount, 'extra_shipping_amount_formatted' => ecommerce_format_price($this->extraShippingAmount), 'total_shipping_amount' => $this->totalShippingAmount, 'total_shipping_amount_formatted' => ecommerce_format_price($this->totalShippingAmount), 'shipping_discount_amount' => $this->shippingDiscountAmount, 'shipping_discount_amount_formatted' => ecommerce_format_price($this->shippingDiscountAmount), 'standalone_shipping_amount' => $this->standaloneShippingAmount, 'standalone_shipping_amount_formatted' => ecommerce_format_price($this->standaloneShippingAmount), 'hook_overridden' => $this->hookOverridden, 'policy_snapshot' => $this->policySnapshot, ]; } /** * 배열에서 DTO를 생성합니다. * * @param array $data 배열 데이터 */ public static function fromArray(array $data): self { return new self( policyId: $data['policy_id'] ?? 0, policyName: $data['policy_name'] ?? '', countryCode: $data['country_code'] ?? 'KR', chargePolicy: $data['charge_policy'] ?? '', shippingAmount: $data['shipping_amount'] ?? 0, extraShippingAmount: $data['extra_shipping_amount'] ?? 0, totalShippingAmount: $data['total_shipping_amount'] ?? 0, shippingDiscountAmount: $data['shipping_discount_amount'] ?? 0, policySnapshot: $data['policy_snapshot'] ?? [], standaloneShippingAmount: $data['standalone_shipping_amount'] ?? 0, hookOverridden: $data['hook_overridden'] ?? false, ); } }