service = $service; } /** * [账户]提交基本信息 * * @description 提交技师的基本个人信息,包括头像、生活照片、个人资料等 * * 业务流程: * 1. 验证提交的数据 * 2. 调用服务层处理业务逻辑 * 3. 返回处理结果 * * 注意事项: * - 同一时间只能有一条待审核记录 * - 审核不通过可以重新提交 * - 头像和生活照片支持任意格式的图片数据 * - 除性别和手机号外,其他字段均为可选 * - 生活照片为可选,支持多张 * * @authenticated 需要技师身份认证 * * @bodyParam nickname string nullable 昵称(2-20个字符) Example: 张三 * @bodyParam avatar string nullable 头像图片 Example: base64或其他格式的图片数据 * @bodyParam life_photos array nullable 生活照片数组 * @bodyParam life_photos.* string required 生活照片 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 200 { * "status": true, * "message": "基本信息提交成功" * } * @response 404 { * "message": "技师信息不存在" * } * @response 422 { * "message": "已有待审核的基本信息记录" * } * @response 422 { * "message": "验证错误", * "errors": { * "nickname": ["昵称不能少于2个字符"], * "gender": ["性别不能为空"], * "mobile": ["手机号不能为空"], * "life_photos.*": ["生活照片格式不正确"] * } * } */ 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或其他格式的图片数据", * "life_photos": [ * "base64或其他格式的图片数据1", * "base64或其他格式的图片数据2" * ], * "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 * * @queryParam type int 位置类型(1:当前位置 2:常用位置) Example: 2 * * @response { * "data": { * "province": "浙江省", * "city": "杭州市", * "district": "西湖区", * "address": "文三路478号", * "adcode": "330106", * "longitude": 120.12345, * "latitude": 30.12345, * "updated_at": "2024-03-22 10:00:00" * } * } */ public function getLocation(Request $request) { $validated = $request->validate([ 'type' => 'required|integer|in:1,2' ]); return $this->success( $this->service->getLocation(Auth::user(), $validated['type']) ); } /** * [账户]设置排班时间 * * @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); } /** * [账户]获取技师详细信息 * * @description 获取当前登录技师的详细信息,包括基本信息、邀请码和钱包信息 * * 业务流程: * 1. 验证用户身份 * 2. 获取技师详细信息 * 3. 返回数据 * * @authenticated 需要技师身份认证 * * @response 200 { * "status": true, * "message": "获取成功", * "data": { * "coach_no": "00000001", * "mobile": "13800138000", * "nickname": "张三", * "avatar": "https://example.com/avatar.jpg", * "age": 25, * "gender": 1, * "work_years": 5, * "intention_city": "杭州", * "life_photos": [ * "https://example.com/photo1.jpg", * "https://example.com/photo2.jpg" * ], * "introduction": "专业按摩师,从业5年", * "state": 1, * "state_text": "正常", * "invite_code": "C1", * "wallet": { * "balance": 1000, * "frozen": 200, * "total_income": 5000, * "today_income": 300, * "withdrawable": 800 * } * } * } * @response 404 { * "message": "技师信息不存在" * } */ public function detail() { // 获取技师详细信息 $data = $this->service->getCoachDetail(); // 返回成功响应 return $this->success($data, '获取成功'); } /** * [账户]更新基础信息 * * @description 更新技师的基础信息,包括昵称、性别和手机号 * * @authenticated 需要技师身份认证 * * @bodyParam nickname string nullable 昵称(2-20个字符) Example: 张三 * @bodyParam gender integer nullable 性别(1:男 2:女) Example: 1 * @bodyParam mobile string nullable 手机号 Example: 13800138000 * * @response { * "status": true, * "message": "基础信息修改申请已提交", * "data": { * "record_id": 1, * "updated_fields": ["nickname", "gender"] * } * } */ public function updateBasicInfo(UpdateBasicInfoRequest $request) { return $this->success( $this->service->updateBasicInfo(Auth::user()->coach, $request->validated()) ); } }