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