AccountController.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. namespace App\Http\Controllers\Coach;
  3. use App\Enums\TechnicianLocationType;
  4. use App\Http\Controllers\Controller;
  5. use App\Http\Requests\Coach\SubmitBaseInfoRequest;
  6. use App\Http\Requests\Coach\SubmitQualificationRequest;
  7. use App\Http\Requests\Coach\SubmitRealNameRequest;
  8. use App\Services\Coach\AccountService;
  9. use App\Traits\ResponseTrait;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Support\Facades\Auth;
  12. /**
  13. * @group 技师端
  14. *
  15. * 技师账户相关的API接口
  16. */
  17. class AccountController extends Controller
  18. {
  19. use ResponseTrait;
  20. protected AccountService $service;
  21. public function __construct(AccountService $service)
  22. {
  23. $this->service = $service;
  24. }
  25. /**
  26. * [账户]提交基本信息
  27. *
  28. * @description 提交技师的基本个人信息
  29. *
  30. * @authenticated
  31. *
  32. * @bodyParam nickname string required 昵称(2-20个字符) Example: 张三
  33. * @bodyParam avatar string required 头像URL Example: http://example.com/avatar.jpg
  34. * @bodyParam gender string required 性别(1:男 2:女) Example: 1
  35. * @bodyParam mobile string required 手机号 Example: 13800138000
  36. * @bodyParam birthday date required 出生日期(年龄需满18岁) Example: 1990-01-01
  37. * @bodyParam work_years integer required 工作年限(0-99) Example: 5
  38. * @bodyParam intention_city string required 意向城市 Example: 北京
  39. * @bodyParam introduction string required 个人简介(10-255个字符) Example: 专业按摩师,从业5年
  40. *
  41. * @response {
  42. * "message": "基本信息提交成功"
  43. * }
  44. */
  45. public function submitBaseInfo(SubmitBaseInfoRequest $request)
  46. {
  47. $data = $request->validated();
  48. return $this->success($this->service->submitBaseInfo(Auth::user(), $data));
  49. }
  50. /**
  51. * [账户]提交资质信息
  52. *
  53. * @description 提交技师的资质认证信息
  54. *
  55. * @authenticated
  56. *
  57. * @bodyParam qual_type string required 资质类型(按摩师/理疗师等) Example: 高级按摩师
  58. * @bodyParam qual_no string required 资质证书编号(5-50个字符) Example: XZ2024001
  59. * @bodyParam qual_photo string required 资质证书照片 Example: http://example.com/cert.jpg
  60. * @bodyParam valid_start date required 有效期开始日期 Example: 2024-01-01
  61. * @bodyParam valid_end date required 有效期结束日期(必须大于开始日期) Example: 2029-01-01
  62. *
  63. * @response {
  64. * "message": "资质信息提交成功"
  65. * }
  66. */
  67. public function submitQualification(SubmitQualificationRequest $request)
  68. {
  69. $data = $request->validated();
  70. return $this->success($this->service->submitQualification(Auth::user(), $data));
  71. }
  72. /**
  73. * [账户]提交实名认证
  74. *
  75. * @description 提交技师的实名认证信息
  76. *
  77. * @authenticated
  78. *
  79. * @bodyParam real_name string required 姓名(2-20个字符) Example: 张三
  80. * @bodyParam id_card string required 身份证号(18位) Example: 370602199001011234
  81. * @bodyParam id_card_front_photo string required 身份证正面照片 Example: http://example.com/front.jpg
  82. * @bodyParam id_card_back_photo string required 身份证反面照片 Example: http://example.com/back.jpg
  83. * @bodyParam id_card_hand_photo string required 手持身份证照片 Example: http://example.com/hold.jpg
  84. *
  85. * @response {
  86. * "message": "实名认证信息提交成功"
  87. * }
  88. */
  89. public function submitRealName(SubmitRealNameRequest $request)
  90. {
  91. $data = $request->validated();
  92. return $this->success($this->service->submitRealName(Auth::user(), $data));
  93. }
  94. /**
  95. * [账户]获取技师信息
  96. *
  97. * @description 获取技师的基本信息、资质信息和实名信息
  98. *
  99. * @authenticated
  100. *
  101. * @response {
  102. * "data": {
  103. * "base_info": {
  104. * "nickname": "张三",
  105. * "avatar": "http://example.com/avatar.jpg",
  106. * "gender": "1",
  107. * "mobile": "138****8000",
  108. * "birthday": "1990-01-01",
  109. * "work_years": 5,
  110. * "intention_city": "北京",
  111. * "introduction": "专业按摩师,从业5年",
  112. * "state": 1,
  113. * "audit_remark": "审核通过"
  114. * },
  115. * "qualification": {
  116. * "qual_type": "高级按摩师",
  117. * "qual_no": "XZ2024001",
  118. * "qual_photo": "http://example.com/cert.jpg",
  119. * "valid_start": "2024-01-01",
  120. * "valid_end": "2029-01-01",
  121. * "state": 1,
  122. * "audit_remark": "审核通过"
  123. * },
  124. * "real_name": {
  125. * "real_name": "张三",
  126. * "id_card": "370602****1234",
  127. * "id_card_front_photo": "http://example.com/front.jpg",
  128. * "id_card_back_photo": "http://example.com/back.jpg",
  129. * "id_card_hand_photo": "http://example.com/hold.jpg",
  130. * "state": 1,
  131. * "audit_remark": "审核通过"
  132. * }
  133. * }
  134. * }
  135. */
  136. public function info()
  137. {
  138. return $this->success($this->service->getCoachInfo(Auth::user()));
  139. }
  140. /**
  141. * [账户]设置技师位置信息
  142. *
  143. * @description 设置技师的当前位置或常用位置
  144. *
  145. * @authenticated
  146. *
  147. * @bodyParam latitude float required 纬度 Example: 39.9042
  148. * @bodyParam longitude float required 经度 Example: 116.4074
  149. * @bodyParam type int 位置类型(1:当前位置 2:常用位置) Example: 2
  150. *
  151. * @response {
  152. * "message": "位置信息设置成功"
  153. * }
  154. */
  155. public function setLocation(Request $request)
  156. {
  157. $validated = $request->validate([
  158. 'latitude' => 'required|numeric|between:-90,90',
  159. 'longitude' => 'required|numeric|between:-180,180',
  160. 'type' => 'sometimes|integer|in:1,2',
  161. ]);
  162. $result = $this->service->setLocation(
  163. Auth::user()->coach->id,
  164. $validated['latitude'],
  165. $validated['longitude'],
  166. $validated['type'] ?? TechnicianLocationType::COMMON->value
  167. );
  168. return $this->success(['message' => '位置信息设置成功']);
  169. }
  170. /**
  171. * [账户]获取技师位置信息
  172. *
  173. * @description 获取技师的当前位置和常用位置信息
  174. *
  175. * @authenticated
  176. *
  177. * @response {
  178. * "data": {
  179. * "current": {
  180. * "address": "北京市朝阳区建国路93号万达广场"
  181. * },
  182. * "common": {
  183. * "address": "北京市海淀区中关村大街1号"
  184. * }
  185. * }
  186. *idid
  187. */
  188. public function getLocation()
  189. {
  190. $result = $this->service->getLocation(Auth::user()->id);
  191. return $this->success($result);
  192. }
  193. }