ADD:添加后台管理端接口;
DEL:删除不必要的头部注释; FIX:修正若干已知错误;
This commit is contained in:
@@ -1,233 +1,306 @@
|
||||
<?php
|
||||
|
||||
# @Author: 嗨噜客(三亚) <fm453>
|
||||
# @Date: 2022-05-22T07:37:26+08:00
|
||||
# @Email: fm453@lukegzs.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2024-08-09T09:20:16+08:00
|
||||
# @Copyright: www.hiluker.cn
|
||||
|
||||
namespace api\controllers\gm\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use addons\models\AcTruck;
|
||||
use addons\models\AcDriver;
|
||||
use addons\models\AcTruckOnline;
|
||||
use addons\models\AcTruckCars;
|
||||
use addons\models\AcStore;
|
||||
use addons\models\AcCar;
|
||||
use addons\models\AcCarBrand;
|
||||
use addons\models\AcCarSeries;
|
||||
use addons\models\AcOrder;
|
||||
use addons\models\AcGps;
|
||||
use addons\models\AcGpsRoute;
|
||||
use addons\models\AcTruckRoute;
|
||||
|
||||
class TruckrouteController extends Common
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
public $online_id = 0;
|
||||
public $truckOl;
|
||||
public function beforeAction($action)
|
||||
{
|
||||
$session = Yii::$app->session;
|
||||
if (isset($_GET['pid']) && (int)$_GET['pid'] > 0) {
|
||||
$session->set('pid', (int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if (!$pid) {
|
||||
return Yii::$app->response->redirect(['index/index']);
|
||||
if (!$this->pid) {
|
||||
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
|
||||
if (!$online_id) {
|
||||
$online_id = $session->get('online_id');
|
||||
} else {
|
||||
$session->set('online_id', $online_id);
|
||||
}
|
||||
if (!$online_id) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '请先选择好要查看的出车大板';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/index', $post]);
|
||||
$return['buttons'] = [
|
||||
['title' => '好的,我知道了', 'class' => 'info', 'url' => $return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
$truckol = $session->get('truckOnline');
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$res = TRUE;
|
||||
if (!$truckol) {
|
||||
$res = $AcTruckOnline->findOne($online_id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
$session->set('truckOnline', $truckol);
|
||||
}
|
||||
}
|
||||
if ($online_id != $truckol['id']) {
|
||||
$res = $AcTruckOnline->findOne($online_id);
|
||||
if ($res) {
|
||||
$truck_id = $res->truck_id;
|
||||
$store_id = $res->from_store;
|
||||
$store2_id = $res->end_store;
|
||||
$truckol = $res->toArray();
|
||||
|
||||
$AcStore = new AcStore();
|
||||
$store = $AcStore->findOne($store_id);
|
||||
if ($store) {
|
||||
$truckol['fromstore_title'] = $store->title;
|
||||
}
|
||||
$store2 = $AcStore->findOne($store2_id);
|
||||
if ($store2) {
|
||||
$truckol['endstore_title'] = $store2->title;
|
||||
}
|
||||
$session->set('truckOnline', $truckol);
|
||||
}
|
||||
}
|
||||
if (!$res) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '请先选择好要查看的出车大板';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['truckol/index', $post]);
|
||||
$return['buttons'] = [
|
||||
['title' => '好的,我知道了', 'class' => 'info', 'url' => $return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
if($online_id > 0){
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
$truckOl = $AcTruckOnline->findOne($online_id);
|
||||
if(!$truckOl) $this->result('未找到的关联板车任务!',[],404);
|
||||
$this->truckOl = $truckOl;
|
||||
$this->online_id = $online_id;
|
||||
}
|
||||
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev', []);
|
||||
$apis = [
|
||||
'list' => '板车路线记录列表',
|
||||
'detail' => '路线记录详情',
|
||||
'add'=>'添加',
|
||||
'edit'=>'编辑',
|
||||
'delete'=>'删除',
|
||||
'show'=>'显示',
|
||||
'hide'=>'隐藏',
|
||||
'ajax'=>'ajax操作'
|
||||
];
|
||||
$this->result('您正使用CMTS-GM系统在途板车路线管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//所有板车位置记录列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=', 'pid', Yii::$app->session->get('pid')];
|
||||
if ($online_id) {
|
||||
$where[] = ['=', 'online_id', $online_id];
|
||||
}
|
||||
$where[] = ['=', 'deleted', 0];
|
||||
$data = $AcTruckRoute->find()->where($where)->orderby('orderby ASC,id DESC');
|
||||
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
|
||||
$truck_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$truck_ids[] = $r->truck_id;
|
||||
}
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=', 'pid', $pid];
|
||||
$where[] = ['IN', 'id', $truck_ids];
|
||||
$where[] = ['=', 'deleted', 0];
|
||||
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
|
||||
return $this->render('list', [
|
||||
'list' => $res,
|
||||
'pager' => $pages,
|
||||
'status' => $status,
|
||||
'trucks' => $trucks,
|
||||
'online_id' => $online_id,
|
||||
'truckol' => $truckol
|
||||
]);
|
||||
$s = $this->search();
|
||||
$res = $s['res'];
|
||||
if (!$res) {
|
||||
$this->result('没有查询到相应的数据!', [], 0);
|
||||
}
|
||||
$data= [
|
||||
'total'=>$s['query']->count(),
|
||||
'routes' => $res,
|
||||
'truckOls' => $s['truckOls'],
|
||||
'trucks' => $s['trucks'],
|
||||
'page'=>$this->page
|
||||
];
|
||||
$this->result('板车路线记录查询成功!', $data, 200);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
public function actionDetail()
|
||||
{
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$AcTruckRoute = [];
|
||||
$AcTruckRoute['status_code'] = 0;
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$AcTruckRoute['truck_id'] = $truckol['truck_id'];
|
||||
$AcTruckRoute['truck_num'] = $truckol['truck_num'];
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id <= 0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcTruckRoute();
|
||||
$detail = $model->findOne($id)->toArray();
|
||||
if(!$detail) $this->result('未查询到相应数据');
|
||||
$this->result('查询成功!', $detail, 200);
|
||||
}
|
||||
|
||||
public function actionAdd()
|
||||
{
|
||||
//数据预检查、编排
|
||||
$data = $this->preSave('add');
|
||||
if(!$data) $this->result('数据预检查未通过,保存失败', $data, 100);
|
||||
|
||||
return $this->render('modify', ['status' => $status, 'detail' => $AcTruckRoute, 'online_id' => $online_id, 'truckol' => $truckol]);
|
||||
//保存资料
|
||||
$model = new AcTruckRoute();
|
||||
foreach ($data as $key=>$val) {
|
||||
$model->$key = $val;
|
||||
}
|
||||
$res = $model->save();
|
||||
$msg = '数据保存失败!';
|
||||
if(!$res) $this->result($msg, [], 100);
|
||||
|
||||
$msg = '数据保存成功!';
|
||||
$return = [];
|
||||
$return['id']= $model->attributes['id']; //获取插入后id;
|
||||
$this->result($msg,$return, 200);
|
||||
}
|
||||
|
||||
//编辑板车位置信息
|
||||
public function actionEdit()
|
||||
{
|
||||
$id = Yii::$app->request->get('id'); //记录ID
|
||||
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
$detail = $this->preUpdate();
|
||||
//数据预检查、编排
|
||||
$data = $this->preSave('edit');
|
||||
if(!$data) $this->result('数据预检查未通过,保存失败', $data, 100);
|
||||
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
$route = $AcTruckRoute->findOne($id);
|
||||
if (!$route) {
|
||||
$post = Yii::$app->request->post();
|
||||
$return = [];
|
||||
$return['msg'] = '位置记录数据获取异常,请重新选择获取';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = '';
|
||||
$return['buttons'] = [
|
||||
['title' => '好的,我知道了', 'class' => 'info', 'url' => $return['url']]
|
||||
];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = 'warning';
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
$route = $route->toArray();
|
||||
$route['truck_id'] = $truckol['truck_id'];
|
||||
$route['online_id'] = $online_id;
|
||||
$route['truck_num'] = $truckol['truck_num'];
|
||||
//保存资料
|
||||
foreach ($data as $key=>$val) {
|
||||
$detail->$key = $val;
|
||||
}
|
||||
$res = $detail->save();
|
||||
$msg = '数据编辑失败!';
|
||||
if(!$res) $this->result($msg, [], 100);
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
return $this->render('modify', ['status' => $status, 'detail' => $route, 'online_id' => $online_id, 'truckol' => $truckol]);
|
||||
$msg = '数据编辑成功!';
|
||||
$return = [];
|
||||
$return['data']= $detail;
|
||||
$this->result($msg,$return, 200);
|
||||
}
|
||||
|
||||
//保存位置记录信息
|
||||
public function actionSave()
|
||||
//删除记录
|
||||
public function actionDelete()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$online_id = Yii::$app->session->get('online_id');
|
||||
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
|
||||
$detail = $this->preUpdate();
|
||||
if ($detail->deleted != 0) {
|
||||
$this->result('数据已被删除过,操作无效', [], 400);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['truck_id'] = $truckol['truck_id'];
|
||||
$data['online_id'] = $online_id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = $detail->deleted + 1;
|
||||
|
||||
//保存资料
|
||||
foreach ($data as $key=>$val) {
|
||||
$detail->$key = $val;
|
||||
}
|
||||
$res = $detail->save();
|
||||
$msg = '板车路线记录删除失败!';
|
||||
if(!$res) $this->result($msg, [], 100);
|
||||
|
||||
$msg = '板车路线记录删除成功!';
|
||||
$this->result($msg,[], 200);
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$detail = $this->preUpdate();
|
||||
$get = Yii::$app->request->get();
|
||||
$msg = '';
|
||||
$errorCode = 0;
|
||||
$_time = time();
|
||||
$detail->update_at = $_time;
|
||||
$res = true;
|
||||
|
||||
switch ($get['do']) {
|
||||
case 'show':
|
||||
if ($detail->status_code != 1) {
|
||||
$detail->status_code = 1;
|
||||
$res = $detail->save();
|
||||
}
|
||||
if ($res) {
|
||||
$msg = '记录显示标记成功';
|
||||
$errorCode = 200;
|
||||
} else {
|
||||
$msg = '记录显示标记失败';
|
||||
$errorCode = 0;
|
||||
}
|
||||
break;
|
||||
case 'hide':
|
||||
if ($detail->status_code != 0) {
|
||||
$detail->status_code = 0;
|
||||
$res = $detail->save();
|
||||
}
|
||||
if ($res) {
|
||||
$msg = '记录隐藏标记成功';
|
||||
$errorCode = 200;
|
||||
} else {
|
||||
$msg = '记录隐藏标记失败';
|
||||
$errorCode = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$this->result($msg, [], $errorCode);
|
||||
}
|
||||
|
||||
private function search(){
|
||||
$pid = $this->pid;
|
||||
$model = new AcTruckRoute();
|
||||
$where = [];
|
||||
$where[] = ['=', 'pid', $pid];
|
||||
if($this->online_id){
|
||||
$where[] = ['=', 'online_id', $this->online_id];
|
||||
}
|
||||
|
||||
$post = $this->postdata;
|
||||
$search = $post['search'] ?? [];
|
||||
|
||||
//板车
|
||||
$search['truck_id'] = isset($search['truck_id']) ? (int)$search['turck_id'] : 0;
|
||||
if ($search['truck_id']) {
|
||||
$where[] = ['=', 'truck_id', $search['truck_id']];
|
||||
}
|
||||
|
||||
$where[] = ['=', 'deleted', 0];
|
||||
|
||||
$data = $model->find()->where($where);
|
||||
|
||||
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $this->pageSize]);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('orderby ASC')->all();
|
||||
|
||||
$AcTruck = new AcTruck();
|
||||
if ($search['truck_id']) {
|
||||
$trucks[$search['truck_id']] = $AcTruck->findOne($search['truck_id']);
|
||||
}else{
|
||||
$truck_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$truck_ids[] = $r->truck_id;
|
||||
}
|
||||
$truck_ids = array_unique($truck_ids);
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=', 'pid', $pid];
|
||||
$where[] = ['IN', 'id', $truck_ids];
|
||||
$where[] = ['=', 'deleted', 0];
|
||||
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
|
||||
}
|
||||
|
||||
$AcTruckOnline = new AcTruckOnline();
|
||||
if ($this->online_id) {
|
||||
$truckOls[$this->online_id] = $this->truckOl;
|
||||
}else{
|
||||
$truckOl_ids = [];
|
||||
foreach ($res as $r) {
|
||||
$truckOl_ids[] = $r->online_id;
|
||||
}
|
||||
$truckOl_ids = array_unique($truckOl_ids);
|
||||
$where = [];
|
||||
$where[] = 'and';
|
||||
$where[] = ['=', 'pid', $pid];
|
||||
$where[] = ['IN', 'id', $truckOl_ids];
|
||||
$where[] = ['=', 'deleted', 0];
|
||||
$truckOls = $AcTruckOnline->find()->where($where)->indexby('id')->all();
|
||||
}
|
||||
|
||||
return ['res'=>$res,'query'=>$data,'trucks'=>$trucks,'truckOls'=>$truckOls];
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据更新前的预检查,返回对应关联数据
|
||||
* 必须确保get与post数据中均包含需更新的数据id且一致
|
||||
* */
|
||||
private function preUpdate()
|
||||
{
|
||||
$id = (int)Yii::$app->request->get('id');
|
||||
if(!$id) $this->result('请求错误,未携带ID参数');
|
||||
$post = $this->postdata;
|
||||
if($post['id'] != $id) $this->result('传参id与请求数据不匹配',[],403);
|
||||
$model = new AcTruckRoute();
|
||||
$res = $model->findOne($id);
|
||||
if(!$res) $this->result('未查询到相应数据',[],404);
|
||||
if($res->pid != $this->pid) $this->result('非本平台数据,不允许操作',[],401);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/*
|
||||
* 数据保存前的预检查(查重、参数校验等)
|
||||
* 要保存的数据[],直接从post中取出
|
||||
* @op,操作类型(add,edit……)
|
||||
* 校验机制:
|
||||
* 编辑数据时,必须用get方式传入参数id,并与post进来的数据id进行比对,只有一致时才能继续;
|
||||
* 查重:禁止录入重复数据
|
||||
* 返回:校验重组后的数据
|
||||
* */
|
||||
private function preSave($op)
|
||||
{
|
||||
$post = $this->postdata;
|
||||
$data = [];
|
||||
$_time = time();
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['longt' => 'lng', 'lat' => 'lat', 'addr' => 'addr'];
|
||||
switch ($op) {
|
||||
case 'add':
|
||||
if(!$this->online_id) $this->result('未关联板车装载任务,保存失败',[],403);
|
||||
$data['online_id'] = $this->online_id;
|
||||
$data['truck_id'] = $this->truckOl->truck_id;
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
break;
|
||||
case 'edit':
|
||||
$id = (int)Yii::$app->request->get('id');
|
||||
$_id = (int)$post['id'];
|
||||
if(!$id != $_id) $this->result('id参数不匹配,请检查');
|
||||
$data['update_at'] = $_time;
|
||||
break;
|
||||
}
|
||||
$data['pid'] = $this->pid;
|
||||
$cols = ['longt' => 'lng', 'lat' => 'lat', 'addr' => 'addr','province'=>'province','city'=>'city'];
|
||||
foreach ($cols as $col => $key) {
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
@@ -237,142 +310,6 @@
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
|
||||
$_time = time();
|
||||
$key = 'update_at';
|
||||
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
|
||||
|
||||
if (!$id) {
|
||||
$data['create_at'] = $_time;
|
||||
}
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存位置资料
|
||||
$AcTruckRoute = new AcTruckRoute();
|
||||
foreach ($data as $key => $val) {
|
||||
$AcTruckRoute->$key = $val;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$res = $AcTruckRoute->updateAll($data, ['id' => $id]);
|
||||
} else {
|
||||
$res = $AcTruckRoute->save();
|
||||
$id = $AcTruckRoute->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
if ($res) {
|
||||
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
|
||||
return $this->redirect(['edit', 'id' => $id]);
|
||||
} else {
|
||||
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除记录
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$return = [];
|
||||
|
||||
$model = new AcTruckRoute();
|
||||
$route = $model->findOne($id);
|
||||
if (!$route) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->pid != $pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->deleted != 0) {
|
||||
$return['msg'] = '数据已被删除过,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$route->deleted = 1;
|
||||
$res = $route->save();
|
||||
|
||||
$return['url'] = '';
|
||||
$return['timeout'] = 1; //n秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if ($res) {
|
||||
$return['msg'] = '位置记录删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
} else {
|
||||
$return['msg'] = '位置记录删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$return = [];
|
||||
|
||||
$model = new AcTruckRoute();
|
||||
$route = $model->findOne($id);
|
||||
if (!$route) {
|
||||
$return['msg'] = '数据不存在,删除失败';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($route->pid != $pid) {
|
||||
$return['msg'] = '非本平台数据,不允许操作';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
if ($route->deleted != 0) {
|
||||
$return['msg'] = '数据已被删除,操作无效';
|
||||
$return['errorcode'] = 400;
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$return['timeout'] = 1; //n秒后自动跳转
|
||||
$res = TRUE;
|
||||
switch ($get['do']) {
|
||||
case 'show':
|
||||
if ($route->status_code != 1) {
|
||||
$route->status_code = 1;
|
||||
$res = $route->save();
|
||||
}
|
||||
if ($res) {
|
||||
$return['msg'] = '记录显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css' => 'success'];
|
||||
} else {
|
||||
$return['msg'] = '客车上板标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'hide':
|
||||
if ($route->status_code != 0) {
|
||||
$route->status_code = 0;
|
||||
$res = $route->save();
|
||||
}
|
||||
if ($res) {
|
||||
$return['msg'] = '记录隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css' => 'success'];
|
||||
} else {
|
||||
$return['msg'] = '客车上板标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user