6
0
Fork 0

调整商品数为0时,去库存提示系统错误

release
vine_liutk 2022-02-16 10:54:44 +08:00
parent 78333acf97
commit 265a1d7d0b
1 changed files with 7 additions and 0 deletions

View File

@ -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);