【类 型】:

【原  因】:
【过  程】:
【影  响】:
This commit is contained in:
air 2025-06-18 18:26:37 +08:00
parent 5e18cd260f
commit ec34269485

View File

@ -524,30 +524,48 @@ class PlaneController extends PublicController
public function setNoflyData() public function setNoflyData()
{ {
if ($_REQUEST['shop_id']) { if ($_REQUEST['shop_id']) {
if ($this->tokenShop_id != C('powerId')) { // 非总管理员 if ($this->tokenShop_id != C('powerId')) {
$where['shop_id'] = $this->tokenShop_id; $where['shop_id'] = $this->tokenShop_id;
} else { } else {
$where['shop_id'] = $_REQUEST['shop_id']; // 总管理员可指定 shop_id $where['shop_id'] = $_REQUEST['shop_id'];
} }
$noflyDb = D('nofly'); $noflyDb = D('nofly');
// 要更新的数据 $data = [];
if ($_REQUEST['nofly_data']) {
// 判断是禁飞区更新
if (isset($_REQUEST['nofly_data']) && !isset($_REQUEST['restrictfly_data']) && !isset($_REQUEST['restrictfly_height'])) {
$data['nofly_data'] = $_REQUEST['nofly_data']; $data['nofly_data'] = $_REQUEST['nofly_data'];
} else { $updateType = 'nofly';
$data['nofly_data'] = "[]";
} }
if ($_REQUEST['restrictfly_data']) {
// 判断是限飞区更新
if (isset($_REQUEST['restrictfly_data']) && isset($_REQUEST['restrictfly_height'])) {
$restrictData = json_decode($_REQUEST['restrictfly_data'], true);
$restrictHeight = json_decode($_REQUEST['restrictfly_height'], true);
// 校验数组长度是否一致
if (!is_array($restrictData) || !is_array($restrictHeight) || count($restrictData) !== count($restrictHeight)) {
$this->ajaxReturn(['status' => 0, 'msg' => '限制飞区坐标组与高度组数量不一致']);
}
$data['restrictfly_data'] = $_REQUEST['restrictfly_data']; $data['restrictfly_data'] = $_REQUEST['restrictfly_data'];
} else { $data['restrictfly_height'] = $_REQUEST['restrictfly_height'];
$data['nofly_data'] = "[]"; $updateType = 'restrict';
} }
if ($noflyDb->where($where)->save($data)) {
$this->ajaxReturn(['status' => 1, 'msg' => '禁飞区数据更新成功']); if (empty($data)) {
$this->ajaxReturn(['status' => 0, 'msg' => '未提交任何可更新的数据']);
}
if ($noflyDb->where($where)->save($data) !== false) {
$msg = ($updateType === 'restrict') ? '限制飞区数据更新成功' : '禁飞区数据更新成功';
$this->ajaxReturn(['status' => 1, 'msg' => $msg]);
} else { } else {
$this->ajaxReturn(['status' => 0, 'msg' => '禁飞区数据更新失败']); $this->ajaxReturn(['status' => 0, 'msg' => '数据更新失败']);
} }
} else { } else {
echo json_encode(array('status' => 0, 'msg' => '参数有误')); echo json_encode(['status' => 0, 'msg' => '参数有误']);
} }
} }
/** /**