From 265a1d7d0bf0e5267e9a7292b4dd4da33f58e1a6 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Wed, 16 Feb 2022 10:54:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81=E6=95=B0?= =?UTF-8?q?=E4=B8=BA0=E6=97=B6=EF=BC=8C=E5=8E=BB=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=B3=BB=E7=BB=9F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Http/Controllers/Dealer/UserProductController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/UserProductController.php b/app/Endpoint/Api/Http/Controllers/Dealer/UserProductController.php index d78396e1..702736a9 100644 --- a/app/Endpoint/Api/Http/Controllers/Dealer/UserProductController.php +++ b/app/Endpoint/Api/Http/Controllers/Dealer/UserProductController.php @@ -8,6 +8,7 @@ use App\Endpoint\Api\Http\Resources\Dealer\UserProductResource; use App\Exceptions\BizException; use App\Helpers\Paginator; use App\Models\DealerUserProductLog; +use Illuminate\Database\QueryException; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Throwable; @@ -76,6 +77,12 @@ class UserProductController extends Controller 'remark'=>$input['remark'] ?? null, ]); DB::commit(); + } catch (QueryException $e) { + DB::rollBack(); + if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { + $e = new BizException('库存不足'); + } + throw $e; } catch (Throwable $th) { DB::rollBack(); report($th);