diff --git a/app/api/controller/Square.php b/app/api/controller/Square.php index c9ee1650..b3ed276b 100644 --- a/app/api/controller/Square.php +++ b/app/api/controller/Square.php @@ -58,6 +58,21 @@ class Square extends Controller return $this->renderError('添加失败'); } + /** + * 删除门店 + * @param int $shopId + * @return Json + */ + public function delete(int $squareId): Json + { + // 门店详情 + $model = squareModel::detail($squareId, $this->storeId); + if (!$model->setDelete()) { + return $this->renderError($model->getError() ?: '删除失败'); + } + return $this->renderSuccess('删除成功'); + } + /** * 列表 diff --git a/app/api/model/Square.php b/app/api/model/Square.php index 57c8ae06..27ba604a 100644 --- a/app/api/model/Square.php +++ b/app/api/model/Square.php @@ -31,6 +31,21 @@ class Square extends \app\common\model\Square return $this->save($data) !== false; } + /** + * 详情信息 + * @param int $storeId + * @return static|array|null + */ + public static function detail(int $squareId, $store_id = 0) + { + $store_id = $store_id ? $store_id : self::$storeId; + $where = [ + 'square_id' => $squareId, + 'store_id' => $store_id + ]; + return static::get($where, []); + } + /** * 新增记录 * @param array $data