状态更新

This commit is contained in:
2026-01-16 15:15:36 +08:00
parent 1f3d66c58e
commit dde8e88106
3 changed files with 26 additions and 0 deletions
@@ -43,6 +43,20 @@ class UsedCarController extends BaseController
$this->service = new UsedCarService();
}
/**
* 更新状态
* @return \support\Response
*/
public function status(Request $request){
try {
$data = $request->post();
$res = $this->service->serviceUpdateStatus($request, $data);
return $this->success([], '更新成功');
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
/**
* 列表页数据格式化
*
+11
View File
@@ -132,6 +132,17 @@ class UsedCarService
return $data;
}
public function serviceUpdateStatus(Request $request, array $data)
{
if (empty($data['id'])) {
throw new BusinessException('id不能为空');
}
if (!isset($data['status'])) {
throw new BusinessException('status错误');
}
return UsedCar::where('id', $data['id'])->update(['status' => $data['status']]);
}
public function getcode($userId){
$userCount = Redis::get('used_car_count_'.$userId, 0);
$todayStart = strtotime('today');