6
0
Fork 0

新增商品已下架异常

release
李静 2021-12-08 15:41:45 +08:00
parent eefe2152c0
commit 05a86b9ff1
3 changed files with 13 additions and 3 deletions

View File

@ -3,7 +3,7 @@
namespace App\Endpoint\Api\Http\Controllers;
use App\Endpoint\Api\Http\Resources\ShoppingCartItemResource;
use App\Exceptions\BizException;
use App\Exceptions\ProductOfflineException;
use App\Models\ProductSku;
use Illuminate\Http\Request;
@ -38,7 +38,7 @@ class ShoppingCartItemController extends Controller
$sku = ProductSku::whereRelation('category', 'is_show', true)->online()->find($input['sku_id']);
if ($sku === null) {
throw new BizException(__('Product has been removed'));
throw new ProductOfflineException();
}
$item = $request->user()->shoppingCartItems()->firstOrCreate([

View File

@ -0,0 +1,11 @@
<?php
namespace App\Exceptions;
class ProductOfflineException extends BizException
{
public function __construct(string $message = '商品已下架')
{
parent::__construct($message);
}
}

View File

@ -6,7 +6,6 @@
"Invalid verification code type": "无效的验证码类型",
"Invalid old password": "原密码错误",
"Inviter does not exist": "邀请人不存在",
"Product has been removed": "商品已下架",
"Registration failed, please try again": "注册失败,请重试",
"Sending too frequently, please try again later": "发送过于频繁,请稍后再试",
"The phone number is already registered": "手机号码已被注册",