This commit is contained in:
tianshujie98
2020-09-25 16:19:19 +08:00
parent 06c3f67886
commit 69f45681f4
+18 -6
View File
@@ -1231,10 +1231,11 @@ class storyModel extends model
*/
public function batchChangePlan($storyIdList, $planID, $oldPlanID = 0)
{
$now = helper::now();
$allChanges = array();
$oldStories = $this->getByList($storyIdList);
$plan = $this->loadModel('productplan')->getById($planID);
$now = helper::now();
$allChanges = array();
$oldStories = $this->getByList($storyIdList);
$plan = $this->loadModel('productplan')->getById($planID);
$oldStoryStages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->in($storyIdList)->fetchGroup('story', 'branch');
foreach($storyIdList as $storyID)
{
$oldStory = $oldStories[$storyID];
@@ -1248,16 +1249,27 @@ class storyModel extends model
if($this->session->currentProductType == 'normal' or empty($oldPlanID) or $oldStory->branch)
{
$story->plan = $planID;
if($planID and $oldStory->stage == 'wait') $story->stage = 'planned';
}
elseif($oldPlanID)
{
$story->plan = trim(str_replace(",$oldPlanID,", ',', ",$oldStory->plan,"), ',');
if(empty($story->branch)) $story->plan .= ",$planID";
}
if($planID) $story->stage = 'planned';
if($planID and $this->session->currentProductType != 'normal' and $oldStory->branch == 0)
{
if(!isset($oldStoryStages[$storyID][$plan->branch]))
{
$story->stage = 'planned';
$newStoryStage = new stdclass();
$newStoryStage->story = $storyID;
$newStoryStage->branch = $plan->branch;
$newStoryStage->stage = $story->stage;
$this->dao->insert(TABLE_STORYSTAGE)->data($newStoryStage)->autoCheck()->exec();
}
}
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
$this->dao->update(TABLE_STORYSTAGE)->set('stage')->eq($story->stage)->autoCheck()->where('story')->eq((int)$storyID)->exec();
if(!$planID) $this->setStage($storyID);
if(!dao::isError()) $allChanges[$storyID] = common::createChanges($oldStory, $story);