【类 型】:feat

【主	题】:注册航线接口 修改
【描	述】:
	[原因]:检查是否有重复id 防止bug
	[过程]:注册前先 检查所有站点 已经注册的航线 是否有重复的飞机id
	[影响]:
【结	束】

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

View File

@ -157,14 +157,27 @@ class PlaneController extends PublicController
} }
} }
/** /**
* @description: 锁定送餐点的航线 * @description: 飞机在站点上注册航线
*/ */
public function lockSite() public function lockSite()
{ {
//总管理员 可接收任何shop_id 非总管理员 只可以调用自身shop_id 否则会中断 //总管理员 可接收任何shop_id 非总管理员 只可以调用自身shop_id 否则会中断
$this->isPower(); $this->isPower();
if ($_REQUEST['id'] && $_REQUEST['runing']) { if ($_REQUEST['id'] && $_REQUEST['plane_id'] && $_REQUEST['runing']) {
$rsDb = D('receive_site');
$where['id'] = $_REQUEST['id'];
$where['shop_id'] = $_REQUEST['shop_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;
}
}
//注册航线
if ($_REQUEST['runing'] == "null") { if ($_REQUEST['runing'] == "null") {
$data['runing'] = null; $data['runing'] = null;
$msg = "已注销执行航线"; $msg = "已注销执行航线";
@ -172,8 +185,7 @@ class PlaneController extends PublicController
$data['runing'] = $_REQUEST['runing']; $data['runing'] = $_REQUEST['runing'];
$msg = "已注册执行航线"; $msg = "已注册执行航线";
} }
$where['id'] = $_REQUEST['id'];
$rsDb = D('receive_site');
if ($rsDb->where($where)->save($data)) { if ($rsDb->where($where)->save($data)) {
echo json_encode(array('status' => 1, 'msg' => $msg)); echo json_encode(array('status' => 1, 'msg' => $msg));
} else { } else {