# @Date: 2022-04-24T20:28:47+08:00 # @Email: fm453@lukegzs.com # @Last modified by: fm453 # @Last modified time: 2024-08-09T09:00:10+08:00 # @Copyright: www.hiluker.cn namespace api\controllers\client\v1; use Yii; use yii\data\Pagination; use addons\models\AcOrder; class OrdercheckController extends Common { public function beforeAction($action) { if (!$this->pid) { $this->result('您正使用本系统内部接口,禁止非法链接使用!'); } return parent::beforeAction($action); } public function actionIndex() { $apis = [ 'basic' => '基础验车', //启运网点 'online' => '中转验车', 'arrive' => '到站验车', //目的地网点 ]; $this->result('您正使用CMTS系统运单验车管理接口!', $apis, 200); } public function actionBasic() { $pid = $this->pid; $status = Yii::$app->params['OrderStatus']; $post = $this->postdata; $id = isset($post['oid']) ? $post['oid'] : 0; if ($id <= 0) { $this->result('查询参数错误!'); } $AcOrder = new AcOrder(); $order = $AcOrder->findOne($id); if (!$order) { $this->result('该运单数据不存在!'); } if (!isset($post['checks'])) { $this->result('验车参数错误!'); } $checks = $post['checks']; //需要更新的验车信息 //判断执行权限 S if (!$this->user_info) { $this->result('无有效用户登陆信息,无权操作!'); } if (!$this->user_id !== $order->from_mid) { // $this->result('不是当前用户的运单,无权操作!'); } //判断执行权限 E $hasChange = 0; //是否有需要更新的数据 $op = isset($post['op']) ? $post['op'] : ''; $isOss = TRUE; //是否启用OSS服务 switch ($op) { case 'data': $hasChange = 1; $checker = isset($checks['checker']) ? trim($checks['checker']) : ''; $order->checker = $checker ? $checker : $this->user_info->username; $start_km = isset($checks['start_km']) ? (int)$checks['start_km'] : 0; $order->start_km = $start_km; $is_driving_lisence = isset($checks['is_driving_lisence']) ? (int)$checks['is_driving_lisence'] : 0; $order->no_driving_lisence = $is_driving_lisence == 1 ? 1 : 0; $car_extra = isset($checks['car_extra']) ? trim($checks['car_extra']) : ''; $order->car_extra = $car_extra; break; case 'driving_lisence': $k = 'driving_lisence'; if (isset($checks[$k]) && $checks[$k]) { if (!$isOss) { $file = Yii::getAlias('@upload-src') . $checks[$k]; if (file_exists($file)) { $hasChange = 1; $order->$k = $checks[$k]; } } else { $hasChange = 1; $order->$k = $checks[$k]; } } break; case 'thumb_f': $k = 'thumb_f'; if (isset($checks[$k]) && $checks[$k]) { if (!$isOss) { $file = Yii::getAlias('@upload-src') . $checks[$k]; if (file_exists($file)) { $hasChange = 1; $order->$k = $checks[$k]; } } else { $hasChange = 1; $order->$k = $checks[$k]; } } break; case 'thumb_b': $k = 'thumb_b'; if (isset($checks[$k]) && $checks[$k]) { $file = Yii::getAlias('@upload-src') . $checks[$k]; if (file_exists($file)) { $hasChange = 1; $order->$k = $checks[$k]; } } break; case 'thumb_l': $k = 'thumb_l'; if (isset($checks[$k]) && $checks[$k]) { if (!$isOss) { $file = Yii::getAlias('@upload-src') . $checks[$k]; if (file_exists($file)) { $hasChange = 1; $order->$k = $checks[$k]; } } else { $hasChange = 1; $order->$k = $checks[$k]; } } break; case 'thumb_r': $k = 'thumb_r'; if (isset($checks[$k]) && $checks[$k]) { if (!$isOss) { $file = Yii::getAlias('@upload-src') . $checks[$k]; if (file_exists($file)) { $hasChange = 1; $order->$k = $checks[$k]; } } else { $hasChange = 1; $order->$k = $checks[$k]; } } break; case 'thumbs': $k = 'thumbs'; if (isset($checks[$k]) && $checks[$k]) { $hasChange = 1; $thumbs = json_encode($checks[$k]); $order->$k = $thumbs; } break; case 'all': $keys = ['driving_lisence', 'thumb_f', 'thumb_b', 'thumb_l', 'thumb_r']; foreach ($keys as $k) { if (isset($checks[$k]) && $checks[$k]) { if (!$isOss) { $file = Yii::getAlias('@upload-src') . $checks[$k]; if (file_exists($file)) { $hasChange = 1; $order->$k = $checks[$k]; } } else { $hasChange = 1; $order->$k = $checks[$k]; } } } $k = 'thumbs'; if (isset($checks[$k]) && $checks[$k]) { $hasChange = 1; $thumbs = json_encode($checks[$k]); $order->$k = $thumbs; } $checker = isset($checks['checker']) ? trim($checks['checker']) : ''; $order->checker = $checker ? $checker : $this->user_info->username; $start_km = isset($checks['start_km']) ? (int)$checks['start_km'] : 0; $order->start_km = $start_km; $is_driving_lisence = isset($checks['is_driving_lisence']) ? (int)$checks['is_driving_lisence'] : 0; $order->no_driving_lisence = $is_driving_lisence == 1 ? 1 : 0; $car_extra = isset($checks['car_extra']) ? trim($checks['car_extra']) : ''; $order->car_extra = $car_extra; if ($hasChange) { $order->is_checked = 1; } break; } if ($hasChange) { $res = $order->save(); $this->result('操作完成!', $order->toArray(), 200); } else { $this->result('没有要更新的数据!', NULL, 200); } } }