123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <?php
- namespace App\Http\Controllers\Coach;
- use App\Enums\TechnicianLocationType;
- use App\Http\Controllers\Controller;
- use App\Http\Requests\Coach\SubmitBaseInfoRequest;
- use App\Http\Requests\Coach\SubmitQualificationRequest;
- use App\Http\Requests\Coach\SubmitRealNameRequest;
- use App\Services\Coach\AccountService;
- use App\Traits\ResponseTrait;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- /**
- * @group 技师端
- *
- * 技师账户相关的API接口
- */
- class AccountController extends Controller
- {
- use ResponseTrait;
- protected AccountService $service;
- public function __construct(AccountService $service)
- {
- $this->service = $service;
- }
- /**
- * [账户]提交基本信息
- *
- * @description 提交技师的基本个人信息
- *
- * @authenticated
- *
- * @bodyParam nickname string required 昵称(2-20个字符) Example: 张三
- * @bodyParam avatar string required 头像URL Example: http://example.com/avatar.jpg
- * @bodyParam gender string required 性别(1:男 2:女) Example: 1
- * @bodyParam mobile string required 手机号 Example: 13800138000
- * @bodyParam birthday date required 出生日期(年龄需满18岁) Example: 1990-01-01
- * @bodyParam work_years integer required 工作年限(0-99) Example: 5
- * @bodyParam intention_city string required 意向城市 Example: 北京
- * @bodyParam introduction string required 个人简介(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 string required 资质类型(按摩师/理疗师等) Example: 高级按摩师
- * @bodyParam qual_no string required 资质证书编号(5-50个字符) Example: XZ2024001
- * @bodyParam qual_photo string required 资质证书照片 Example: http://example.com/cert.jpg
- * @bodyParam valid_start date required 有效期开始日期 Example: 2024-01-01
- * @bodyParam valid_end date required 有效期结束日期(必须大于开始日期) Example: 2029-01-01
- *
- * @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 required 姓名(2-20个字符) Example: 张三
- * @bodyParam id_card string required 身份证号(18位) Example: 370602199001011234
- * @bodyParam id_card_front_photo string required 身份证正面照片 Example: http://example.com/front.jpg
- * @bodyParam id_card_back_photo string required 身份证反面照片 Example: http://example.com/back.jpg
- * @bodyParam id_card_hand_photo string required 手持身份证照片 Example: http://example.com/hold.jpg
- *
- * @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": "http://example.com/avatar.jpg",
- * "gender": "1",
- * "mobile": "138****8000",
- * "birthday": "1990-01-01",
- * "work_years": 5,
- * "intention_city": "北京",
- * "introduction": "专业按摩师,从业5年",
- * "state": 1,
- * "audit_remark": "审核通过"
- * },
- * "qualification": {
- * "qual_type": "高级按摩师",
- * "qual_no": "XZ2024001",
- * "qual_photo": "http://example.com/cert.jpg",
- * "valid_start": "2024-01-01",
- * "valid_end": "2029-01-01",
- * "state": 1,
- * "audit_remark": "审核通过"
- * },
- * "real_name": {
- * "real_name": "张三",
- * "id_card": "370602****1234",
- * "id_card_front_photo": "http://example.com/front.jpg",
- * "id_card_back_photo": "http://example.com/back.jpg",
- * "id_card_hand_photo": "http://example.com/hold.jpg",
- * "state": 1,
- * "audit_remark": "审核通过"
- * }
- * }
- * }
- */
- 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 位置类型(1:当前位置 2:常用位置) Example: 2
- *
- * @response {
- * "message": "位置信息设置成功"
- * }
- */
- public function setLocation(Request $request)
- {
- $validated = $request->validate([
- 'latitude' => 'required|numeric|between:-90,90',
- 'longitude' => 'required|numeric|between:-180,180',
- 'type' => 'sometimes|integer|in:1,2',
- ]);
- $result = $this->service->setLocation(
- Auth::user()->coach->id,
- $validated['latitude'],
- $validated['longitude'],
- $validated['type'] ?? TechnicianLocationType::COMMON->value
- );
- 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);
- }
- }
|