service = $service; } /** * [账户]提交基本信息 * * @description 提交技师的基本个人信息 * * @authenticated * * @bodyParam nickname string nullable 昵称(2-20个字符) Example: 张三 * @bodyParam avatar string nullable 头像图片 Example: base64或其他格式的图片数据 * @bodyParam gender string required 性别(1:男 2:女) Example: 1 * @bodyParam mobile string required 手机号 Example: 13800138000 * @bodyParam birthday date nullable 出生日期(年龄需满18岁) Example: 1990-01-01 * @bodyParam work_years integer nullable 工作年限(0-99) Example: 5 * @bodyParam intention_city string nullable 意向城市 Example: 北京 * @bodyParam introduction string nullable 个人简介(10-255个字符) Example: 专业按摩师,从业5年 * * @response { * "message": "基本信息提交成功" * } */ public function submitBaseInfo(SubmitBaseInfoRequest $request) { $data = $request->validated(); return $this->success($this->service->submitBaseInfo(Auth::user(), $data)); } /** * [账户]提交资质信息 * * @description 提交技师的资质认证信息,包括资质照片、营业执照和健康证 * * @authenticated * * @bodyParam qual_type int required 资质类型(1:初级按摩师 2:中级按摩师 3:高级按摩师) Example: 1 * @bodyParam qual_photo string required 资质证书照片 Example: base64或其他格式的图片数据 * @bodyParam business_license string required 营业执照照片 Example: base64或其他格式的图片数据 * @bodyParam health_cert string required 健康证照片 Example: base64或其他格式的图片数据 * * @response { * "message": "资质信息提交成功" * } */ public function submitQualification(SubmitQualificationRequest $request) { $data = $request->validated(); return $this->success($this->service->submitQualification(Auth::user(), $data)); } /** * [账户]提交实名认证 * * @description 提交技师的实名认证信息 * * @authenticated * * @bodyParam real_name string nullable 姓名(2-20个字符) Example: 张三 * @bodyParam id_card string nullable 身份证号(18位) Example: 370602199001011234 * @bodyParam id_card_front_photo string required 身份证正面照片 Example: base64或其他格式的图片数据 * @bodyParam id_card_back_photo string required 身份证反面照片 Example: base64或其他格式的图片数据 * @bodyParam id_card_hand_photo string required 手持身份证照片 Example: base64或其他格式的图片数据 * * @response { * "message": "实名认证信息提交成功" * } */ public function submitRealName(SubmitRealNameRequest $request) { $data = $request->validated(); return $this->success($this->service->submitRealName(Auth::user(), $data)); } /** * [账户]获取技师信息 * * @description 获取技师的基本信息、资质信息和实名认证信息 * * @authenticated * * @response { * "data": { * "base_info": { * "nickname": "张三", * "avatar": "base64或其他格式的图片数据", * "gender": "1", * "mobile": "138****8000", * "birthday": "1990-01-01", * "work_years": 5, * "intention_city": "北京", * "introduction": "专业按摩师,从业5年", * "state": 1, * "state_text": "已通过", * "audit_remark": "审核通过" * }, * "qualification": { * "qual_type": "高级按摩师", * "qual_photo": "base64或其他格式的图片数据", * "business_license": "base64或其他格式的图片数据", * "health_cert": "base64或其他格式的图片数据", * "state": 1, * "state_text": "已通过", * "audit_remark": "审核通过" * }, * "real_name": { * "real_name": "张三", * "id_card": "370602****1234", * "id_card_front_photo": "base64或其他格式的图片数据", * "id_card_back_photo": "base64或其他格式的图片数据", * "id_card_hand_photo": "base64或其他格式的图片数据", * "state": 1, * "state_text": "已通过", * "audit_remark": "审核通过" * } * } * } * @response 404 { * "message": "用户不存在" * } * @response 404 { * "message": "技师信息不存在" * } */ public function info() { return $this->success($this->service->getCoachInfo(Auth::user())); } /** * [账户]设置技师位置信息 * * @description 设置技师的当前位置或常用位置 * * @authenticated * * @bodyParam latitude float required 纬度 Example: 39.9042 * @bodyParam longitude float required 经度 Example: 116.4074 * @bodyParam type int nullable 位置类型(1:当前位置 2:常用位置) Example: 2 * @bodyParam province string nullable 省份 Example: 北京市 * @bodyParam city string nullable 城市 Example: 北京市 * @bodyParam district string nullable 区县 Example: 朝阳区 * @bodyParam address string nullable 详细地址 Example: 建国路93号万达广场 * @bodyParam adcode string nullable 行政区划代码 Example: 110105 * * @response { * "message": "位置信息设置成功" * } */ public function setLocation(SetLocationRequest $request) { // 获取验证后的数据 $validated = $request->validated(); // 确保用户和技师存在 $user = Auth::user(); abort_if(!$user->coach, 404, '技师信息不存在'); // 提取位置信息 $locationInfo = $this->extractLocationInfo($validated); // 传递技师ID给服务层 $this->service->setLocation( $user->coach->id, $validated['latitude'], $validated['longitude'], $validated['type'] ?? TechnicianLocationType::COMMON->value, $locationInfo ); return $this->success(['message' => '位置信息设置成功']); } /** * [账户]获取技师位置信息 * * @description 取技师的当前位置和常用位置信息 * * @authenticated * * @response { * "data": { * "current": { * "address": "北京市朝阳区建国路93号万达广场" * }, * "common": { * "address": "北京市海淀区中关村大街1号" * } * } *idid */ public function getLocation() { $result = $this->service->getLocation(Auth::user()->id); return $this->success($result); } /** * [账户]设置排班时间 * * @description 设置技师每天通用的排班时间段 * * @authenticated * * @bodyParam time_ranges array required 时间段数组 * @bodyParam time_ranges[].start_time string required 开始时间(HH:mm格式) Example: "09:00" * @bodyParam time_ranges[].end_time string required 结束时间(HH:mm格式) Example: "12:00" * * @response { * "status": true, * "message": "排班设置成功", * "data": { * "coach_id": 1, * "time_ranges": [ * { * "start_time": "09:00", * "end_time": "12:00" * }, * { * "start_time": "14:00", * "end_time": "18:00" * } * ] * } * } * @response 400 { * "message": "时间段格式错误" * } * @response 400 { * "message": "时间格式错误,应为HH:mm格式" * } * @response 400 { * "message": "结束时间必须大于开始时间" * } * @response 400 { * "message": "时间段之间不能重叠" * } */ public function setSchedule(Request $request) { $validated = $request->validate([ 'time_ranges' => 'required|array|min:1', 'time_ranges.*.start_time' => [ 'required', 'string', 'regex:/^([01][0-9]|2[0-3]):[0-5][0-9]$/', ], 'time_ranges.*.end_time' => [ 'required', 'string', 'regex:/^([01][0-9]|2[0-3]):[0-5][0-9]$/', ], ], [ 'time_ranges.required' => '必须设置时间段', 'time_ranges.array' => '时间段必须是数组格式', 'time_ranges.min' => '至少设置一个时间段', 'time_ranges.*.start_time.required' => '开始时间不能为空', 'time_ranges.*.start_time.regex' => '开始时间格式错误,应为HH:mm格式', 'time_ranges.*.end_time.required' => '结束时间不能为空', 'time_ranges.*.end_time.regex' => '结束时间格式错误,应为HH:mm格式', ]); return $this->success( $this->service->setSchedule(Auth::user()->id, $validated['time_ranges']) ); } /** * [账户]更改技师工作状态 * * @description 更改技师的工作状态(休息中/工作中),工作状态会自动判断为空闲或忙碌 * * @authenticated * * @bodyParam status int required 状态(1:休息中 2:工作中) Example: 2 * * @response { * "status": true, * "message": "状态更新成功", * "data": { * "work_status": 2, * "work_status_text": "空闲中", * "updated_at": "2024-03-20 10:00:00" * } * } * @response 400 { * "message": "无效的状态值" * } * @response 422 { * "message": "当前状态不能更改为休息状态" * } */ public function updateWorkStatus(Request $request) { $validated = $request->validate([ 'status' => 'required|integer|in:1,2', ], [ 'status.required' => '状态不能为空', 'status.integer' => '状态必须是整数', 'status.in' => '无效的状态值', ]); return $this->success( $this->service->updateWorkStatus(Auth::user()->id, $validated['status']) ); } /** * [账户]获取技师工作状态 * * @description 获取技师当前工作状态 * * @authenticated * * @response { * "data": { * "work_status": 2, * "work_status_text": "空闲中", * "updated_at": "2024-03-22 10:00:00" * } * } * @response 404 { * "message": "技师不存在" * } */ public function getWorkStatus() { return $this->success( $this->service->getWorkStatus(Auth::user()->coach->id) ); } /** * [账户]获取技师排班信息 * * @return \Illuminate\Http\JsonResponse * * @description 技师获取自己的排班时间段信息 * * @response { * "status": true, * "message": "获取成功", * "data": { * "time_ranges": [ * { * "start_time": "09:00", * "end_time": "12:00" * }, * { * "start_time": "14:00", * "end_time": "18:00" * } * ], * "updated_at": "2024-03-20 10:00:00" * } * } */ public function getSchedule() { $schedule = $this->service->getSchedule(Auth::id()); return $this->success($schedule); } }