Browse Source

购物车数量为0时执行删除操作

master
Lemon 5 years ago
parent
commit
2ac9f20fe7
  1. 12
      app/Controller/v3/ShopCartUpdateController.php

12
app/Controller/v3/ShopCartUpdateController.php

@ -5,6 +5,7 @@ namespace App\Controller\v3;
use App\Constants\v3\ErrorCode;
use App\Controller\BaseController;
use App\Exception\ErrorCodeException;
use App\Model\v3\ShoppingCart;
use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\ShopCartUpdateServiceInterface;
@ -28,7 +29,15 @@ class ShopCartUpdateController extends BaseController
$goodsId = $this->request->input('goods_id',0);
$num = $this->request->input('num',0);
$activityType = $this->request->input('activity_type',1);
if($num <= 0){
$shopcartIds = ShoppingCart::query()->where([
'user_id' => $userId,
'goods_id' => $goodsId,
'activity_type' => $activityType
])
->value('id');
$res = $this->shopCarServiceUpdate->undo($shopcartIds);
}else{
if ($activityType == 2) {
// TODO 校验当前用户今天是否超过了购买活动秒杀商品的(特定价格)的订单笔数
if (!$this->orderOnlineService->checkIfBuyFlashGoodsToday($userId)) {
@ -41,6 +50,7 @@ class ShopCartUpdateController extends BaseController
}
$res = $this->shopCarServiceUpdate->do($userId,$goodsId,$num,$activityType);
}
return $this->success($res);
}

Loading…
Cancel
Save