From b7b94971d243939e17e5e0f31040583f2e2603f2 Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:14:05 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E5=A2=9E=E5=8A=A0getNofly=20=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=A6=81=E9=A3=9E=E5=8C=BA=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=95=86=E9=93=BA=E8=B4=A6=E5=8F=B7=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E8=AE=BF=E9=97=AE=E6=8E=A5=E5=8F=A3=20=E8=A1=A8?= =?UTF-8?q?=E9=87=8C=E5=B9=B6=E6=B2=A1=E5=AF=B9=E5=BA=94=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=20=E9=A1=BA=E4=BE=BF=E5=88=9B=E5=BB=BA=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E5=95=86=E9=93=BA=E7=9A=84=E8=AE=B0=E5=BD=95=20=E3=80=90?= =?UTF-8?q?=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PlaneController.class.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index 02103ad..b14156d 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -542,6 +542,37 @@ class PlaneController extends PublicController echo json_encode(array('status' => 0, 'msg' => '参数有误')); } } + /** + * @description: 获取禁飞区数据(如果没有就插入空记录) + */ + public function getNofly() + { + if ($this->tokenShop_id != C('powerId')) { // 非总管理员 + $where['shop_id'] = $this->tokenShop_id; + } else { + $where['shop_id'] = $_REQUEST['shopId']; // 总管理员可指定 shop_id + } + + $noflyDb = D('nofly'); + $field = array('id', 'shop_id', 'nofly_data', 'restrictfly_data'); + $noflyData = $noflyDb->where($where)->field($field)->find(); + + if ($noflyData) { + echo json_encode(array('status' => 1, 'msg' => '访问成功', "noflyData" => $noflyData)); + } else { + // 如果没有记录,插入一条空记录 账号首次表里没有对应商铺的记录 顺便为商铺创建一条记录 + $data['shop_id'] = $where['shop_id']; + $data['nofly_data'] = json_encode([]); + $data['restrictfly_data'] = json_encode([]); + $insertId = $noflyDb->add($data); + if ($insertId) { + $newData = $noflyDb->where(['id' => $insertId])->field($field)->find(); + echo json_encode(array('status' => 1, 'msg' => '首次创建禁飞区记录成功', "noflyData" => $newData)); + } else { + echo json_encode(array('status' => 0, 'msg' => '创建禁飞区记录失败')); + } + } + } /** * @description: 飞机在站点上注册航线或注销航线 并处理对应的订单 ps:用处理事务 保证两表同步 */