【类 型】:fix

【主	题】:注册注销航线接口 后端检测 绑定航线字段是不是空  空的话打断 返回状态码 提示前端
【描	述】:
	[原因]:
	[过程]:
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
szdot 2024-07-12 03:35:46 +08:00
parent 82a07bbd15
commit af83cd5f80

View File

@ -168,27 +168,18 @@ class PlaneController extends PublicController
$rsDb = D('receive_site');
$where['id'] = $_REQUEST['id'];
$where['shop_id'] = $_REQUEST['shop_id'];
//航线注册 合法检查 ps:注销跳过此步骤
if ($_REQUEST['plane_id'] != "") { //注册航线调用接口时会传飞机id过来
$rsCheck = $rsDb->where($where)->select();
foreach ($rsCheck as $key => $value) {
$runingPlanes = explode(',', $value['runing']);
if (in_array($_REQUEST['plane_id'], $runingPlanes)) {
echo json_encode(array('status' => 0, 'msg' => '此飞机已经注册过航线了!'));
exit;
}
}
$msg = "已注册执行航线";
} else {
$msg = "已注销执行航线";
//后端检测
$rsCheck = $rsDb->where($where)->find();
if ($rsCheck['bind_route'] == null || $rsCheck['bind_route'] == '') {
echo json_encode(array('status' => 0, 'msg' => '此站点未绑定航线!'));
}
// 如果 $_REQUEST['runing'] 为空字符串,将其设置为 '' 而不是 NULL
$data['runing'] = $_REQUEST['runing'] !== null ? $_REQUEST['runing'] : '';
// 如果 $_REQUEST['runing'] 为空字符串 或者null将其设置为 null
$data['runing'] = $_REQUEST['runing'] == null || $_REQUEST['runing'] = '' ? '' : $_REQUEST['runing'];
if ($rsDb->where($where)->save($data)) {
echo json_encode(array('status' => 1, 'msg' => '站点航线执行操作成功'));
echo json_encode(array('status' => 1, 'msg' => '站点航线执行操作成功!'));
} else {
echo json_encode(array('status' => 0, 'msg' => '站点航线执行操作失败'));
echo json_encode(array('status' => 0, 'msg' => '站点航线执行操作失败!'));
}
} else {
echo json_encode(array('status' => 0, 'msg' => '参数有误'));