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']);