调整商品数为0时,去库存提示系统错误
parent
78333acf97
commit
265a1d7d0b
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue