From 423f8e7ede1fd65c9f43a8694e77dd6f2f4a430a Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Tue, 28 Jun 2022 21:00:49 +0800 Subject: [PATCH] fixed cart --- beike/Shop/Http/Controllers/CartController.php | 2 +- beike/Shop/Services/CartService.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/beike/Shop/Http/Controllers/CartController.php b/beike/Shop/Http/Controllers/CartController.php index ecad57c1..a67c3633 100644 --- a/beike/Shop/Http/Controllers/CartController.php +++ b/beike/Shop/Http/Controllers/CartController.php @@ -56,7 +56,7 @@ class CartController extends Controller * @param $cartId * @return array */ - public function destroy(Request $request,$cartId): array + public function destroy(Request $request, $cartId): array { $customer = current_customer(); CartService::delete($customer, $cartId); diff --git a/beike/Shop/Services/CartService.php b/beike/Shop/Services/CartService.php index b028f97e..2fcaa9bc 100644 --- a/beike/Shop/Services/CartService.php +++ b/beike/Shop/Services/CartService.php @@ -86,6 +86,10 @@ class CartService Cart::query()->where('customer_id', $customer->id) ->whereIn('product_sku_id', $productSkuIds) ->update(['selected' => 1]); + + Cart::query()->where('customer_id', $customer->id) + ->whereNotIn('product_sku_id', $productSkuIds) + ->update(['selected' => 0]); }