From e0e841071bde33be2dd6e33808a89bdc3c788824 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Mon, 4 Jul 2022 18:05:19 +0800 Subject: [PATCH] fixed checkout --- beike/Shop/Services/CheckoutService.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/beike/Shop/Services/CheckoutService.php b/beike/Shop/Services/CheckoutService.php index e90ce3b7..cd06736c 100644 --- a/beike/Shop/Services/CheckoutService.php +++ b/beike/Shop/Services/CheckoutService.php @@ -46,20 +46,23 @@ class CheckoutService public function update($requestData): array { $shippingAddressId = $requestData['shipping_address_id'] ?? 0; + $shippingMethodCode = $requestData['shipping_method_code'] ?? ''; + $paymentAddressId = $requestData['payment_address_id'] ?? 0; - $shippingMethod = $requestData['shipping_method'] ?? ''; - $paymentMethod = $requestData['payment_method'] ?? ''; + $paymentMethodCode = $requestData['payment_method_code'] ?? ''; + if ($shippingAddressId) { $this->updateShippingAddressId($shippingAddressId); } + if ($shippingMethodCode) { + $this->updateShippingMethod($shippingMethodCode); + } + if ($paymentAddressId) { $this->updatePaymentAddressId($shippingAddressId); } - if ($shippingMethod) { - $this->updateShippingMethod($shippingMethod); - } - if ($paymentMethod) { - $this->updatePaymentMethod($paymentMethod); + if ($paymentMethodCode) { + $this->updatePaymentMethod($paymentMethodCode); } return $this->checkoutData(); } @@ -85,14 +88,14 @@ class CheckoutService $this->cart->update(['payment_address_id' => $paymentAddressId]); } - private function updateShippingMethod($shippingMethod) + private function updateShippingMethod($shippingMethodCode) { - $this->cart->update(['shipping_method_code' => $shippingMethod]); + $this->cart->update(['shipping_method_code' => $shippingMethodCode]); } - private function updatePaymentMethod($paymentMethod) + private function updatePaymentMethod($paymentMethodCode) { - $this->cart->update(['payment_method_code' => $paymentMethod]); + $this->cart->update(['payment_method_code' => $paymentMethodCode]); } /**