|
|
|
|
@ -363,7 +363,6 @@ class CourseController extends CommonController
|
|
|
|
|
* path="/api/mobile/course/content-check",
|
|
|
|
|
* tags={"小程序-课程"},
|
|
|
|
|
* summary="签到",
|
|
|
|
|
* @OA\Parameter(name="is_show", in="query", @OA\Schema(type="string"), required=false, description="预览0否1是(返回距离但是不提交签到)"),
|
|
|
|
|
* @OA\Parameter(name="course_content_id", in="query", @OA\Schema(type="string"), required=false, description="课表id"),
|
|
|
|
|
* @OA\Parameter(name="longitude", in="query", @OA\Schema(type="string"), required=false, description="longitude"),
|
|
|
|
|
* @OA\Parameter(name="latitude", in="query", @OA\Schema(type="string"), required=false, description="latitude"),
|
|
|
|
|
@ -377,13 +376,11 @@ class CourseController extends CommonController
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$messages = [
|
|
|
|
|
'is_show.required' => '预览必填',
|
|
|
|
|
'longitude.required' => '经度必填',
|
|
|
|
|
'latitude.required' => '纬度必填',
|
|
|
|
|
'course_content_id.required' => '课程id必填',
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'is_show' => 'required',
|
|
|
|
|
'longitude' => 'required',
|
|
|
|
|
'latitude' => 'required',
|
|
|
|
|
'course_content_id' => 'required'
|
|
|
|
|
@ -395,9 +392,6 @@ class CourseController extends CommonController
|
|
|
|
|
$content_check_range = Config::getValueByKey('content_check_range');
|
|
|
|
|
$courseContent = CourseContent::find($all['course_content_id']);
|
|
|
|
|
$distance = getDistance($courseContent->longitude, $courseContent->latitude, $all['longitude'], $all['latitude']);
|
|
|
|
|
if ($all['is_show'] == 1) {
|
|
|
|
|
return $this->success(compact('distance', 'content_check_range'));
|
|
|
|
|
}
|
|
|
|
|
if ($distance > $content_check_range) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '超出打卡范围']);
|
|
|
|
|
}
|
|
|
|
|
@ -414,7 +408,9 @@ class CourseController extends CommonController
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/api/mobile/course/content-check-list",
|
|
|
|
|
* tags={"小程序-课程"},
|
|
|
|
|
* summary="获取签到记录",
|
|
|
|
|
* summary="获取签到记录和距离",
|
|
|
|
|
* @OA\Parameter(name="longitude", in="query", @OA\Schema(type="string"), required=false, description="longitude"),
|
|
|
|
|
* @OA\Parameter(name="latitude", in="query", @OA\Schema(type="string"), required=false, description="latitude"),
|
|
|
|
|
* @OA\Parameter(name="course_content_id", in="query", @OA\Schema(type="string"), required=false, description="课表id"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response=200,
|
|
|
|
|
@ -426,19 +422,27 @@ class CourseController extends CommonController
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$messages = [
|
|
|
|
|
'longitude.required' => '经度必填',
|
|
|
|
|
'latitude.required' => '纬度必填',
|
|
|
|
|
'course_content_id.required' => '课程id必填',
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'longitude' => 'required',
|
|
|
|
|
'latitude' => 'required',
|
|
|
|
|
'course_content_id' => 'required'
|
|
|
|
|
], $messages);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
// 获取打卡范围,千米
|
|
|
|
|
$content_check_range = Config::getValueByKey('content_check_range');
|
|
|
|
|
$courseContent = CourseContent::find($all['course_content_id']);
|
|
|
|
|
$distance = getDistance($courseContent->longitude, $courseContent->latitude, $all['longitude'], $all['latitude']);
|
|
|
|
|
$list = CourseContentCheck::where('course_content_id', $all['course_content_id'])
|
|
|
|
|
->where('user_id', $this->getUserId())
|
|
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
|
->get();
|
|
|
|
|
return $this->success(compact('list'));
|
|
|
|
|
return $this->success(compact('list', 'content_check_range', 'distance'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|