【类 型】:

【原  因】:
【过  程】:
【影  响】:
This commit is contained in:
air 2025-06-16 23:30:33 +08:00
parent 956c25b154
commit 417d0dbd2f

View File

@ -555,35 +555,40 @@ class PlaneController extends PublicController
*/ */
public function getNoflyData() public function getNoflyData()
{ {
if ($_REQUEST['shop_id']) { if (!isset($_REQUEST['shop_id'])) {
if ($this->tokenShop_id != C('powerId')) { // 非总管理员 echo json_encode(['status' => 0, 'msg' => '缺少参数 shop_id']);
$where['shop_id'] = $this->tokenShop_id; exit;
} else {
$where['shop_id'] = $_REQUEST['shop_id']; // 总管理员可指定 shop_id
} }
$shop_id = $_REQUEST['shop_id'];
if ($this->tokenShop_id != C('powerId')) {
$shop_id = $this->tokenShop_id;
}
$where['shop_id'] = $shop_id;
$noflyDb = D('nofly'); $noflyDb = D('nofly');
$field = array('id', 'shop_id', 'nofly_data', 'restrictfly_data'); $field = ['id', 'shop_id', 'nofly_data', 'restrictfly_data'];
$noflyData = $noflyDb->where($where)->field($field)->find(); $noflyData = $noflyDb->where($where)->field($field)->find();
if ($noflyData) { if ($noflyData) {
echo json_encode(array('status' => 1, 'msg' => '访问成功', "noflyData" => $noflyData)); echo json_encode(['status' => 1, 'msg' => '访问成功', 'noflyData' => $noflyData]);
} else { } else {
// 如果没有记录,插入一条空记录 账号首次表里没有对应商铺的记录 顺便为商铺创建一条记录 // 插入空记录
$data['shop_id'] = $where['shop_id']; $data = [
$data['nofly_data'] = json_encode([]); 'shop_id' => $shop_id,
$data['restrictfly_data'] = json_encode([]); 'nofly_data' => '[]',
'restrictfly_data' => '[]'
];
$insertId = $noflyDb->add($data); $insertId = $noflyDb->add($data);
if ($insertId) { if ($insertId) {
$newData = $noflyDb->where(['id' => $insertId])->field($field)->find(); $newData = $noflyDb->where(['id' => $insertId])->field($field)->find();
echo json_encode(array('status' => 1, 'msg' => '首次创建禁飞区记录成功', "noflyData" => $newData)); echo json_encode(['status' => 1, 'msg' => '首次创建禁飞区记录成功', 'noflyData' => $newData]);
} else { } else {
echo json_encode(array('status' => 0, 'msg' => '创建禁飞区记录失败')); echo json_encode(['status' => 0, 'msg' => '创建禁飞区记录失败']);
} }
} }
} else {
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
}
} }
/** /**
* @description: 飞机在站点上注册航线或注销航线 并处理对应的订单 ps:用处理事务 保证两表同步 * @description: 飞机在站点上注册航线或注销航线 并处理对应的订单 ps:用处理事务 保证两表同步