diff --git a/plugs/think-plugs-inspection/src/controller/api/auth/Record.php b/plugs/think-plugs-inspection/src/controller/api/auth/Record.php index 8f0f1ac..5c90995 100644 --- a/plugs/think-plugs-inspection/src/controller/api/auth/Record.php +++ b/plugs/think-plugs-inspection/src/controller/api/auth/Record.php @@ -48,16 +48,18 @@ class Record extends Auth } $lat = $this->request->post('lat'); $lng = $this->request->post('lng'); + if ($lat != 0 || $lng != 0) { + $record->points()->save([ + 'staff_id' => $this->staff->id, + 'lat' => $lat, + 'lng' => $lng, + 'is_pause' => 1, + 'create_at' => date('Y-m-d H:i:s'), + ]); + } $record->status = 1; $record->imgs = $result['imgs']; $record->content = $result['content']; - $record->points()->save([ - 'staff_id' => $this->staff->id, - 'lat' => $lat, - 'lng' => $lng, - 'is_pause' => 1, - 'create_at' => date('Y-m-d H:i:s'), - ]); $record->end_at = date('Y-m-d H:i:s'); $record->save(); $record->autoFix(); @@ -74,13 +76,17 @@ class Record extends Auth if (empty($record)) { $this->error('记录不存在'); } - $point = $record->points()->save([ - 'staff_id' => $this->staff->id, - 'is_pause' => $this->request->post('is_pause', 0), - 'lat' => $lat, - 'lng' => $lng, - 'create_at' => date('Y-m-d H:i:s'), - ]); + if ($lat != 0 || $lng != 0) { + $point = $record->points()->save([ + 'staff_id' => $this->staff->id, + 'is_pause' => $this->request->post('is_pause', 0), + 'lat' => $lat, + 'lng' => $lng, + 'create_at' => date('Y-m-d H:i:s'), + ]); + } else { + $point = []; + } $record->autoFix(); $record->save(); $this->success('添加点成功', $point);