|
@@ -1077,6 +1077,26 @@ class AccountService
|
|
|
return Redis::geoadd('coach_locations', $longitude, $latitude, $key);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取技师最新基本信息
|
|
|
+ *
|
|
|
+ * @param CoachUser $coach 技师对象
|
|
|
+ * @return CoachInfoRecord 最新的基本信息记录
|
|
|
+ * @throws \Illuminate\Http\Exceptions\HttpResponseException 当信息不存在时抛出404异常
|
|
|
+ */
|
|
|
+ private function getLatestBaseInfo(CoachUser $coach): CoachInfoRecord
|
|
|
+ {
|
|
|
+ // 获取最新的技师信息记录(排除审核拒绝的记录)
|
|
|
+ $latestInfo = $coach->infoRecords()
|
|
|
+ ->where('state', '<>', TechnicianAuthStatus::REJECTED->value)
|
|
|
+ ->latest()
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ abort_if(!$latestInfo, 404, '技师基本信息不存在');
|
|
|
+
|
|
|
+ return $latestInfo;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取技师详细信息
|
|
|
*
|
|
@@ -1099,12 +1119,8 @@ class AccountService
|
|
|
$coach = $user->coach;
|
|
|
abort_if(!$coach, 404, '技师信息不存在');
|
|
|
|
|
|
- // 获取最新的技师信息记录(排除审核拒绝的记录)
|
|
|
- $latestInfo = CoachInfoRecord::where('coach_id', $coach->id)
|
|
|
- ->where('state', '<>', TechnicianAuthStatus::REJECTED->value)
|
|
|
- ->latest()
|
|
|
- ->first();
|
|
|
- abort_if(!$latestInfo, 404, '技师基本信息不存在');
|
|
|
+ // 获取最新的基本信息记录
|
|
|
+ $latestInfo = $this->getLatestBaseInfo($coach);
|
|
|
|
|
|
// 生成技师工号(例如:8位数字,不足前面补0)
|
|
|
$coachNo = str_pad($coach->id, 8, '0', STR_PAD_LEFT);
|