* Refactor fixFirst method.

This commit is contained in:
tianshujie
2023-08-31 15:01:21 +08:00
parent 199afc7d67
commit 243cf04eb6
5 changed files with 40 additions and 31 deletions
+6 -17
View File
@@ -3901,28 +3901,17 @@ class executionModel extends model
}
/**
* 修改燃尽图首天工时。
* Fix burn for first day.
*
* @param int $executionID
* @param object $burn
* @access public
* @return void
* @return bool
*/
public function fixFirst($executionID)
public function fixFirst(object $burn): bool
{
$execution = $this->getById($executionID);
$burn = $this->dao->select('*')->from(TABLE_BURN)->where('execution')->eq($executionID)->andWhere('date')->eq($execution->begin)->andWhere('task')->eq(0)->fetch();
$withLeft = $this->post->withLeft ? $this->post->withLeft : 0;
$data = fixer::input('post')
->add('execution', $executionID)
->add('date', $execution->begin)
->add('left', $withLeft ? $this->post->estimate : $burn->left)
->add('consumed', empty($burn) ? 0 : $burn->consumed)
->remove('withLeft')
->get();
if(!is_numeric($data->estimate)) return false;
$this->dao->replace(TABLE_BURN)->data($data)->exec();
$this->dao->replace(TABLE_BURN)->data($burn)->exec();
return !dao::isError();
}
/**