Эх сурвалжийг харах

优化订单系统删除购物车中的广告位

15313670163 2 сар өмнө
parent
commit
8ab974e493

+ 6 - 1
app/JsonRpc/OrderService.php

@@ -852,7 +852,12 @@ class OrderService implements OrderServiceInterface
         if (empty($shop)) {
             return Result::error("不存在此条记录!(参数错误)"); 
         }else{
-            $result = ShoppingCart::where('shopping_id', $shop['shopping_id'])->where('user_id',$data['user_id'])->where('pid',$data['pid'])->delete();
+            $count = ShoppingCart::where('shopping_id', $data['shopping_id'])->where('user_id',$data['user_id'])->count();
+            if($count == 1){
+                $result = ShoppingCart::where('shopping_id', $data['shopping_id'])->where('user_id',$data['user_id'])->update(['pid' => null, 'website_id' => null]);; 
+            }else{
+                $result = ShoppingCart::where('shopping_id', $shop['shopping_id'])->where('user_id',$data['user_id'])->where('pid',$data['pid'])->delete();
+            } 
         }
         if(empty($result)){
             return Result::error("删除失败");