protected function _save($type, $id, $begin_time, $duration, $count)
{
/**
* @var \ManaPHP\Meter\Round\Model $model
* @var \ManaPHP\Meter\Round\Model $instance
*/
$model = new $this->_model();
$hash = md5($type . ':' . $begin_time . '-' . $duration . ':' . $id);
$r = $model::updateAll(['count' => $count], ['hash' => $hash]);
if ($r === 0) {
$instance = new $this->_model();
$instance->hash = $hash;
$instance->type = $type;
$instance->id = $id;
$instance->count = $count;
$instance->begin_time = $begin_time;
$instance->duration = $duration;
$instance->created_time = time();
try {
$instance->create();
} catch (\Exception $e) {
$model::updateAll(['count' => $count], ['hash' => $hash]);
}
}
}