diff --git a/app/store/controller/Shop.php b/app/store/controller/Shop.php index c0a23048..e349e24f 100644 --- a/app/store/controller/Shop.php +++ b/app/store/controller/Shop.php @@ -97,6 +97,18 @@ class Shop extends Controller return $this->renderError($model->getError() ?: '更新失败'); } + public function updateParking(int $shopId): Json + { + // 门店详情 + $model = ShopModel::detail($shopId); + // 新增记录 + if ($model->editParking($this->postForm())) { + return $this->renderSuccess('更新成功'); + } + return $this->renderError($model->getError() ?: '更新失败'); + } + + /** * 删除门店 * @param int $shopId diff --git a/app/store/model/store/Shop.php b/app/store/model/store/Shop.php index e677b644..6ab723b3 100644 --- a/app/store/model/store/Shop.php +++ b/app/store/model/store/Shop.php @@ -105,6 +105,16 @@ class Shop extends ShopModel $data['remark'] = json_encode($data['remark'], JSON_UNESCAPED_UNICODE); return $this->save($this->createData($data)) !== false; } + + public function editParking(array $data): bool + { + if (!empty($data['parking_coordinate'])) { + $parking_coordinate = explode(',', $data['parking_coordinate']); + $data['parking_latitude'] = $parking_coordinate[0]; + $data['parking_longitude'] = $parking_coordinate[1]; + } + return $this->save($data) !== false; + } /** * 软删除