barcode = $item["barcode"]; // 序列号前缀 } if (isset($item["device_id"])) { $upgradeLogModel->device_id = $item["device_id"]; // 设备ID } if (isset($item["manufacture_id"])) { $upgradeLogModel->manufacture_id = $item["manufacture_id"]; // 厂商ID } if (isset($item["project_id"])) { $upgradeLogModel->project_id = $item["project_id"]; // 项目ID } if (isset($item["model_id"])) { $upgradeLogModel->model_id = $item["model_id"]; // 设备型号ID } if (isset($item["package_name"])) { $upgradeLogModel->package_name = $item["package_name"]; // 包名 } if (isset($item["current_version"])) { $upgradeLogModel->current_version = $item["current_version"]; // 当前版本 } if (isset($item["target_version"])) { $upgradeLogModel->target_version = $item["target_version"]; // 目标版本 } if (isset($item["status"])) { $upgradeLogModel->status = $item["status"]; // 升级状态,1:下载成功,2:取消下载,3:开始升级,4:取消升级,5:升级成功 } if (isset($item["error_code"])) { $upgradeLogModel->error_code = $item["error_code"]; // 错误码 } if (isset($item["timestamp"])) { $upgradeLogModel->timestamp = $item["timestamp"]; // } if (isset($item["type"])) { $upgradeLogModel->type = $item["type"]; // 日志类型 1 app 2.ota整机 } $saveResult = $upgradeLogModel->save(); return $saveResult; } catch (Exception $e) { return false; } } /** * 更新版本日志 * @param $id * @param $item * @return null|static */ static function update($id, $item) { $upgradeLogModel = UpgradeLogModel::findOne($id); if (empty($upgradeLogModel)) { return false; } if (isset($item["barcode"])) { $upgradeLogModel->barcode = $item["barcode"]; // 序列号前缀 } if (isset($item["device_id"])) { $upgradeLogModel->device_id = $item["device_id"]; // 设备ID } if (isset($item["manufacture_id"])) { $upgradeLogModel->manufacture_id = $item["manufacture_id"]; // 厂商ID } if (isset($item["project_id"])) { $upgradeLogModel->project_id = $item["project_id"]; // 项目ID } if (isset($item["model_id"])) { $upgradeLogModel->model_id = $item["model_id"]; // 设备型号ID } if (isset($item["current_version"])) { $upgradeLogModel->current_version = $item["current_version"]; // 当前版本 } if (isset($item["target_version"])) { $upgradeLogModel->target_version = $item["target_version"]; // 目标版本 } if (isset($item["status"])) { $upgradeLogModel->status = $item["status"]; // 升级状态,1:下载成功,2:取消下载,3:开始升级,4:取消升级,5:升级成功 } if (isset($item["error_code"])) { $upgradeLogModel->error_code = $item["error_code"]; // 错误码 } if (isset($item["type"])) { $upgradeLogModel->type = $item["type"]; // 日志类型 1 app 2.ota整机 } $resultSave = $upgradeLogModel->save(); return $resultSave; } /** * 删除版本日志 * @param $id * @param $item * @return null|static */ public static function delete($id) { $upgradeModel = UpgradeLogModel::findOne($id); if (empty($upgradeModel)) { return false; } return UpgradeLogModel::deleteAll(["id" => $id]); } }