From 92ac719fbf1955e1edba5af98d15307b22cfc169 Mon Sep 17 00:00:00 2001 From: szdot Date: Fri, 12 Jul 2024 04:40:06 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=09=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afactor=20=E3=80=90=E4=B8=BB=09=E9=A2=98=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E5=90=8E=E7=AB=AF=20=E6=A3=80=E6=B5=8B=20=E5=85=B6?= =?UTF-8?q?=E5=AE=83=E7=AB=99=E7=82=B9=E6=98=AF=E5=90=A6=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E6=9C=89=20=E9=87=8D=E5=A4=8D=E7=9A=84=E6=B3=A8=E5=86=8C=20?= =?UTF-8?q?=E6=88=96=E6=B3=A8=E9=94=80=E9=A3=9E=E6=9C=BA=20=E3=80=90?= =?UTF-8?q?=E6=8F=8F=09=E8=BF=B0=E3=80=91=EF=BC=9A=20=09[=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0]=EF=BC=9A=20=09[=E8=BF=87=E7=A8=8B]=EF=BC=9A=20=09[?= =?UTF-8?q?=E5=BD=B1=E5=93=8D]=EF=BC=9A=20=E3=80=90=E7=BB=93=09=E6=9D=9F?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- .../Controller/PlaneController.class.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/FlyCube/MpApi/Controller/PlaneController.class.php b/FlyCube/MpApi/Controller/PlaneController.class.php index 7272f20..f17c3cd 100644 --- a/FlyCube/MpApi/Controller/PlaneController.class.php +++ b/FlyCube/MpApi/Controller/PlaneController.class.php @@ -168,11 +168,31 @@ class PlaneController extends PublicController $rsDb = D('receive_site'); $where['id'] = $_REQUEST['id']; $where['shop_id'] = $_REQUEST['shop_id']; - //后端检测 + /*端检测后*/ + //检查站点是否绑定了航线 $rsCheck = $rsDb->where($where)->find(); if ($rsCheck['bind_route'] == null || $rsCheck['bind_route'] == '') { exit(json_encode(array('status' => 0, 'msg' => '此站点未绑定航线!'))); } + //遍历检查提交的runing 和其它列表是否有重复值 ps:防止 正在执行其它站点的任务 又在此站点注销 或者注册 + $whereAll['shop_id'] = $_REQUEST['shop_id']; //排除此站点 + $whereAll['id'] = array('neq', $_REQUEST['id']); + + $submittedRuning = $_REQUEST['runing'] ?? ''; // 获取传入的 runing 字段,并按逗号分割成数组 + $submittedRuningArray = explode(',', $submittedRuning); + + $otherRecords = $rsDb->where($whereAll)->select(); // 查询数据库中符合条件的所有记录 + foreach ($otherRecords as $record) { + $existingRuning = $record['runing'] ?? ''; + $existingRuningArray = explode(',', $existingRuning); + // 检查两个数组是否有重复元素 + $intersection = array_intersect($submittedRuningArray, $existingRuningArray); + if (!empty($intersection)) { + exit(json_encode(array('status' => 0, 'msg' => '提交的航线与其他站点重复!'))); + } + } + + /*提交 注册 或 注销信息*/ // 如果 $_REQUEST['runing'] 为空字符串 或者null,将其设置为 null $data['runing'] = trim($_REQUEST['runing']) === '' ? null : trim($_REQUEST['runing']);