ADD:添加后台管理端接口;

DEL:删除不必要的头部注释;
FIX:修正若干已知错误;
This commit is contained in:
2025-07-13 19:40:10 +08:00
parent 0a45e55cca
commit 270b881437
66 changed files with 8618 additions and 8129 deletions
+275 -477
View File
@@ -1,50 +1,235 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-22T07:38:28+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2024-08-09T09:20:02+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;
class TruckcarController extends Common
{
public function beforeAction($action)
{
if (!$this->pid) {
$this->result('您正使用本系统内部接口,禁止非法链接使用!');
}
return parent::beforeAction($action);
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev', []);
$apis = [
'list' => '承运清单',
'detail' => '承运详情',
'get-status'=>'获取运输状态字典',
'add'=>'添加',
'edit'=>'编辑',
'delete'=>'删除',
'show'=>'显示',
'hide'=>'隐藏',
'ajax'=>'ajax操作'
];
$this->result('您正使用CMTS-GM系统板车承运管理接口!', $apis, 200);
}
public function actionGetStatus(){
$status = Yii::$app->params['TruckCarsStatus'];
$this->result('板车装载状态字典', $status, 200);
}
//所有装车记录列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$s = $this->search();
$res = $s['res'];
if (!$res) {
$this->result('没有查询到相应的数据!', [], 0);
}
$data= [
'total'=>$s['query']->count(),
'truck_cars' => $res,
'cars' => $s['cars'],
'page'=>$this->page
];
$this->result('板车列表查询成功!', $data, 200);
}
public function actionDetail()
{
$pid = $this->pid;
$post = $this->postdata;
$id = isset($post['id']) ? $post['id'] : 0;
if ($id <= 0) {
$this->result('查询参数错误!');
}
$model = new AcTruckCars();
$detail = $model->findOne($id)->toArray();
if(!$detail) $this->result('未查询到相应数据');
$data = $this->showTruck($detail);
$this->result('查询成功!', $data, 200);
}
public function actionAdd()
{
//数据预检查、编排
$data = $this->preSave('add');
if(!$data) $this->result('数据预检查未通过,保存失败', $data, 100);
//保存资料
$model = new AcTruckCars();
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()
{
$detail = $this->preUpdate();
//数据预检查、编排
$data = $this->preSave('edit');
if(!$data) $this->result('数据预检查未通过,保存失败', $data, 100);
//保存资料
foreach ($data as $key=>$val) {
$detail->$key = $val;
}
$res = $detail->save();
$msg = '数据编辑失败!';
if(!$res) $this->result($msg, [], 100);
$msg = '数据编辑成功!';
$return = [];
$return['data']= $detail;
$this->result($msg,$return, 200);
}
//删除板车
public function actionDelete()
{
$detail = $this->preUpdate();
if ($detail->deleted != 0) {
$this->result('数据已被删除过,操作无效', [], 400);
}
$data = [];
$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;
$online_id = $detail->online_id;
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
$order_id = $detail->order_id;
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
switch ($get['do']) {
case 'intruck':
//上板
if ($detail->status_code != 0) {
$this->result('当前运单并非待承运状态,操作无效',[], 400);
}
$detail->status_code = 1;
$res = $detail->save();
if ($res) {
//增加板车一辆装车统计
$truckol->update_at = $_time;
$truckol->updateCounters(['cars' => 1]);
$truckol->save();
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 2;
$order->save();
$msg = '客车上板标记成功';
$errorCode = 200;
} else {
$msg = '客车上板标记失败';
$errorCode = 100;
}
break;
case 'arrive':
//运达
if ($detail->status_code == 0) {
$this->result('当前运单尚待承运,操作无效',[], 400);
}
$detail->status_code = 99;
$detail->to_time = $_time;
$res = $detail->save();
if ($res) {
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 3;
$order->save();
$msg = '客车运达标记记成功';
$errorCode = 200;
} else {
$this->result('客车运达标记失败',[], 100);
}
break;
case 'fix':
//处理质损
$data['status_code'] = 80;
if ($detail->status_code != 1) {
$this->result('当前运单并非运输中状态,操作无效',[], 400);
}
$res = $detail->save();
if ($res) {
$msg = '客车运达标记记成功';
$errorCode = 200;
} else {
$this->result('客车运损标记失败',[], 100);
}
break;
default:
break;
}
$this->result($msg,[], $errorCode);
}
private function search(){
$pid = $this->pid;
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
$AcTruckCars = new AcTruckCars();
$return = [];
$model = new AcTruckCars();
$where = [];
$where[] = 'and';
$where[] = ['=', 'pid', Yii::$app->session->get('pid')];
$where[] = ['=', 'pid', $pid];
$post = $this->postdata;
$search = $post['search'] ?? [];
$search = isset($post['search']) ? $post['search'] : [];
$search['start_city'] = isset($search['start_city']) ? trim(htmlspecialchars_decode($search['start_city'])) : '';
if (!empty($search['start_city'])) {
$where[] = ['LIKE', 'from_city', $search['start_city']];
@@ -54,15 +239,12 @@
$where[] = ['LIKE', 'to_city', $search['aim_city']];
}
$search['car_id'] = isset($search['car_id']) ? (int)$search['car_id'] : 0;
$CarModel = new AcCar();
if (!empty($search['car_id'])) {
if (!$search['car_id']) {
$where[] = ['=', 'car_id', $search['car_id']];
$car = $CarModel->findOne($search['car_id']);
$search['car_title'] = isset($car->title) ? $car->title : '';
}
$search['status_code'] = isset($search['status_code']) ? $search['status_code'] : 'all';
if ($search['status_code'] != 'all') {
$where[] = ['=', 'status_code', (int)$search['status_code']];
$search['status_code'] = isset($search['status_code']) ? (int)$search['status_code'] : 0;
if ($search['status_code']) {
$where[] = ['=', 'status_code', $search['status_code']];
}
//按月份筛选
$search['start_m'] = isset($search['start_m']) ? $search['start_m'] : '';
@@ -76,8 +258,10 @@
}
$where[] = ['=', 'deleted', 0];
$data = $AcTruckCars->find()->where($where);
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '20']);
$data = $model->find()->where($where);
$pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => $this->pageSize]);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('status_code ASC,id DESC')->all();
$car_ids = [];
@@ -93,470 +277,84 @@
$where[] = ['=', 'deleted', 0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['TruckCarsStatus'];
return $this->render('list', [
'list' => $res,
'pager' => $pages,
'status' => $status,
'cars' => $cars,
'search' => $search
]);
return ['res'=>$res,'query'=>$data,'cars'=>$cars];
}
public function actionNew()
/*
* 数据更新前的预检查,返回对应关联数据
* 必须确保get与post数据中均包含需更新的数据id且一致
* */
private function preUpdate()
{
$status = Yii::$app->params['TruckCarsStatus'];
$AcTruckCars = [];
$AcTruckCars['status_code'] = 0;
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
$AcTruckCars['online_id'] = $online_id;
$order_id = Yii::$app->request->get('order_id'); //待承运订单ID
$AcTruckCars['order_id'] = $order_id;
$car_id = Yii::$app->request->get('car_id'); //待装客车ID
$AcTruckCars['car_id'] = $car_id;
return $this->render('create', ['status' => $status, 'detail' => $AcTruckCars]);
$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 AcTruckCars();
$res = $model->findOne($id);
if(!$res) $this->result('未查询到相应数据',[],404);
if($res->pid != $this->pid) $this->result('非本平台数据,不允许操作',[],401);
return $res;
}
//编辑客车上板信息
public function actionEdit()
{
$id = Yii::$app->request->get('id'); //承运单ID
$truck_id = $online_id = $store_id = $store2_id = 0;
$truckCar = $truckol = [];
$AcTruckCars = new AcTruckCars();
$res = $AcTruckCars->findOne($id);
if ($res) {
$truckCar = $res->toArray();
$online_id = $res->online_id;
$store2_id = $res->to_store;
$store_id = $res->from_store;
$order_id = $res->order_id;
/*
* 数据保存前的预检查(查重、参数校验等)
* 要保存的数据[],直接从post中取出
* @op,操作类型(add,edit……)
* 校验机制:
* 编辑数据时,必须用get方式传入参数id,并与post进来的数据id进行比对,只有一致时才能继续;
* 查重:禁止录入重复数据
* 返回:校验重组后的数据
* */
private function preSave($op)
{
$post = $this->postdata;
/*出车计划判断*/
$online_id = $post['online_id'] ?? 0;
if (!(int)$online_id) {
$this->result('未关联板车出车计划信息,保存失败',[],400);
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$AcTruckOnline = new AcTruckOnline();
$res = $AcTruckOnline->findOne($online_id);
if ($res) {
$truck_id = $res->truck_id;
$truckol = $res->toArray();
$truckol = $AcTruckOnline->findOne($online_id);
if (!$truckol) {
$this->result('未找到指定板车出车计划,保存失败',[],404);
}
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if (!$truck) {
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truck/list', $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');
}
$truckCar['truck_id'] = $truck_id;
$truckCar['truck_title'] = $truck->num_p . $truck->num_area . $truck->num_left;
$truckCar['truck_num'] = $truckCar['truck_title'] ? $truckCar['truck_title'] : $truckol['truck_num'];
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if ($store) {
$truckCar['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if ($store2) {
$truckCar['endstore_title'] = $store2->title;
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
$truckCar['driver_title'] = $truckCar['driver_mobile'] = '';
if ($driver) {
$truckCar['driver_title'] = $driver->name;
$truckCar['driver_mobile'] = $driver->mobile;
}
$truckCar['from_time'] = !empty($truckCar['from_time']) ? $truckCar['from_time'] : $truckol['from_date'];
$truckCar['to_time'] = !empty($truckCar['to_time']) ? $truckCar['to_time'] : $truckol['end_date'];
$from_city = $order->start_city;
$truckCar['from_city'] = !empty($truckCar['from_city']) ? $truckCar['from_city'] : $from_city;
$truckCar['from_city'] = $truckCar['from_city'] ? $truckCar['from_city'] : $truckol['from_city'];
$end_city = $order->aim_city;
$truckCar['to_city'] = !empty($truckCar['to_city']) ? $truckCar['to_city'] : $end_city;
$truckCar['to_city'] = $truckCar['to_city'] ? $truckCar['to_city'] : $truckol['end_city'];
$truckCar['driver_name'] = isset($truckCar['driver_name']) ? $truckCar['driver_name'] : $truckol['driver_name'];
$truckCar['driver_mobiles'] = isset($truckCar['driver_mobiles']) ? $truckCar['driver_mobiles'] : $truckol['driver_mobiles'];
$status = Yii::$app->params['TruckCarsStatus'];
return $this->render('modify', ['status' => $status, 'detail' => $truckCar]);
}
//保存客车上板信息(直接指派方式)
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$data = [];
//格式化数据
//目标键=》POST键
$model = new AcTruckCars();
switch ($op) {
case 'add':
$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;
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$cols = ['from_city' => 'from_city', 'to_city' => 'to_city'];
foreach ($cols as $col => $key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['online_id' => 'online_id', 'from_store' => 'from_store', 'to_store' => 'to_store'];
if (isset($_GET['debug']) && ($_GET['debug'] == 1)) {
$cols['status_code'] = 'status_code';
$cols = ['to_time' => 'to_time', 'from_time' => 'from_time'];
foreach ($cols as $col => $key) {
if (isset($post[$key]) && $post[$key] != "") $data[$key] = strtotime($post[$key]);
}
$cols = ['from_store' => 'from_store', 'to_store' => 'to_store', 'order_id' => 'order_id', 'car_id' => 'car_id','status_code'=>'status_code'];
foreach ($cols as $col => $key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
/*出车计划判断*/
$online_id = $data['online_id'];
if (!$online_id) {
$return['msg'] = '未关联板车出车计划信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
if (!$truckol) {
$return['msg'] = '未找到指定板车出车计划,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'to_time';
if (isset($post[$key]) && $post[$key] != "") {
$data[$key] = strtotime($post[$key]);
}
$key = 'from_time';
if (isset($post[$key]) && $post[$key] != "") {
$data[$key] = strtotime($post[$key]);
}
if (!$id) {
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;
$data['pid'] = $pid;
//保存上板信息
$AcTruckCars = new AcTruckCars();
foreach ($data as $key => $val) {
$AcTruckCars->$key = $val;
}
if ($id) {
$res = $AcTruckCars->updateAll($data, ['id' => $id]);
} else {
$res = $AcTruckCars->save();
$id = $AcTruckCars->attributes['id']; //获取插入后id
}
if ($res) {
//修改对应运单状态
$_code = 0;
if (isset($data['status_code'])) {
if ($data['status_code'] == 1) {
$_code = 2;
} else if ($data['status_code'] == 99) {
$_code = 3;
}
}
if ($_code) {
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
if (!$order_id) {
$car = $AcTruckCars->findOne($id);
$order_id = $car->order_id;
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$order->update_at = $_time;
$order->status_code = $_code;
$order->save();
}
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit', 'id' => $id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//保存客车上板信息(板车出车界面车辆管理方式)
public function actionSave2()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['from_city' => 'from_city', 'to_city' => 'to_city'];
foreach ($cols as $col => $key) {
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['online_id' => 'online_id', 'from_store' => 'from_store', 'to_store' => 'to_store', 'order_id' => 'order_id', 'car_id' => 'car_id'];
if (isset($_GET['debug']) && ($_GET['debug'] == 1)) {
$cols['status_code'] = 'status_code';
}
foreach ($cols as $col => $key) {
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
/*出车计划判断*/
$online_id = $data['online_id'];
if (!$online_id) {
$return['msg'] = '未关联板车出车计划信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
if (!$truckol) {
$return['msg'] = '未找到指定板车出车计划,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'to_time';
if (isset($post[$key]) && $post[$key] != "") {
$data[$key] = strtotime($post[$key]);
}
$key = 'from_time';
if (isset($post[$key]) && $post[$key] != "") {
$data[$key] = strtotime($post[$key]);
}
if (!$id) {
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;
$data['pid'] = $pid;
//保存上板信息
$AcTruckCars = new AcTruckCars();
foreach ($data as $key => $val) {
$AcTruckCars->$key = $val;
}
if ($id) {
$res = $AcTruckCars->updateAll($data, ['id' => $id]);
} else {
$res = $AcTruckCars->save();
$id = $AcTruckCars->attributes['id']; //获取插入后id
}
if ($res) {
//修改对应运单状态
$_code = 0;
if (isset($data['status_code'])) {
if ($data['status_code'] == 1) {
$_code = 2;
} else if ($data['status_code'] == 99) {
$_code = 3;
}
}
if ($_code) {
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
if (!$order_id) {
$car = $AcTruckCars->findOne($id);
$order_id = $car->order_id;
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$order->update_at = $_time;
$order->status_code = $_code;
$order->save();
}
\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');
$data = $return = [];
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcTruckCars();
$car = $model->findOne($id);
if (!$car) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->pid != $pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->deleted != 0) {
$return['msg'] = '数据已被删除过,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
foreach ($data as $key => $val) {
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data, ['id' => $id]);
$return['url'] = Url::toRoute('truckcar/list');
$return['timeout'] = 3; //3秒后自动跳转
$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');
$data = $return = [];
$_time = time();
$data['update_at'] = $_time;
$model = new AcTruckCars();
$car = $model->findOne($id);
if (!$car) {
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->pid != $pid) {
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($car->deleted != 0) {
$return['msg'] = '数据已被删除,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$online_id = $car->online_id;
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
$order_id = $car->order_id;
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$return['timeout'] = 1; //n秒后自动跳转
$where = ['id' => $id];
switch ($get['do']) {
case 'intruck':
if ($car->status_code != 0) {
$return['msg'] = '当前运单并非待承运状态,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 1;
$data['from_time'] = $_time;
$res = $model->updateAll($data, $where);
if ($res) {
//增加板车一辆装车统计
$truckol->update_at = $_time;
$truckol->updateCounters(['cars' => 1]);
$truckol->save();
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 2;
$order->save();
$return['msg'] = '客车上板标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css' => 'success'];
} else {
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
case 'arrive':
if ($car->status_code == 0) {
$return['msg'] = '当前任务尚待承运,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 99;
$data['to_time'] = $_time;
$res = $model->updateAll($data, $where);
if ($res) {
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 3;
$order->save();
$return['msg'] = '客车运达标记记成功';
$return['errorcode'] = 200;
$return['data'] = ['css' => 'primary'];
} else {
$return['msg'] = '客车运达标记失败';
$return['errorcode'] = 0;
}
break;
case 'fix':
$data['status_code'] = 80;
if ($car->status_code != 1) {
$return['msg'] = '当前运单并非运输中状态,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '客车运达标记记成功';
$return['errorcode'] = 200;
$return['data'] = ['css' => 'primary'];
} else {
$return['msg'] = '客车运达标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
return $data;
}
}