【类 型】:feat
【原 因】:增加getNofly 接口 获取禁飞区记录 【过 程】:如果商铺账号第一次访问接口 表里并没对应记录 顺便创建对应商铺的记录 【影 响】:
This commit is contained in:
parent
046cd39166
commit
b7b94971d2
@ -542,6 +542,37 @@ class PlaneController extends PublicController
|
||||
echo json_encode(array('status' => 0, 'msg' => '参数有误'));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 获取禁飞区数据(如果没有就插入空记录)
|
||||
*/
|
||||
public function getNofly()
|
||||
{
|
||||
if ($this->tokenShop_id != C('powerId')) { // 非总管理员
|
||||
$where['shop_id'] = $this->tokenShop_id;
|
||||
} else {
|
||||
$where['shop_id'] = $_REQUEST['shopId']; // 总管理员可指定 shop_id
|
||||
}
|
||||
|
||||
$noflyDb = D('nofly');
|
||||
$field = array('id', 'shop_id', 'nofly_data', 'restrictfly_data');
|
||||
$noflyData = $noflyDb->where($where)->field($field)->find();
|
||||
|
||||
if ($noflyData) {
|
||||
echo json_encode(array('status' => 1, 'msg' => '访问成功', "noflyData" => $noflyData));
|
||||
} else {
|
||||
// 如果没有记录,插入一条空记录 账号首次表里没有对应商铺的记录 顺便为商铺创建一条记录
|
||||
$data['shop_id'] = $where['shop_id'];
|
||||
$data['nofly_data'] = json_encode([]);
|
||||
$data['restrictfly_data'] = json_encode([]);
|
||||
$insertId = $noflyDb->add($data);
|
||||
if ($insertId) {
|
||||
$newData = $noflyDb->where(['id' => $insertId])->field($field)->find();
|
||||
echo json_encode(array('status' => 1, 'msg' => '首次创建禁飞区记录成功', "noflyData" => $newData));
|
||||
} else {
|
||||
echo json_encode(array('status' => 0, 'msg' => '创建禁飞区记录失败'));
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 飞机在站点上注册航线或注销航线 并处理对应的订单 ps:用处理事务 保证两表同步
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user