From 956c25b154a23802eec677f92a66a85023967a1a Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Mon, 16 Jun 2025 23:16:04 +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=9A=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91=EF=BC=9A?= =?UTF-8?q?=20=E3=80=90=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=20?= =?UTF-8?q?=E3=80=90=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 | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index 47ae289..ead610f 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -555,30 +555,34 @@ class PlaneController extends PublicController */ public function getNoflyData() { - if ($this->tokenShop_id != C('powerId')) { // 非总管理员 - $where['shop_id'] = $this->tokenShop_id; - } else { - $where['shop_id'] = $_REQUEST['shop_id']; // 总管理员可指定 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)); + if ($_REQUEST['shop_id']) { + if ($this->tokenShop_id != C('powerId')) { // 非总管理员 + $where['shop_id'] = $this->tokenShop_id; } else { - echo json_encode(array('status' => 0, 'msg' => '创建禁飞区记录失败')); + $where['shop_id'] = $_REQUEST['shop_id']; // 总管理员可指定 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' => '创建禁飞区记录失败')); + } + } + } else { + echo json_encode(array('status' => 0, 'msg' => '参数有误')); } } /**