From 2a1c61df61118594dc5672b9516bf592aaf095b9 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 14 Jan 2026 13:44:52 +0800 Subject: [PATCH] 1 --- app/common/service/UsedCarService.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/common/service/UsedCarService.php b/app/common/service/UsedCarService.php index 804c980..3d3dc66 100644 --- a/app/common/service/UsedCarService.php +++ b/app/common/service/UsedCarService.php @@ -107,6 +107,26 @@ class UsedCarService return $data; } + public function beforeServiceUpdate($data, Request $request): array + { + if (empty($data['product_name'])) { + throw new BusinessException('产品名称不能为空'); + } + if (empty($data['images'])) { + throw new BusinessException('产品图片不能为空'); + } + if (empty($data['price'])) { + $data['price'] = 0; + } + if (!empty($data['attachment'])) { + $data['attachment'] = json_encode($data['attachment']); + }else{ + $data['attachment'] = ''; + } + $data['mileage'] = str_replace(['K','M','k','m'], '', $data['mileage']); + return $data; + } + public function getcode($userId){ $userCount = Redis::get('used_car_count_'.$userId, 0); $todayStart = strtotime('today');