|
|
|
|
@ -553,25 +553,25 @@ class CourseController extends CommonController
|
|
|
|
|
{
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$messages = [
|
|
|
|
|
'longitude.required' => '经度必填',
|
|
|
|
|
'latitude.required' => '纬度必填',
|
|
|
|
|
// 'longitude.required' => '经度必填',
|
|
|
|
|
// 'latitude.required' => '纬度必填',
|
|
|
|
|
'course_content_id.required' => '课表id必填',
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'longitude' => 'required',
|
|
|
|
|
'latitude' => 'required',
|
|
|
|
|
// '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');
|
|
|
|
|
// $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 ($distance > $content_check_range) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '超出打卡范围']);
|
|
|
|
|
}
|
|
|
|
|
// $distance = getDistance($courseContent->longitude, $courseContent->latitude, $all['longitude'], $all['latitude']);
|
|
|
|
|
// if ($distance > $content_check_range) {
|
|
|
|
|
// return $this->fail([ResponseCode::ERROR_BUSINESS, '超出打卡范围']);
|
|
|
|
|
// }
|
|
|
|
|
// 判断当天才能签到
|
|
|
|
|
$today = date('Y-m-d');
|
|
|
|
|
if ($today != $courseContent->date) {
|
|
|
|
|
@ -639,12 +639,12 @@ class CourseController extends CommonController
|
|
|
|
|
$all = \request()->all();
|
|
|
|
|
$messages = [
|
|
|
|
|
'longitude.required' => '经度必填',
|
|
|
|
|
'latitude.required' => '纬度必填',
|
|
|
|
|
'course_id.required' => '课表id必填',
|
|
|
|
|
// 'latitude.required' => '纬度必填',
|
|
|
|
|
// 'course_id.required' => '课表id必填',
|
|
|
|
|
];
|
|
|
|
|
$validator = Validator::make($all, [
|
|
|
|
|
'longitude' => 'required',
|
|
|
|
|
'latitude' => 'required',
|
|
|
|
|
// 'longitude' => 'required',
|
|
|
|
|
// 'latitude' => 'required',
|
|
|
|
|
'course_id' => 'required'
|
|
|
|
|
], $messages);
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
@ -652,14 +652,14 @@ class CourseController extends CommonController
|
|
|
|
|
}
|
|
|
|
|
// 获取打卡范围,千米
|
|
|
|
|
$content_check_range = Config::getValueByKey('content_check_range');
|
|
|
|
|
$course = Course::find($all['course_id']);
|
|
|
|
|
if (empty($course->longitude) || empty($course->latitude)) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '请先设置课程经纬度']);
|
|
|
|
|
}
|
|
|
|
|
$distance = getDistance($course->longitude, $course->latitude, $all['longitude'], $all['latitude']);
|
|
|
|
|
if ($distance > $content_check_range) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_BUSINESS, '超出打卡范围']);
|
|
|
|
|
}
|
|
|
|
|
// $course = Course::find($all['course_id']);
|
|
|
|
|
// if (empty($course->longitude) || empty($course->latitude)) {
|
|
|
|
|
// return $this->fail([ResponseCode::ERROR_BUSINESS, '请先设置课程经纬度']);
|
|
|
|
|
// }
|
|
|
|
|
// $distance = getDistance($course->longitude, $course->latitude, $all['longitude'], $all['latitude']);
|
|
|
|
|
// if ($distance > $content_check_range) {
|
|
|
|
|
// return $this->fail([ResponseCode::ERROR_BUSINESS, '超出打卡范围']);
|
|
|
|
|
// }
|
|
|
|
|
// 判断当天才能签到
|
|
|
|
|
$today = date('Y-m-d');
|
|
|
|
|
if ($today != $course->start_date) {
|
|
|
|
|
|